public void Write(CMwNod node, GameBoxBody body) { if (node == null) { Write(-1); } else { if (body.AuxilaryNodes.ContainsValue(node)) { Write(body.AuxilaryNodes.FirstOrDefault(x => x.Equals(node)).Key); } else { body.AuxilaryNodes[body.AuxilaryNodes.Count] = node; Write(body.AuxilaryNodes.Count); Write(node.ID); node.Write(this, body.GBX.Remap); } } }
public T ReadNodeRef <T>(GameBoxBody body) where T : CMwNod { var index = ReadInt32() - 1; // GBX seems to start the index at 1 if (index >= 0 && (!body.AuxilaryNodes.ContainsKey(index) || body.AuxilaryNodes[index] == null)) // If index is 0 or bigger and the node wasn't read yet, or is null { body.AuxilaryNodes[index] = CMwNod.Parse <T>(this); } if (index < 0) // If aux node index is below 0 then there's not much to solve { return(null); } body.AuxilaryNodes.TryGetValue(index, out CMwNod n); // Tries to get the available node from index if (n is T nod) // If the node is presented at the index, then it's simple { return(nod); } // But sometimes it indexes the node reference that is further in the expected indexes return((T)body.AuxilaryNodes.Last().Value); // So it grabs the last one instead, needs to be further tested }
public GameBox(GameBoxHeaderInfo headerInfo) : base(headerInfo) { Header = new GameBoxHeader <T>(this); Body = new GameBoxBody <T>(this); }
/// <summary> /// Constructs an empty GameBox object. /// </summary> public GameBox() { Header = new GameBoxHeader <T>(this); Body = new GameBoxBody <T>(this); }
public CMwNod ReadNodeRef(GameBoxBody body) { return(ReadNodeRef <CMwNod>(body)); }