public static void Remove(GameObject pNode) { Debug.Assert(pNode != null); GameObjectManager pMan = GameObjectManager.PrivGetInstance(); Debug.Assert(pMan != null); // pNode may be part of a tree. If so, find it's root. // The root will be on the GameObjectManager's Linked list GameObject pRoot = null; GameObject pTmp = pNode; while (pTmp != null) { pRoot = pTmp; pTmp = (GameObject)pTmp.GetParent(); } Debug.Assert(pRoot != null); // Now that we have the root of pNode's tree, or we have pNode if it has no parent // lets find that node on the GameObjectManager's Linked list GameObjectNode pTree = (GameObjectNode)pMan.BaseGetActive(); while (pTree != null) { if (pTree.pGameObj == pRoot) { // found it break; } // Goto Next tree pTree = (GameObjectNode)pTree.GetNext(); } // pTree should now be holding the node that matches Root Debug.Assert(pTree != null); // we shouldn't kills nodes with families right? // we aren't monsters Debug.Assert(pNode.GetFirstChild() == null); // check to see if pTree is just holding pNode or if // it is holding a tree containing pNode GameObject pNodeParent = (GameObject)pNode.GetParent(); if (pTree.pGameObj == pNode) { // pNode is not part of a tree so just remove it. Debug.Assert(pNodeParent == null); Remove(pTree); } else { // pNode is a part of a tree so we'll use the node's // parent composite remove method to remove it. Debug.Assert(pNodeParent != null); pNodeParent.Remove(pNode); } }
public static void Update() { GameObjectManager pMan = GameObjectManager.pActiveMan; Debug.Assert(pMan != null); GameObjectNode pGameObjectNode = (GameObjectNode)pMan.BaseGetActive(); while (pGameObjectNode != null) { ReverseIterator pRev = new ReverseIterator(pGameObjectNode.pGameObj); Component pNode = pRev.First(); while (!pRev.IsDone()) { GameObject pGameObj = (GameObject)pNode; //Debug.WriteLine("update: {0} ({1})", pGameObj, pGameObj.GetHashCode()); pGameObj.Update(); pNode = pRev.Next(); } pGameObjectNode = (GameObjectNode)pGameObjectNode.pNext; } }
public static void Update() { GameObjectManager pMan = GameObjectManager.PrivGetInstance(); Debug.Assert(pMan != null); GameObjectNode pNode = (GameObjectNode)pMan.BaseGetActive(); //= new ReverseIterator(pNode.pGameObject); while (pNode != null) { // Update the node Debug.Assert(pNode.pGameObject != null); //ReverseIterator pRIter = new ReverseIterator(pNode.pGameObject); GameObjectManager.poReverseIterator.TakeHierachy(pNode.pGameObject); GameObject pComponent = (GameObject)GameObjectManager.poReverseIterator.First(); while (!poReverseIterator.IsDone()) { //pComponent.Print(); pComponent.Update(); pComponent = (GameObject)GameObjectManager.poReverseIterator.Next(); } //pNode.pGameObject.Update(); pNode = (GameObjectNode)pNode.pNext; } }
public static void Update() { GameObjectManager pMan = GameObjectManager.PrivGetInstance(); Debug.Assert(pMan != null); GameObjectNode pNode = (GameObjectNode)pMan.BaseGetActive(); while (pNode != null) { // Update the node Debug.Assert(pNode.pGameObj != null); pNode.pGameObj.Update(); pNode = (GameObjectNode)pNode.GetNext(); } }
public static void NonTreeRemove(GameObject pNode) { Debug.Assert(pNode != null); GameObjectManager pMan = GameObjectManager.PrivGetInstance(); Debug.Assert(pMan != null); GameObjectNode pGameObjNode = (GameObjectNode)pMan.BaseGetActive(); while (pGameObjNode != null) { if (pGameObjNode.pGameObj == pNode) { // found it break; } // Goto Next tree pGameObjNode = (GameObjectNode)pGameObjNode.GetNext(); } Debug.Assert(pGameObjNode != null); Remove(pGameObjNode); }
//CHANGE THIS public static void Remove(GameObject pNode) { // Keenan(delete.E) Debug.Assert(pNode != null); GameObjectManager pMan = GameObjectManager.pActiveMan; GameObject pSafetyNode = pNode; // OK so we have a linked list of trees (Remember that) // 1) find the tree root (we already know its the most parent) GameObject pTmp = pNode; GameObject pRoot = null; while (pTmp != null) { pRoot = pTmp; pTmp = (GameObject)Iterator.GetParent(pTmp); } // 2) pRoot is the tree we are looking for // now walk the active list looking for pRoot GameObjectNode pTree = (GameObjectNode)pMan.BaseGetActive(); while (pTree != null) { if (pTree.pGameObj == pRoot) { // found it break; } // Goto Next tree pTree = (GameObjectNode)pTree.pNext; } // 3) pTree is the tree that holds pNode // Now remove the node from that tree Debug.Assert(pTree != null); Debug.Assert(pTree.pGameObj != null); // Is pTree.poGameObj same as the node we are trying to delete? // Answer: should be no... since we always have a group (that was a good idea) Debug.Assert(pTree.pGameObj != pNode); GameObject pParent = (GameObject)Iterator.GetParent(pNode); Debug.Assert(pParent != null); GameObject pChild = (GameObject)Iterator.GetChild(pNode); Debug.Assert(pChild == null); // remove the node pParent.Remove(pNode); // TODO - Recycle pNode }