public NXNN ReadNodeNames(ExtendedBinaryReader reader, long pos) { NodeTree = new NXNN() { TreeNode = new string(reader.ReadChars(4)), NodeLength = reader.ReadUInt32() }; pos = reader.BaseStream.Position; //Save Position reader.JumpTo(reader.ReadUInt32() + 4, false); var nodeCount = reader.ReadUInt32(); reader.JumpTo(reader.ReadUInt32(), false); for (int i = 0; i < nodeCount; i++) { NodeTree node = new NodeTree(); node.NodeIndex = reader.ReadUInt32(); var nameOffset = reader.ReadUInt32(); long nodePos = reader.BaseStream.Position; //Save Position reader.JumpTo(nameOffset, false); node.NodeName = reader.ReadNullTerminatedString(); reader.JumpTo(nodePos); NodeTree.Nodes.Add(node); } reader.JumpTo(pos); reader.JumpAhead(NodeTree.NodeLength); return(NodeTree); }
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; } } }