public static void RM_Mod_SyncScripts(TwinsFile RM_Archive, ChunkType chunk) { if (RM_Archive.ContainsItem((uint)RM_Sections.Code)) { TwinsSection code_section = RM_Archive.GetItem <TwinsSection>((uint)RM_Sections.Code); if (code_section.ContainsItem((uint)RM_Code_Sections.Script)) { TwinsSection script_section = code_section.GetItem <TwinsSection>((uint)RM_Code_Sections.Script); if (script_section.Records.Count > 0) { List <uint> scripts = new List <uint>(); for (int i = 0; i < script_section.Records.Count; i++) { scripts.Add(script_section.Records[i].ID); script_section.RemoveItem(script_section.Records[i].ID); } for (int i = 0; i < scripts.Count; i++) { script_section.Records.Add(Twins_Data.allScripts[scripts[i]]); } } } } }
public static void RM_Mod_ClassicExplosions(TwinsFile RM_Archive, Script GenericCrateExplode) { if (RM_Archive.ContainsItem((uint)RM_Sections.Code)) { TwinsSection code_section = RM_Archive.GetItem <TwinsSection>((uint)RM_Sections.Code); if (code_section.ContainsItem((uint)RM_Code_Sections.Script)) { TwinsSection script_section = code_section.GetItem <TwinsSection>((uint)RM_Code_Sections.Script); if (script_section.Records.Count > 0) { if (script_section.ContainsItem((uint)ScriptID.COM_GENERIC_CRATE_EXPLODE)) { script_section.RemoveItem((uint)ScriptID.COM_GENERIC_CRATE_EXPLODE); script_section.Records.Add(GenericCrateExplode); } } } } }
public static void RM_SwitchCharactersMod(TwinsFile RM_Archive, Script StrafeLeft, Script StrafeRight) { if (RM_Archive.ContainsItem((uint)RM_Sections.Code)) { TwinsSection code_section = RM_Archive.GetItem <TwinsSection>((uint)RM_Sections.Code); bool containsCharacter = false; if (code_section.ContainsItem((uint)RM_Code_Sections.Object)) { TwinsSection obj_section = code_section.GetItem <TwinsSection>((uint)RM_Code_Sections.Object); if (obj_section.Records.Count > 0) { for (int obj = 0; obj < obj_section.Records.Count; obj++) { if (obj_section.Records[obj].ID == (uint)ObjectID.CRASH) { GameObject gameObj = (GameObject)obj_section.Records[obj]; gameObj.Scripts[(int)CharacterGameObjectScriptOrder.OnStrafeLeft] = (ushort)ScriptID.HEAD_COM_GENERIC_CHARACTER_STRAFE_LEFT; gameObj.Scripts[(int)CharacterGameObjectScriptOrder.OnStrafeRight] = (ushort)ScriptID.HEAD_COM_GENERIC_CHARACTER_STRAFE_RIGHT; obj_section.Records[obj] = gameObj; containsCharacter = true; } else if (obj_section.Records[obj].ID == (uint)ObjectID.CORTEX) { GameObject gameObj = (GameObject)obj_section.Records[obj]; gameObj.Scripts[(int)CharacterGameObjectScriptOrder.OnStrafeLeft] = (ushort)ScriptID.HEAD_COM_GENERIC_CHARACTER_STRAFE_LEFT; gameObj.Scripts[(int)CharacterGameObjectScriptOrder.OnStrafeRight] = (ushort)ScriptID.HEAD_COM_GENERIC_CHARACTER_STRAFE_RIGHT; obj_section.Records[obj] = gameObj; containsCharacter = true; } else if (obj_section.Records[obj].ID == (uint)ObjectID.NINA) { GameObject gameObj = (GameObject)obj_section.Records[obj]; gameObj.Scripts[(int)CharacterGameObjectScriptOrder.OnStrafeLeft] = (ushort)ScriptID.HEAD_COM_GENERIC_CHARACTER_STRAFE_LEFT; gameObj.Scripts[(int)CharacterGameObjectScriptOrder.OnStrafeRight] = (ushort)ScriptID.HEAD_COM_GENERIC_CHARACTER_STRAFE_RIGHT; obj_section.Records[obj] = gameObj; containsCharacter = true; } } } } if (containsCharacter) { if (code_section.ContainsItem((uint)RM_Code_Sections.Script)) { TwinsSection script_section = code_section.GetItem <TwinsSection>((uint)RM_Code_Sections.Script); if (script_section.Records.Count > 0) { if (script_section.ContainsItem((uint)ScriptID.COM_GENERIC_CHARACTER_STRAFE_LEFT)) { script_section.RemoveItem((uint)ScriptID.COM_GENERIC_CHARACTER_STRAFE_LEFT); } if (script_section.ContainsItem((uint)ScriptID.COM_GENERIC_CHARACTER_STRAFE_RIGHT)) { script_section.RemoveItem((uint)ScriptID.COM_GENERIC_CHARACTER_STRAFE_RIGHT); } if (!script_section.ContainsItem((uint)ScriptID.HEAD_COM_GENERIC_CHARACTER_STRAFE_LEFT)) { script_section.Records.Add(Twins_Data.allScripts[(uint)ScriptID.HEAD_COM_GENERIC_CHARACTER_STRAFE_LEFT]); } if (!script_section.ContainsItem((uint)ScriptID.HEAD_COM_GENERIC_CHARACTER_STRAFE_RIGHT)) { script_section.Records.Add(Twins_Data.allScripts[(uint)ScriptID.HEAD_COM_GENERIC_CHARACTER_STRAFE_RIGHT]); } script_section.Records.Add(StrafeLeft); script_section.Records.Add(StrafeRight); } } } } for (uint section_id = (uint)RM_Sections.Instances1; section_id <= (uint)RM_Sections.Instances8; section_id++) { if (!RM_Archive.ContainsItem(section_id)) { continue; } TwinsSection section = RM_Archive.GetItem <TwinsSection>(section_id); if (section.Records.Count > 0) { if (!section.ContainsItem((uint)RM_Instance_Sections.ObjectInstance)) { continue; } TwinsSection instances = section.GetItem <TwinsSection>((uint)RM_Instance_Sections.ObjectInstance); for (int i = 0; i < instances.Records.Count; ++i) { Instance instance = (Instance)instances.Records[i]; if (instance.ObjectID == (uint)ObjectID.CRASH) { instance.UnkI322[(int)CharacterInstanceFloats.StrafingSpeed] = 0.1f; } else if (instance.ObjectID == (uint)ObjectID.CORTEX) { instance.UnkI322[(int)CharacterInstanceFloats.StrafingSpeed] = 0.1f; } else if (instance.ObjectID == (uint)ObjectID.NINA) { instance.UnkI322[(int)CharacterInstanceFloats.StrafingSpeed] = 0.1f; } instances.Records[i] = instance; } } } }