private static void SetTileAdvanced(Vector2i tPos, Tile tile) { bool deleting = tile.ID == 0; if (InTileBounds(tPos.x, tPos.y)) { if (deleting) { DeleteTile(tPos); } else { TileType type = GetTileType(tile); GetTileType(type.Layer, tPos.x, tPos.y).OnDeleted(tPos); if (type.CanAdd(tPos)) { SetTileFast(tPos, tile); } } } }