public override void Load(Stream fileStream) { ExtendedBinaryReader reader = new ExtendedBinaryReader(fileStream) { Offset = 0x20 }; long pos = 0; // NINJA INFO [N*IF] InfoList = new NXIF() { HeaderInfoNode = new string(reader.ReadChars(4)), NodeLength = reader.ReadUInt32(), NodeCount = reader.ReadUInt32() }; reader.JumpTo(InfoList.NodeLength + 8); for (int i = 0; i < InfoList.NodeCount; i++) { string nodeName = new string(reader.ReadChars(4)); uint nodeLength = reader.ReadUInt32(); reader.JumpBehind(8); switch (nodeName) { case "NXTL": case "NZTL": // NINJA TEXTURE LIST [N*TL] TextureList = ReadTextureList(reader, pos); break; case "NXEF": // NINJA EFFECTS [N*EF] EffectList = ReadEffectList(reader, pos); break; case "NXNN": // NINJA NODE NAMES [N*NN] NodeTree = ReadNodeNames(reader, pos); break; case "NXOB": case "NZOB": ObjectList = ReadNodes(reader, pos); break; default: reader.JumpAhead(8); reader.JumpAhead(nodeLength); Console.WriteLine($"Block {nodeName} Not Implemented!"); break; } } }
public NXEF ReadEffectList(ExtendedBinaryReader reader, long pos) { EffectList = new NXEF() { EffectNode = new string(reader.ReadChars(4)), NodeLength = reader.ReadUInt32() }; pos = reader.BaseStream.Position; //Save Position reader.JumpTo(reader.ReadUInt32() + 4, false); var effectTypeCount = reader.ReadUInt32(); var effectTypeOffset = reader.ReadUInt32(); var techiqueCount = reader.ReadUInt32(); var techniqueOffset = reader.ReadUInt32(); reader.JumpTo(effectTypeOffset, false); for (int i = 0; i < effectTypeCount; i++) { EFFFILE effFile = new EFFFILE(); effFile.Type = reader.ReadUInt32(); var jumpPoint = reader.ReadUInt32(); long effectPos = reader.BaseStream.Position; //Save Position reader.JumpTo(jumpPoint, false); effFile.Filename = reader.ReadNullTerminatedString(); reader.JumpTo(effectPos); EffectList.Effects.Add(effFile); } reader.JumpTo(techniqueOffset, false); for (int i = 0; i < techiqueCount; i++) { TECHNAME tech = new TECHNAME(); tech.Type = reader.ReadUInt32(); tech.NodeID = reader.ReadUInt32(); var jumpPoint = reader.ReadUInt32(); long techPos = reader.BaseStream.Position; //Save Position reader.JumpTo(jumpPoint, false); tech.Filename = reader.ReadNullTerminatedString(); reader.JumpTo(techPos); EffectList.Techs.Add(tech); } reader.JumpTo(pos); reader.JumpAhead(EffectList.NodeLength); return(EffectList); }