Skip to content

Commit

Permalink
limbless update
Browse files Browse the repository at this point in the history
  • Loading branch information
igorseabra4 committed Jun 25, 2019
1 parent 76003ec commit d290159
Show file tree
Hide file tree
Showing 10 changed files with 734 additions and 248 deletions.
2 changes: 2 additions & 0 deletions HeroesPowerPlant/HeroesPowerPlant.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@
<Compile Include="LayoutEditor\SetObjects\ObjectClassesShadow\List00\Object0004_DashRamp.cs" />
<Compile Include="LayoutEditor\SetObjects\ObjectClassesShadow\List00\Object000E_Rocket.cs" />
<Compile Include="LayoutEditor\SetObjects\ObjectClassesShadow\List00\Object000F_Platform.cs" />
<Compile Include="LayoutEditor\SetObjects\ObjectClassesShadow\List00\Object0007_Case.cs" />
<Compile Include="LayoutEditor\SetObjects\ObjectClassesShadow\List00\Object0065_GUNBeetle.cs" />
<Compile Include="LayoutEditor\SetObjects\ObjectClassesShadow\List00\Object0012_ItemCapsule.cs" />
<Compile Include="LayoutEditor\SetObjects\ObjectClassesShadow\List00\Object0014_GoalRing.cs" />
<Compile Include="LayoutEditor\SetObjects\ObjectClassesShadow\List00\Object0020_Weapon.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,46 @@ public override void CreateTransformMatrix(Vector3 Position, Vector3 Rotation)
Matrix.Scaling(Scale + 1f) * transformMatrix;
}

private string FloorBase = "S11_ON_FIREA_BASE.DFF";
private string FloorBlue = "S11_ON_FIREA_BLUE.DFF";
private string FloorRed = "S11_ON_FIREA_RED.DFF";
private string AirBase = "S11_ON_FIREB_BASE.DFF";
private string AirBlue = "S11_ON_FIREB_BLUE.DFF";
private string AirRed = "S11_ON_FIREB_RED.DFF";

public override void Draw(SharpRenderer renderer, string[][] modelNames, int modelMiscSetting, bool isSelected)
{
if (BaseType == BaseTypeEnum.None)
DrawCube(renderer, isSelected);
else if (BaseType == BaseTypeEnum.Floor)
{
Draw(renderer, "S11_ON_FIREA_BASE.DFF", isSelected);
if (Program.MainForm.renderer.dffRenderer.DFFModels.ContainsKey(FloorBase))
Draw(renderer, FloorBase, isSelected);
if (IsBlue)
Draw(renderer, "S11_ON_FIREA_BLUE.DFF", isSelected);
{
if (Program.MainForm.renderer.dffRenderer.DFFModels.ContainsKey(FloorBase))
Draw(renderer, FloorBlue, isSelected);
}
else
Draw(renderer, "S11_ON_FIREA_RED.DFF", isSelected);
{
if (Program.MainForm.renderer.dffRenderer.DFFModels.ContainsKey(FloorRed))
Draw(renderer, FloorRed, isSelected);
}
}
else if (BaseType == BaseTypeEnum.Air)
{
Draw(renderer, "S11_ON_FIREB_BASE.DFF", isSelected);
if (Program.MainForm.renderer.dffRenderer.DFFModels.ContainsKey(AirBase))
Draw(renderer, AirBase, isSelected);
if (IsBlue)
Draw(renderer, "S11_ON_FIREB_BLUE.DFF", isSelected);
{
if (Program.MainForm.renderer.dffRenderer.DFFModels.ContainsKey(AirBase))
Draw(renderer, AirBlue, isSelected);
}
else
Draw(renderer, "S11_ON_FIREB_RED.DFF", isSelected);
{
if (Program.MainForm.renderer.dffRenderer.DFFModels.ContainsKey(AirRed))
Draw(renderer, AirRed, isSelected);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace HeroesPowerPlant.LayoutEditor
{
public class Object0007_Case : SetObjectManagerShadow
{
public string Note => "Not all misc. settings are in list yet.";

public int Type
{
get => ReadInt(0);
set => Write(0, value);
}

public float ScaleX
{
get => ReadFloat(4);
set => Write(4, value);
}

public float ScaleY
{
get => ReadFloat(8);
set => Write(8, value);
}

public float ScaleZ
{
get => ReadFloat(12);
set => Write(12, value);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public enum Weapon
GrenadeLauncher = 0x0C,
GUNBazooka = 0x0D,
TankCannon = 0x0E,
BlackBarrel = 0x0F,
BigBarrel = 0x10,
EggBazooka = 0x11,
RPG = 0x12,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace HeroesPowerPlant.LayoutEditor
{
public class Object0065_GUNBeetle : Object_ShadowEmpty
{
public string Note => "Not all misc. settings are in list yet.";

public int Attack
{
get => ReadInt(32);
set => Write(32, value);
}

public float PatrolWidth
{
get => ReadInt(40);
set => Write(40, value);
}

public int Type
{
get => ReadInt(56);
set => Write(56, value);
}

public int Weapon
{
get => ReadInt(60);
set => Write(60, value);
}
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,56 @@
namespace HeroesPowerPlant.LayoutEditor
using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace HeroesPowerPlant.LayoutEditor
{
public class Object_ShadowEmpty : SetObjectManagerShadow
{
[Browsable(true)]
public byte[] MiscSettingsBytes
{
get => MiscSettings;
set => MiscSettings = value;
}

public int[] MiscSettingInts
{
get
{
List<int> result = new List<int>();
for (int i = 0; i < MiscSettings.Length; i += 4)
{
result.Add(BitConverter.ToInt32(MiscSettings, i));
}
return result.ToArray();
}
set
{
List<byte> result = new List<byte>();
foreach (int i in value)
result.AddRange(BitConverter.GetBytes(i));
MiscSettings = result.ToArray();
}
}

public float[] MiscSettingFloats
{
get
{
List<float> result = new List<float>();
for (int i = 0; i < MiscSettings.Length; i += 4)
{
result.Add(BitConverter.ToSingle(MiscSettings, i));
}
return result.ToArray();
}
set
{
List<byte> result = new List<byte>();
foreach (float i in value)
result.AddRange(BitConverter.GetBytes(i));
MiscSettings = result.ToArray();
}
}
}
}
23 changes: 12 additions & 11 deletions HeroesPowerPlant/LayoutEditor/SetObjects/SetObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ namespace HeroesPowerPlant.LayoutEditor
{
public abstract class SetObjectManager
{
// Misc setting related
public byte[] MiscSettings { get; set; }
public byte[] MiscSettings;

// Drawing related
public Matrix transformMatrix;
Expand All @@ -22,17 +21,23 @@ public virtual void Draw(SharpRenderer renderer, string[][] modelNames, int mode
{
int nameIndex = modelMiscSetting == -1 ? 0 : MiscSettings[modelMiscSetting];

bool drew = false;

if (modelNames != null && modelNames.Length > 0 && nameIndex < modelNames.Length)
{
foreach (string s in modelNames[nameIndex])
Draw(renderer, s, isSelected);
else
if (Program.MainForm.renderer.dffRenderer.DFFModels.ContainsKey(s))
{
drew = true;
Draw(renderer, s, isSelected);
}
}
else if (!drew)
DrawCube(renderer, isSelected);
}

protected void Draw(SharpRenderer renderer, string modelName, bool isSelected)
{
if (Program.MainForm.renderer.dffRenderer.DFFModels.ContainsKey(modelName))
{
renderData.worldViewProjection = transformMatrix * renderer.viewProjection;
renderData.Color = isSelected ? renderer.selectedObjectColor : Vector4.One;

Expand All @@ -47,11 +52,7 @@ protected void Draw(SharpRenderer renderer, string modelName, bool isSelected)
renderer.tintedShader.Apply();

Program.MainForm.renderer.dffRenderer.DFFModels[modelName].Render(renderer.Device);
}
else
{
DrawCube(renderer, isSelected);
}

}

protected void DrawCube(SharpRenderer renderer, bool isSelected)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using SharpDX;
using System;
using System.Collections.Generic;

namespace HeroesPowerPlant.LayoutEditor
{
public abstract class SetObjectManagerShadow : SetObjectManager
public class SetObjectManagerShadow : SetObjectManager
{
public override void CreateTransformMatrix(Vector3 Position, Vector3 Rotation)
{
Expand All @@ -18,46 +17,6 @@ public override void CreateTransformMatrix(Vector3 Position, Vector3 Rotation)
Matrix.Translation(Position);
}

public int[] MiscSettingInts
{
get
{
List<int> result = new List<int>();
for (int i = 0; i < MiscSettings.Length; i += 4)
{
result.Add(BitConverter.ToInt32(MiscSettings, i));
}
return result.ToArray();
}
set
{
List<byte> result = new List<byte>();
foreach (int i in value)
result.AddRange(BitConverter.GetBytes(i));
MiscSettings = result.ToArray();
}
}

public float[] MiscSettingFloats
{
get
{
List<float> result = new List<float>();
for (int i = 0; i < MiscSettings.Length; i += 4)
{
result.Add(BitConverter.ToSingle(MiscSettings, i));
}
return result.ToArray();
}
set
{
List<byte> result = new List<byte>();
foreach (float i in value)
result.AddRange(BitConverter.GetBytes(i));
MiscSettings = result.ToArray();
}
}

public int ReadInt(int j) => BitConverter.ToInt32(MiscSettings, j);

public float ReadFloat(int j) => BitConverter.ToSingle(MiscSettings, j);
Expand Down
2 changes: 2 additions & 0 deletions HeroesPowerPlant/LayoutEditor/SetObjects/SetObjectShadow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ private SetObjectManagerShadow FindObjectManager()
{
case 0x01: case 0x02: case 0x03: case 0x06: return new Object00_SpringShadow();
case 0x04: return new Object0004_DashRamp();
case 0x07: return new Object0007_Case();
case 0x0E: return new Object000E_Rocket();
case 0x0F: return new Object000F_Platform();
case 0x10: return new Object0010_Ring();
case 0x12: return new Object0012_ItemCapsule();
case 0x14: return new Object0014_GoalRing();
case 0x1F: return new SetObjectManagerShadow(); // warp hole
case 0x20: return new Object0020_Weapon();
case 0x4F: return new Object004F_Vehicle();
default: return new Object_ShadowEmpty();
Expand Down
Loading

0 comments on commit d290159

Please sign in to comment.