Ejemplo n.º 1
0
 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);
         }
     }
 }
Ejemplo n.º 2
0
        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
        }
Ejemplo n.º 3
0
 public GameBox(GameBoxHeaderInfo headerInfo) : base(headerInfo)
 {
     Header = new GameBoxHeader <T>(this);
     Body   = new GameBoxBody <T>(this);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructs an empty GameBox object.
 /// </summary>
 public GameBox()
 {
     Header = new GameBoxHeader <T>(this);
     Body   = new GameBoxBody <T>(this);
 }
Ejemplo n.º 5
0
 public CMwNod ReadNodeRef(GameBoxBody body)
 {
     return(ReadNodeRef <CMwNod>(body));
 }