Skip to content

Commit

Permalink
Actors: Added support for C_FramesController
Browse files Browse the repository at this point in the history
  • Loading branch information
Greavesy1899 committed Oct 10, 2023
1 parent e10aca9 commit 892d14b
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions Mafia2Libs/Controls/ActorItemAddOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public ActorItemAddOption()
TypeCombo.Items.Add(ActorTypes.CleanEntity);
TypeCombo.Items.Add(ActorTypes.Radio);
TypeCombo.Items.Add(ActorTypes.Telephone);
TypeCombo.Items.Add(ActorTypes.FramesController);
TypeCombo.SelectedIndex = 0;
}

Expand Down
2 changes: 2 additions & 0 deletions Mafia2Libs/ResourceTypes/FileTypes/Actors/ActorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public static IActorExtraDataInterface CreateExtraData(ActorTypes type)
return new ActorRadio();
case ActorTypes.Telephone:
return new ActorTelephone();
case ActorTypes.FramesController:
return new ActorFramesController();
default:
Console.WriteLine("Cannot read type: " + type);
return null;
Expand Down
55 changes: 55 additions & 0 deletions Mafia2Libs/ResourceTypes/FileTypes/Actors/ActorTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2700,4 +2700,59 @@ public override int GetSize()
return 428;
}
}

public class ActorFramesController : IActorExtraDataInterface
{
public class FramesControllerEntry
{
public ulong SceneNameHash { get; set; }
public ulong FrameNameHash { get; set; }

public override string ToString()
{
return string.Format("Scene: {0} Frame: {1}", SceneNameHash, FrameNameHash);
}
}

public FramesControllerEntry[] Entries { get; set; }
public ulong Unk0 { get; set; }

private const uint NUM_ENTRIES = 20;

public ActorFramesController() : base()
{
Entries = new FramesControllerEntry[NUM_ENTRIES];
for(ulong i = 0; i < NUM_ENTRIES; i++)
{
Entries[i] = new FramesControllerEntry();
}
}

public void ReadFromFile(MemoryStream stream, bool isBigEndian)
{
for (ulong i = 0; i < NUM_ENTRIES; i++)
{
Entries[i].SceneNameHash = stream.ReadUInt64(isBigEndian);
Entries[i].FrameNameHash = stream.ReadUInt64(isBigEndian);
}

Unk0 = stream.ReadUInt64(isBigEndian);
}

public void WriteToFile(MemoryStream writer, bool isBigEndian)
{
for (ulong i = 0; i < NUM_ENTRIES; i++)
{
writer.Write(Entries[i].SceneNameHash, isBigEndian);
writer.Write(Entries[i].FrameNameHash, isBigEndian);
}

writer.Write(Unk0, isBigEndian);
}

public int GetSize()
{
return 328;
}
}
}

0 comments on commit 892d14b

Please sign in to comment.