/// <summary> /// Gets the player's tile. /// </summary> /// <returns></returns> public Map.Tile GetPlayerTile() { byte playerZ = this.Client.Player.Z; int floor = 0; if (playerZ <= 7) { floor = 7 - playerZ; } else { floor = 2; } int tileNumber = this.Client.Memory.ReadInt32(this.TileNumberStart + (Constants.Map.MaxTilesPerFloor * floor * 4) + Constants.Map.TileNumberCenterOffset); Map.Tile t = this.CachedTiles[tileNumber]; t.UpdateObjects(); uint id = this.Client.Player.ID; if (!t.ContainsCreature(id)) { return(null); } t.WorldLocation = this.Client.Player.Location; t.RealMemoryLocation = this.TileNumberToMemoryLocation(t.TileNumber, t); t.MemoryLocation = this.CentralizeMemoryLocation(t.RealMemoryLocation, t); return(t); }
/// <summary> /// Gets a tile. /// </summary> /// <param name="tileNumber">The tile number to look for.</param> /// <param name="playerTile">The player's tile, used to get memory location and world location.</param> /// <param name="mapBegin">The memory address of the beginning of the map structure.</param> /// <returns></returns> public Map.Tile GetTile(int tileNumber, Map.Tile playerTile, int mapBegin = 0) { if (tileNumber < 0 || tileNumber >= this.CachedTiles.Length) { return(null); } if (playerTile == null) { playerTile = this.GetPlayerTile(); } if (playerTile == null) { return(null); } if (mapBegin == 0) { mapBegin = this.MapStart; } Map.Tile t = this.CachedTiles[tileNumber]; t.Address = mapBegin + this.Client.Addresses.Map.TileStep * tileNumber; t.UpdateObjects(); t.RealMemoryLocation = this.TileNumberToMemoryLocation(t.TileNumber, playerTile); t.MemoryLocation = this.CentralizeMemoryLocation(t.RealMemoryLocation, playerTile); t.WorldLocation = this.MemoryLocationToWorldLocation(t.MemoryLocation, playerTile); return(t); }