From 892d14b14a1e3f84b5f9274988951bf7f133b8bc Mon Sep 17 00:00:00 2001 From: Greavesy1899 Date: Tue, 10 Oct 2023 17:13:43 +0100 Subject: [PATCH] Actors: Added support for C_FramesController --- Mafia2Libs/Controls/ActorItemAddOption.cs | 1 + .../FileTypes/Actors/ActorFactory.cs | 2 + .../FileTypes/Actors/ActorTypes.cs | 55 +++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/Mafia2Libs/Controls/ActorItemAddOption.cs b/Mafia2Libs/Controls/ActorItemAddOption.cs index c1c3d350..134b10a3 100644 --- a/Mafia2Libs/Controls/ActorItemAddOption.cs +++ b/Mafia2Libs/Controls/ActorItemAddOption.cs @@ -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; } diff --git a/Mafia2Libs/ResourceTypes/FileTypes/Actors/ActorFactory.cs b/Mafia2Libs/ResourceTypes/FileTypes/Actors/ActorFactory.cs index 79f4b740..014f95ac 100644 --- a/Mafia2Libs/ResourceTypes/FileTypes/Actors/ActorFactory.cs +++ b/Mafia2Libs/ResourceTypes/FileTypes/Actors/ActorFactory.cs @@ -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; diff --git a/Mafia2Libs/ResourceTypes/FileTypes/Actors/ActorTypes.cs b/Mafia2Libs/ResourceTypes/FileTypes/Actors/ActorTypes.cs index 91717673..c77488d2 100644 --- a/Mafia2Libs/ResourceTypes/FileTypes/Actors/ActorTypes.cs +++ b/Mafia2Libs/ResourceTypes/FileTypes/Actors/ActorTypes.cs @@ -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; + } + } }