public Int32 GetTileWalkCost(Tile tile) { return 0; }
/// <summary> /// Set the tile at the specified position. /// </summary> /// <param name="pos">The position to set the tile at.</param> /// <param name="tile">The tile to set.</param> public void SetTile(Position pos, Tile tile) { SetTile(pos.x, pos.y, pos.z, tile); }
/// <summary> /// Get the tile at the specified position or null if no /// such maptile exists. /// </summary> /// <param name="x">The x coordinate of the position.</param> /// <param name="y">The y coordinate of the position.</param> /// <param name="z">The z coordinate of the position.</param> /// <returns>The tile at the specified position.</returns> public Tile GetTile(int x, int y, byte z) { int hash = Position.HashCode((ushort)x, (ushort)y); Tile tile; //Check if tile is cached bool exists = cachedTiles[z].TryGetValue(hash, out tile); if (exists) { return tile; } ushort[] vals; //Tile isn't cached, try main exists = mainTiles[z].TryGetValue(hash, out vals); if (exists) { //Create tile and add to cached Item ground = Item.CreateItem(vals[0]); ground.CurrentPosition = new Position((ushort)x, (ushort)y, z); tile = new Tile(ground); for (int i = 1; i < vals.Length; i++) { if (vals[i] == 0) { Log.Write("Invalid ID at position x: " + x + " y: " + y + " z: " + z); } else { Item item = Item.CreateItem(vals[i]); item.CurrentPosition = new Position((ushort)x, (ushort)y, z); tile.AddThing(item); } } //Cache it cachedTiles[z].Add(hash, tile); return tile; } return null; }
/// <summary> /// Set the tile at the specified position. /// </summary> /// <param name="x">The x coordinate of the position.</param> /// <param name="y">The y coordinate of the position.</param> /// <param name="z">The z coordinate of the position.</param> /// <param name="tile">The tile to set.</param> public void SetTile(ushort x, ushort y, byte z, Tile tile) { int hash = Position.HashCode(x, y); cachedTiles[z].Add(hash, tile); }
/// <summary> /// Adds a single map tile. /// </summary> /// <param name="tile">Maptile to add.</param> /// <param name="player">Player for whom the map tile is being added.</param> private void AddMapTile(Tile tile, Player player) { if (tile != null) { foreach (Thing t in tile.GetThings()) { t.AddItself(this, player); } } netmsg.AddByte(0xFF); //End of maptile byte }