public Tile() { info = new TileInfo(); tileSceneNode = null; renderable = null; init = false; loaded = false; bounds = new AxisAlignedBox(); boundsExt = new AxisAlignedBox(); //worldBounds = new AxisAlignedBox(); neighbors = new Tile[4]; }
public void Release() { if (init) { init = false; if (loaded && renderable != null) { renderable.Release(); renderable = null; loaded = false; } if (neighbors[(int)Neighbor.North] != null) { neighbors[(int)Neighbor.North].SetNeighbor(Neighbor.South, null); } if (neighbors[(int)Neighbor.South] != null) { neighbors[(int)Neighbor.South].SetNeighbor(Neighbor.North, null); } if (neighbors[(int)Neighbor.East] != null) { neighbors[(int)Neighbor.East].SetNeighbor(Neighbor.West, null); } if (neighbors[(int)Neighbor.West] != null) { neighbors[(int)Neighbor.West].SetNeighbor(Neighbor.East, null); } for (long i = 0; i < 4; i++) { neighbors[i] = null; } if (tileSceneNode != null) { //mTileNode->getParent()->removeChild( mTileNode->getName() ); //delete mTileNode; //assert (mTileSceneNode->getParent()); // jsw - we need to call both of these to delete the scene node. The first // one removes it from the SceneManager's list of all nodes, and the 2nd one // removes it from the tree of scene nodes. tileSceneNode.Creator.DestroySceneNode(tileSceneNode.Name); tileSceneNode.Parent.RemoveChild(tileSceneNode); tileSceneNode = null; } TileManager.Instance.FreeTile(this); } }
public void LinkRenderableNeighbor() { // South if (neighbors[(int)Neighbor.South] != null) { if (neighbors[(int)Neighbor.South].IsLoaded) { Renderable.Renderable n = neighbors[(int)Neighbor.South].Renderable; Debug.Assert(n != null); renderable.SetNeighbor(Neighbor.South, n); n.SetNeighbor(Neighbor.North, renderable); } } //North if (neighbors[(int)Neighbor.North] != null) { if (neighbors[(int)Neighbor.North].IsLoaded) { Renderable.Renderable n = neighbors[(int)Neighbor.North].Renderable; Debug.Assert(n != null); renderable.SetNeighbor(Neighbor.North, n); n.SetNeighbor(Neighbor.South, renderable); } } //East if (neighbors[(int)Neighbor.East] != null) { if (neighbors[(int)Neighbor.East].IsLoaded) { Renderable.Renderable n = neighbors[(int)Neighbor.East].Renderable; Debug.Assert(n != null); renderable.SetNeighbor(Neighbor.East, n); n.SetNeighbor(Neighbor.West, renderable); } } //West if (neighbors[(int)Neighbor.West] != null) { if (neighbors[(int)Neighbor.West].IsLoaded) { Renderable.Renderable n = neighbors[(int)Neighbor.West].Renderable; Debug.Assert(n != null); renderable.SetNeighbor(Neighbor.West, n); n.SetNeighbor(Neighbor.East, renderable); } } }