public override void Load(ref System.IO.FileStream File, ref System.IO.BinaryReader Reader) { File.Position = Offset + Base; if (File.Position < File.Length && Size > 0) { Header = Reader.ReadUInt32(); Records = (int)Reader.ReadUInt32(); ContentSize = Reader.ReadUInt32(); Array.Resize(ref _Item, Records); for (int i = 0; i <= Records - 1; i++) { uint ElementOffset = Reader.ReadUInt32(); uint ElementSize = Reader.ReadUInt32(); uint ElementID = Reader.ReadUInt32(); uint Pos = (uint)File.Position; switch (ElementID) { case 1: { Behaviors Insts = new Behaviors(); Insts.Offset = ElementOffset; Insts.Base = Offset + Base; Insts.Size = ElementSize; Insts.ID = ElementID; Insts.Load(ref File, ref Reader); _Item[i] = Insts; break; } case 2: { FuckingShits Insts = new FuckingShits(); Insts.Offset = ElementOffset; Insts.Base = Offset + Base; Insts.Size = ElementSize; Insts.ID = ElementID; Insts.Load(ref File, ref Reader); _Item[i] = Insts; break; } case 3: { Positions Insts = new Positions(); Insts.Offset = ElementOffset; Insts.Base = Offset + Base; Insts.Size = ElementSize; Insts.ID = ElementID; Insts.Load(ref File, ref Reader); _Item[i] = Insts; break; } case 4: { Paths Insts = new Paths(); Insts.Offset = ElementOffset; Insts.Base = Offset + Base; Insts.Size = ElementSize; Insts.ID = ElementID; Insts.Load(ref File, ref Reader); _Item[i] = Insts; break; } case 5: { SurfaceBehaviours Insts = new SurfaceBehaviours(); Insts.Offset = ElementOffset; Insts.Base = Offset + Base; Insts.Size = ElementSize; Insts.ID = ElementID; Insts.Load(ref File, ref Reader); _Item[i] = Insts; break; } case 6: { Instances Insts = new Instances(); Insts.Offset = ElementOffset; Insts.Base = Offset + Base; Insts.Size = ElementSize; Insts.ID = ElementID; Insts.Load(ref File, ref Reader); _Item[i] = Insts; break; } case 7: { Triggers Trigs = new Triggers(); Trigs.Offset = ElementOffset; Trigs.Base = Offset + Base; Trigs.Size = ElementSize; Trigs.ID = ElementID; Trigs.Load(ref File, ref Reader); _Item[i] = Trigs; break; } default: { BaseSection BS = new BaseSection(); BS.Offset = ElementOffset; BS.Base = Offset + Base; BS.Size = ElementSize; BS.ID = ElementID; BS.Load(ref File, ref Reader); _Item[i] = BS; break; } } File.Position = Pos; } } }
public override void Load(ref System.IO.FileStream File, ref System.IO.BinaryReader Reader) { File.Position = Offset + Base; if (File.Position < File.Length && Size > 0) { Header = Reader.ReadUInt32(); Records = (int)Reader.ReadUInt32(); ContentSize = Reader.ReadUInt32(); Array.Resize(ref _Item, Records); for (int i = 0; i <= Records - 1; i++) { uint ElementOffset = Reader.ReadUInt32(); uint ElementSize = Reader.ReadUInt32(); uint ElementID = Reader.ReadUInt32(); uint Pos = (uint)File.Position; switch (ElementID) { case 0: { GameObjects GObjs = new GameObjects(); GObjs.Offset = ElementOffset; GObjs.Base = Offset + Base; GObjs.Size = ElementSize; GObjs.ID = ElementID; GObjs.Load(ref File, ref Reader); _Item[i] = GObjs; break; } case 1: { Scripts Srpts = new Scripts(); Srpts.Offset = ElementOffset; Srpts.Base = Offset + Base; Srpts.Size = ElementSize; Srpts.ID = ElementID; Srpts.Load(ref File, ref Reader); _Item[i] = Srpts; break; } case 2: { Animations Anims = new Animations(); Anims.Offset = ElementOffset; Anims.Base = Offset + Base; Anims.Size = ElementSize; Anims.ID = ElementID; Anims.Load(ref File, ref Reader); _Item[i] = Anims; break; } case 3: { OGIs OGInfos = new OGIs(); OGInfos.Offset = ElementOffset; OGInfos.Base = Offset + Base; OGInfos.Size = ElementSize; OGInfos.ID = ElementID; OGInfos.Load(ref File, ref Reader); _Item[i] = OGInfos; break; } case 4: { BaseSection BS = new BaseSection(); BS.Offset = ElementOffset; BS.Base = Offset + Base; BS.Size = ElementSize; BS.ID = ElementID; BS.Load(ref File, ref Reader); _Item[i] = BS; break; } case 6: { Sound S = new Sound(); if (_Item[i - 1] is SoundDescriptions) { S.Shift = (_Item[i - 1].Records + 1) * 12; for (int j = 0; j <= _Item[i - 1].Records - 1; j++) { S.Shift += (int)_Item[i - 1]._Item[j].Size; } } else { S.Shift = 0; } S.Offset = ElementOffset; S.Base = Offset + Base; S.Size = ElementSize; S.ID = ElementID; S.Load(ref File, ref Reader); _Item[i] = S; break; } case 5: { SoundDescriptions SDs = new SoundDescriptions(); SDs.Offset = ElementOffset; SDs.Base = Offset + Base; SDs.Size = ElementSize; SDs.ID = ElementID; SDs.Load(ref File, ref Reader); _Item[i] = SDs; break; } default: { SoundbankDescriptions SDs = new SoundbankDescriptions(); SDs.Offset = ElementOffset; SDs.Base = Offset + Base; SDs.Size = ElementSize; SDs.ID = ElementID; SDs.Load(ref File, ref Reader); _Item[i] = SDs; break; } } File.Position = Pos; } } }
/// <summary> /// Create new RM2 chunk /// </summary> public void NewRM2() { Array.Resize(ref Item, 12); Records = 12; Item[0] = new GraphicsSection(); Item[0].ID = 11; Item[0].Records = 9; Array.Resize(ref Item[0]._Item, 9); for (int i = 0; i <= 8; i++) { switch (i) { case 0: { Item[0][i] = new Textures(); break; } case 1: { Item[0][i] = new Materials(); break; } case 2: { Item[0][i] = new Models(); break; } case 3: { Item[0][i] = new GCs(); break; } case 4: { Item[0][i] = new ID4Models(); break; } case 5: { Item[0][i] = new BaseSection(); break; } case 6: { Item[0][i] = new GCs(); break; } case 7: { Item[0][i] = new BaseSection(); break; } case 8: { Item[0][i] = new BaseSection(); break; } } Item[0][i].ID = (uint)i; } Array.Resize(ref Item, 12); Item[1] = new CodeSection(); Item[1].ID = 10; Item[1].Records = 13; Array.Resize(ref Item[1]._Item, 13); for (int i = 0; i <= 12; i++) { switch (i) { case 0: { Item[1][i] = new GameObjects(); break; } case 1: { Item[1][i] = new Scripts(); break; } case 2: { Item[1][i] = new Animations(); break; } case 3: { Item[1][i] = new OGIs(); break; } case 4: { Item[1][i] = new BaseSection(); break; } case 5: { Item[1][i] = new SoundDescriptions(); break; } case 6: { Item[1][i] = new Sound(); break; } case 7: case 8: case 9: case 10: case 11: case 12: { Item[1][i] = new SoundbankDescriptions(); break; } } Item[1][i].ID = (uint)i; } Item[2] = new BaseItem(); Item[2].ID = 8; Item[3] = new GeoData(); Item[3].ID = 9; for (int j = 4; j <= 11; j++) { Item[j] = new InstanceInfoSection(); Item[j].ID = (uint)j - 4; Item[j].Records = 9; Array.Resize(ref Item[j]._Item, 9); for (int i = 0; i <= 8; i++) { switch (i) { case 0: { Item[j][i] = new BaseSection(); break; } case 1: { Item[j][i] = new Behaviors(); break; } case 2: { Item[j][i] = new FuckingShits(); break; } case 3: { Item[j][i] = new Positions(); break; } case 4: { Item[j][i] = new Paths(); break; } case 5: { Item[j][i] = new SurfaceBehaviours(); break; } case 6: { Item[j][i] = new Instances(); break; } case 7: { Item[j][i] = new Triggers(); break; } case 8: { Item[j][i] = new BaseSection(); break; } } Item[j][i].ID = (uint)i; } } Recalculate(); }
/// <summary> /// New SM2 Chunk /// </summary> /// <param name="Name">Name of the chunk</param> public void NewSM2(string Name) { Records = 7; Array.Resize(ref Item, 7); Item[0] = new GraphicsSection(); Item[0].ID = 6; Item[0].Records = 9; Array.Resize(ref Item[0]._Item, 9); for (int i = 0; i <= 8; i++) { switch (i) { case 0: { Item[0][i] = new Textures(); break; } case 1: { Item[0][i] = new Materials(); break; } case 2: { Item[0][i] = new Models(); break; } case 3: { Item[0][i] = new GCs(); break; } case 4: { Item[0][i] = new BaseSection(); break; } case 5: { Item[0][i] = new BaseSection(); break; } case 6: { Item[0][i] = new GCs(); break; } case 7: { Item[0][i] = new BaseSection(); break; } case 8: { Item[0][i] = new BaseSection(); break; } } Item[0][i].ID = (uint)i; } for (int i = 1; i <= 6; i++) { Item[i] = new BaseItem(); Item[i].ID = (uint)i - 1; } System.IO.MemoryStream NewStream = new System.IO.MemoryStream(); System.IO.BinaryWriter NSwriter = new System.IO.BinaryWriter(NewStream); int I32 = 196608; NSwriter.Write(I32); NSwriter.Write(Name.Length); for (int i = 0; i <= Name.Length - 1; i++) { NSwriter.Write(Name[i]); } I32 = 0; NSwriter.Write(I32); Int16 I16 = 5642; NSwriter.Write(I16); byte B = 0; for (int i = 0; i <= 54; i++) { NSwriter.Write(B); } int[] indexes = new int[] { }; Item[1].Put_Stream(NewStream, 0, indexes); Recalculate(); }
public override void Load(ref System.IO.FileStream File, ref System.IO.BinaryReader Reader) { File.Position = Offset + Base; if (File.Position < File.Length && Size > 0) { Header = Reader.ReadUInt32(); Records = (int)Reader.ReadUInt32(); ContentSize = Reader.ReadUInt32(); Array.Resize(ref _Item, Records); for (int i = 0; i <= Records - 1; i++) { uint ElementOffset = Reader.ReadUInt32(); uint ElementSize = Reader.ReadUInt32(); uint ElementID = Reader.ReadUInt32(); uint Pos = (uint)File.Position; switch (ElementID) { case 0: { Textures Texs = new Textures(); Texs.Offset = ElementOffset; Texs.Base = Offset + Base; Texs.Size = ElementSize; Texs.ID = ElementID; Texs.Load(ref File, ref Reader); _Item[i] = Texs; break; } case 1: { Materials Mtrls = new Materials(); Mtrls.Offset = ElementOffset; Mtrls.Base = Offset + Base; Mtrls.Size = ElementSize; Mtrls.ID = ElementID; Mtrls.Load(ref File, ref Reader); _Item[i] = Mtrls; break; } case 2: { Models Mdls = new Models(); Mdls.Offset = ElementOffset; Mdls.Base = Offset + Base; Mdls.Size = ElementSize; Mdls.ID = ElementID; Mdls.Load(ref File, ref Reader); _Item[i] = Mdls; break; } case 3: case 6: { GCs GCs = new GCs(); GCs.Offset = ElementOffset; GCs.Base = Offset + Base; GCs.Size = ElementSize; GCs.ID = ElementID; GCs.Load(ref File, ref Reader); _Item[i] = GCs; break; } case 7: { Terrains Ts = new Terrains(); Ts.Offset = ElementOffset; Ts.Base = Offset + Base; Ts.Size = ElementSize; Ts.ID = ElementID; Ts.Load(ref File, ref Reader); _Item[i] = Ts; break; } case 4: { ID4Models Mdls = new ID4Models(); Mdls.Offset = ElementOffset; Mdls.Base = Offset + Base; Mdls.Size = ElementSize; Mdls.ID = ElementID; Mdls.Load(ref File, ref Reader); _Item[i] = Mdls; break; } default: { BaseSection BS = new BaseSection(); BS.Offset = ElementOffset; BS.Base = Offset + Base; BS.Size = ElementSize; BS.ID = ElementID; BS.Load(ref File, ref Reader); _Item[i] = BS; break; } } File.Position = Pos; } } }