/// <summary> /// Removes the item in the specified tile from the game, and updates the indexes. /// </summary> private static void RemoveItem(Tile tile, int dimension) { int itemID = tile.Item.ItemID; Point2D l = tile.Location; Chunk chunk = World.Data.World.GetChunkByTile(dimension, l.X, l.Y); if (chunk.Items.ContainsKey(itemID)) { RTree.RTree <Point2D> result = chunk.Items[itemID]; bool success = result.Delete(new RTree.Rectangle(l.X, l.Y, l.X, l.Y), new Point2D(l.X, l.Y)); if (!success) { throw new RegistryDeletionException("Failed to delete an item!"); } if (result.Count == 0) { RTree.RTree <Point2D> chunksContaining = ItemRegistry.Registries[dimension].ItemIDToChunk[itemID]; bool succeed = chunksContaining.Delete(new RTree.Rectangle(chunk.ChunkLocation.X, chunk.ChunkLocation.Y, chunk.ChunkLocation.X, chunk.ChunkLocation.Y), new Point2D(chunk.ChunkLocation.X, chunk.ChunkLocation.Y)); if (!succeed) { throw new RegistryDeletionException("Failed to delete a chunk containing an item!"); } } tile.Item = null; } }
public void LoadNavMesh(DNavM mesh) { foreach (Common.DTngl tr in mesh.list) { MeshElement me = new MeshElement(tr.p); AddElement(me); } foreach (KeyValuePair <int, MeshElement> kv in this.m_meshDict) { List <MeshElement> meshList = m_rtree.Intersects(kv.Value.bounding); foreach (MeshElement element in meshList) { if (element.meshId != kv.Value.meshId) { kv.Value.SetNeighbor(element); } } int count = 0; foreach (MeshElement n in kv.Value.neighbor) { if (n != null) { count++; } } if (count == 0) { m_rtree.Delete(kv.Value.bounding, kv.Value); continue; } } }