public static void Reset() { //ensure call Create() first GameObjectMan pMan = GameObjectMan.GetInstance(); Debug.Assert(pMan != null); GameObjectNode pGameObjectNode = (GameObjectNode)pMan.baseGetActiveList(); while (pGameObjectNode != null) { Component pGameObject = (Component)pGameObjectNode.getGameObject(); while (pGameObject.holder == Component.Container.Composite) { Composite pComposite = (Composite)pGameObject; pGameObject = (Component)pComposite.poHead; pComposite.poHead = null; pComposite.poLast = null; if (pGameObject == null || pGameObject.holder == Component.Container.Leaf) { break; } } pGameObjectNode = (GameObjectNode)pGameObjectNode.pNext; } }
public static void Update() { //ensure call Create() first GameObjectMan pMan = GameObjectMan.GetInstance(); Debug.Assert(pMan != null); GameObjectNode pGameObjectNode = (GameObjectNode)pMan.baseGetActiveList(); while (pGameObjectNode != null) { ReverseIterator pRev = new ReverseIterator(pGameObjectNode.getGameObject()); Component pNode = pRev.first(); while (!pRev.isDone()) { GameObject pGameObj = (GameObject)pNode; pGameObj.update(); pNode = pRev.next(); } pGameObjectNode = (GameObjectNode)pGameObjectNode.pNext; } }
public static void Remove(GameObject pNode) { Debug.Assert(pNode != null); //ensure call Create() first GameObjectMan pMan = GameObjectMan.GetInstance(); Debug.Assert(pMan != null); // 1. find tree root GameObject pTmp = pNode; GameObject pRoot = null; while (pTmp != null) { pRoot = pTmp; pTmp = (GameObject)Iterator.GetParent(pTmp); } // 2. pRoot is the tree we looking for, walk the active list looking for pTree GameObjectNode pTree = (GameObjectNode)pMan.baseGetActiveList(); while (pTree != null) { if (pTree.getGameObject() == pRoot) { break; } // go to next tree pTree = (GameObjectNode)pTree.pNext; } // 3. pTree is the tree that holds pNode, remove pNode from pTree Debug.Assert(pTree != null); Debug.Assert(pTree.getGameObject() != null); // always have a group Debug.Assert(pTree.getGameObject() != pNode); GameObject pParent = (GameObject)Iterator.GetParent(pNode); Debug.Assert(pParent != null); // remove the node pParent.remove(pNode); }