Esempio n. 1
0
        /// <inheritdoc />
        public void SetTile(ushort xChunkTile, ushort yChunkTile, Tile tile)
        {
            if (xChunkTile >= ChunkSize || yChunkTile >= ChunkSize)
            {
                throw new ArgumentException("Tile indices out of bounds.");
            }

            var gridTile = ChunkTileToGridTile(new MapGrid.Indices(xChunkTile, yChunkTile));

            var newTileRef = new TileRef(_grid.MapID, _grid.Index, gridTile.X, gridTile.Y, tile);
            var oldTile    = _tiles[xChunkTile, yChunkTile];

            _mapManager.RaiseOnTileChanged(_grid.Index, newTileRef, oldTile);
            _grid.UpdateAABB(gridTile);

            _tiles[xChunkTile, yChunkTile] = tile;
        }
            /// <inheritdoc />
            public void SetTile(ushort xChunkTile, ushort yChunkTile, Tile tile)
            {
                if (xChunkTile >= ChunkSize || yChunkTile >= ChunkSize)
                {
                    throw new ArgumentException("Tile indices out of bounds.");
                }

                // same tile, no point to continue
                if (_tiles[xChunkTile, yChunkTile].TileId == tile.TileId)
                {
                    return;
                }

                var gridTile   = ChunkTileToGridTile(new MapIndices(xChunkTile, yChunkTile));
                var newTileRef = new TileRef(_grid.MapID, _grid.Index, gridTile.X, gridTile.Y, tile);
                var oldTile    = _tiles[xChunkTile, yChunkTile];

                _grid.LastModifiedTick = LastModifiedTick = _mapManager._gameTiming.CurTick;
                _mapManager.RaiseOnTileChanged(newTileRef, oldTile);
                _grid.UpdateAABB(gridTile);

                _tiles[xChunkTile, yChunkTile] = tile;
            }