Skip to content

Commit

Permalink
Actors: C_Lift support; bump to 2.31
Browse files Browse the repository at this point in the history
  • Loading branch information
Greavesy1899 committed Mar 26, 2024
1 parent 25d99ae commit a1a8a5f
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 4 deletions.
1 change: 1 addition & 0 deletions Mafia2Libs/Controls/ActorItemAddOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public ActorItemAddOption()
TypeCombo.Items.Add(ActorTypes.C_Item);
TypeCombo.Items.Add(ActorTypes.C_Door);
TypeCombo.Items.Add(ActorTypes.Tree);
TypeCombo.Items.Add(ActorTypes.Lift);
TypeCombo.Items.Add(ActorTypes.C_Sound);
TypeCombo.Items.Add(ActorTypes.StaticEntity);
TypeCombo.Items.Add(ActorTypes.Garage);
Expand Down
6 changes: 3 additions & 3 deletions Mafia2Libs/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Mafia: Toolkit")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.29")]
[assembly: AssemblyFileVersion("2.29")]
[assembly: AssemblyVersion("2.31")]
[assembly: AssemblyFileVersion("2.31")]
2 changes: 2 additions & 0 deletions Mafia2Libs/ResourceTypes/FileTypes/Actors/ActorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public static IActorExtraDataInterface CreateExtraData(ActorTypes type)
return new ActorDoor();
case ActorTypes.Tree:
return new ActorTree();
case ActorTypes.Lift:
return new ActorLift();
case ActorTypes.C_Sound:
return new ActorSoundEntity();
case ActorTypes.StaticEntity:
Expand Down
138 changes: 138 additions & 0 deletions Mafia2Libs/ResourceTypes/FileTypes/Actors/ActorTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2755,4 +2755,142 @@ public int GetSize()
return 328;
}
}

public class ActorLift : ActorPhysicsBase
{
[Category("C_Lift")]
public int InitialFloor { get; set; }
[Category("C_Lift")]
public float MotionSpeed { get; set; }
[Category("C_Lift")]
public float AcceleratingDistance { get; set; }
[Category("C_Lift")]
public float BreakingDistance { get; set; }
[Category("C_Lift")]
public string LightFrameName { get; set; } // limited to 32
[Category("C_Lift")]
public string LinkerPrefix { get; set; } // limited to 32
[Category("C_Lift")]
public int SoundCategoryId { get; set; }
[Category("C_Lift")]
public int AcceleratingSoundId { get; set; }
[Category("C_Lift")]
public int BreakingSoundId { get; set; }
[Category("C_Lift")]
public int MovingSoundId { get; set; }
[Category("C_Lift")]
public int ButtonSoundId { get; set; }
[Category("C_Lift")]
public bool bAutomaticDoorOpen { get; set; }
[Category("C_Lift")]
public string Door1Name { get; set; }
[Category("C_Lift")]
public string Door2Name { get; set; }
[Category("C_Lift")]
public bool bScriptControlled { get; set; }
[Category("C_Lift")]
public int InnerSpaceGraphIndex { get; set; }
[Category("C_Lift")]
public int OverrideFloors { get; set; }
[Category("C_Lift")]
public int SplineType { get; set; }
[Category("C_Lift")]
public float SplineInRange { get; set; }
[Category("C_Lift")]
public int SplineNavigation { get; set; }
[Category("C_Lift")]
public ulong SplineLock0 { get; set; }
[Category("C_Lift")]
public ulong SplineLock1 { get; set; }
[Category("C_Lift")]
public float Unk0 { get; set; }
[Category("C_Lift")]
public float Unk1 { get; set; }
[Category("C_Lift")]
public float Unk2 { get; set; }


public ActorLift()
{
LightFrameName = string.Empty;
LinkerPrefix = string.Empty;
Door1Name = string.Empty;
Door2Name = string.Empty;
}

public override void ReadFromFile(MemoryStream reader, bool isBigEndian)
{
base.ReadFromFile(reader, isBigEndian);

reader.Seek(240, SeekOrigin.Begin);

InitialFloor = reader.ReadInt32(isBigEndian);
MotionSpeed = reader.ReadSingle(isBigEndian);
AcceleratingDistance = reader.ReadSingle(isBigEndian);
BreakingDistance = reader.ReadSingle(isBigEndian);
LightFrameName = reader.ReadStringBuffer(32);
LinkerPrefix = reader.ReadStringBuffer(32);
SoundCategoryId = reader.ReadInt32(isBigEndian);
AcceleratingSoundId = reader.ReadInt32(isBigEndian);
BreakingSoundId = reader.ReadInt32(isBigEndian);
MovingSoundId = reader.ReadInt32(isBigEndian);
ButtonSoundId = reader.ReadInt32(isBigEndian);
bAutomaticDoorOpen = Convert.ToBoolean(reader.ReadByte8());
Door1Name = reader.ReadStringBuffer(64);
Door2Name = reader.ReadStringBuffer(64);
bScriptControlled = Convert.ToBoolean(reader.ReadByte8());
reader.Seek(2, SeekOrigin.Current); // padding?
InnerSpaceGraphIndex = reader.ReadInt32(isBigEndian);
OverrideFloors = reader.ReadInt32(isBigEndian);
SplineType = reader.ReadInt32(isBigEndian);
SplineInRange = reader.ReadSingle(isBigEndian);
SplineNavigation = reader.ReadInt32(isBigEndian);
SplineLock0 = reader.ReadUInt64(isBigEndian);
SplineLock1 = reader.ReadUInt64(isBigEndian);
Unk0 = reader.ReadSingle(isBigEndian);
Unk1 = reader.ReadSingle(isBigEndian);
Unk2 = reader.ReadSingle(isBigEndian);

}

public override void WriteToFile(MemoryStream writer, bool isBigEndian)
{
base.WriteToFile(writer, isBigEndian);

// Write padding
writer.Write(new byte[GetSize() - writer.Length]);
writer.Position = 240;

writer.Write(InitialFloor, isBigEndian);
writer.Write(MotionSpeed, isBigEndian);
writer.Write(AcceleratingDistance, isBigEndian);
writer.Write(BreakingDistance, isBigEndian);
writer.WriteStringBuffer(32, LightFrameName);
writer.WriteStringBuffer(32, LinkerPrefix);
writer.Write(SoundCategoryId, isBigEndian);
writer.Write(AcceleratingSoundId, isBigEndian);
writer.Write(BreakingSoundId, isBigEndian);
writer.Write(MovingSoundId, isBigEndian);
writer.Write(ButtonSoundId, isBigEndian);
writer.WriteByte(Convert.ToByte(bAutomaticDoorOpen));
writer.WriteStringBuffer(64, Door1Name);
writer.WriteStringBuffer(64, Door2Name);
writer.WriteByte(Convert.ToByte(bScriptControlled));
writer.Write((ushort)0, isBigEndian); // padding
writer.Write(InnerSpaceGraphIndex, isBigEndian);
writer.Write(OverrideFloors, isBigEndian);
writer.Write(SplineType, isBigEndian);
writer.Write(SplineNavigation, isBigEndian);
writer.Write(SplineLock0, isBigEndian);
writer.Write(SplineLock1, isBigEndian);
writer.Write(Unk0, isBigEndian);
writer.Write(Unk1, isBigEndian);
writer.Write(Unk2, isBigEndian);
}

public override int GetSize()
{
return 520;
}
}
}
2 changes: 1 addition & 1 deletion Mafia2Libs/Utils/Settings/ToolkitSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class ToolkitSettings

// Update vars
public static float CurrentVersion = 1.0f;
public static readonly float Version = 2.30f;
public static readonly float Version = 2.31f;

public static void ReadINI()
{
Expand Down

0 comments on commit a1a8a5f

Please sign in to comment.