protected override void DerivedWash(DLink pDLink) { Debug.Assert(pDLink != null); GONode pNode = (GONode)pDLink; pNode.Clear(); }
protected override void DerivedDumpNode(DLink pDLink) { Debug.Assert(pDLink != null); GONode pNode = (GONode)pDLink; pNode.DumpGONode(); }
protected override DLink DerivedCreateNode() { DLink pNode = new GONode(); Debug.Assert(pNode != null); return(pNode); }
//to destroy game objects that are hit public static void Dettach(GameObject pGameObject) { GONodeMan pGOMan = GONodeMan.PrivGetInstance(); Debug.Assert(pGOMan != null); //Remeber: a doublly linked list of trees //whatever game object we get, we have to travel up its tree // to its its tree's root/ upper most parent Debug.Assert(pGameObject != null); GameObject pTemp = pGameObject; GameObject pRoot = null; while (pTemp != null) { pRoot = pTemp; pTemp = (GameObject)Iterator.GetParent(pTemp); //keep traveling up the tree //exit out at the top of the tree } //Found the tree our game object is in // now go traverse the DLink list to that tree GONode pTree = (GONode)pGOMan.BaseGetActive(); while (pTree != null) { //check if the game objects match if (pTree.poGameObject == pRoot) { break; } pTree = (GONode)pTree.pNext; } //Now we are in the tree with the Game Object //we need to remove Debug.Assert(pTree != null); Debug.Assert(pTree.poGameObject != null); GameObject pParent = (GameObject)Iterator.GetParent(pGameObject); Debug.Assert(pParent != null); GameObject pChild = (GameObject)Iterator.GetChild(pGameObject); Debug.Assert(pChild == null); //finally //Remove Gamobject from its parent composite pParent.Remove(pGameObject); }
public static void Remove(GONode pNode) { GONodeMan pGOMan = GONodeMan.PrivGetInstance(); Debug.Assert(pGOMan != null); Debug.Assert(pNode != null); pGOMan.BaseRemove(pNode); }
private GONodeMan(int reserverNum = 3, int growth = 1) : base() { this.BaseIntialize(reserverNum, growth); this.poNodeCompare = new GONode(); this.poNullGO = new NullGO(); this.poNodeCompare.poGameObject = this.poNullGO; }
public static GONode Attach(GameObject pGObject) { GONodeMan pGOMan = GONodeMan.PrivGetInstance(); Debug.Assert(pGOMan != null); GONode pNode = (GONode)pGOMan.BaseAdd(); Debug.Assert(pNode != null); pNode.Set(pGObject); return(pNode); }
public static GameObject Find(GameObject.Name name) { GONodeMan pGOMan = GONodeMan.PrivGetInstance(); Debug.Assert(pGOMan != null); pGOMan.poNodeCompare.poGameObject.SetName(name); GONode pNode = (GONode)pGOMan.BaseFind(pGOMan.poNodeCompare); Debug.Assert(pNode != null); return(pNode.poGameObject); }
protected override bool DerivedCompare(DLink pDLink1, DLink pDLink2) { Debug.Assert(pDLink1 != null); Debug.Assert(pDLink2 != null); GONode pSNode1 = (GONode)pDLink1; GONode pSNode2 = (GONode)pDLink2; Boolean status = false; if (pSNode1.poGameObject.GetName() == pSNode2.poGameObject.GetName()) { status = true; } return(status); }
public static void Update() { // go through active list and update everything in it // while loop GONodeMan pMan = GONodeMan.PrivGetInstance(); Debug.Assert(pMan != null); //Debug.WriteLine("---------------"); GONode pGONode = (GONode)pMan.BaseGetActive(); while (pGONode != null) { //Debug.WriteLine("update: GameObjectTree {0} ({1})", pGONode.poGameObject, pGONode.poGameObject.GetHashCode()); //Debug.WriteLine(" +++++"); if (pGONode.poGameObject.GetPlayerOption() == true) { ReverseIterator pRev = new ReverseIterator(pGONode.poGameObject); //need to update the children 1st then work our way back up the tree // So depth first(ReverseIterator) // maintaines integrity of the bounding collision rectangles Component pNode = pRev.First(); while (!pRev.IsDone()) { GameObject pGameObj = (GameObject)pNode; //Debug.WriteLine("update: {0} ({1})", pGameObj, pGameObj.GetHashCode()); pGameObj.Update(); pNode = pRev.Next(); } //Debug.WriteLine(" ------"); pGONode = (GONode)pGONode.pNext; } } }