public override void RemoveTileObstacle(TileObstacle tileObstacle = null) { _tile.SetWalkable(true); if (!tileObstacle) { tileObstacle = (TileObstacle)_tile.GetAttributes().FirstOrDefault(attribute => attribute is TileObstacle); } if (tileObstacle == null) { return; } if (tileObstacle is PlayerExit) { return; } ObstacleType obstacleType = tileObstacle.ObstacleType; int oldConnectionScore = tileObstacle.ConnectionScore; if (oldConnectionScore == NeighbourTileCalculator.ConnectionOnAllSidesScore) { EditorOverworldTileBackgroundPlacer tileBackgroundPlacer = new EditorOverworldTileBackgroundPlacer(_tile); tileBackgroundPlacer.PlaceBackground <OverworldTileBaseGround>(); } _tile.RemoveAttribute(tileObstacle); tileObstacle.Remove(); //After removing tile, check with neighbour tiles if wall connections should be updated UpdateNeighboursForRemovedObstacle(obstacleType); }
public override void RemoveTileObstacle(TileObstacle tileObstacle = null) { if (!tileObstacle) { tileObstacle = (TileObstacle)_tile.GetAttributes().FirstOrDefault(attribute => attribute is TileObstacle); } if (tileObstacle == null) { return; } if (tileObstacle is PlayerExit) { return; } _tile.SetWalkable(true); ObstacleType obstacleType = tileObstacle.ObstacleType; int oldConnectionScore = tileObstacle.ConnectionScore; // If needed, place a background in the gap that the removed path left. // OPTIMISATION: Currently only looking at connection score from obstacles, but should also take eg. door attributes into account. if (oldConnectionScore == NeighbourTileCalculator.ConnectionOnAllSidesScore) { EditorMazeTileBackgroundPlacer tileBackgroundPlacer = new EditorMazeTileBackgroundPlacer(_tile); tileBackgroundPlacer.PlaceBackground <MazeTileBaseGround>(); } _tile.RemoveAttribute(tileObstacle); tileObstacle.Remove(); //After removing tile, check with neighbour tiles if wall connections should be updated UpdateNeighboursForRemovedObstacle(obstacleType); }