public override void PlaceBackground(EditorOverworldTile tile) { EditorOverworldTileBackgroundPlacer tileBackgroundPlacer = new EditorOverworldTileBackgroundPlacer(tile); OverworldTileBackgroundRemover tileBackgroundRemover = new OverworldTileBackgroundRemover(tile); OverworldTileAttributeRemover tileAttributeRemover = new OverworldTileAttributeRemover(tile); List <ITileBackground> backgrounds = tile.GetBackgrounds(); ITileBackground overworldTileBaseWater = (OverworldTileBaseWater)tile.GetBackgrounds().FirstOrDefault(background => background is OverworldTileBaseWater); if (overworldTileBaseWater == null) { Type oldMainMaterial = tile.TileMainMaterial?.GetType(); // old material before updating it if (oldMainMaterial == null || oldMainMaterial == typeof(GroundMainMaterial)) { tileBackgroundRemover.RemoveBackground <OverworldTilePath>(); } OverworldTileBaseWater water = tileBackgroundPlacer.PlaceBackground <OverworldTileBaseWater>(); List <ITileAttribute> attributes = tile.GetAttributes(); for (int i = 0; i < attributes.Count; i++) { tileAttributeRemover.Remove(attributes[i]); } if (oldMainMaterial == null || oldMainMaterial == typeof(GroundMainMaterial)) { if (water.ConnectionScore == 16) // remove background if we completely covered the tile with water { tileBackgroundRemover.RemoveBackground <OverworldTileBaseGround>(); } } } }
public override void PlaceBackground(EditorOverworldTile tile) { EditorOverworldTileBackgroundPlacer tileBackgroundPlacer = new EditorOverworldTileBackgroundPlacer(tile); OverworldTileBackgroundRemover tileBackgroundRemover = new OverworldTileBackgroundRemover(tile); OverworldTileAttributeRemover tileAttributeRemover = new OverworldTileAttributeRemover(tile); Type oldMainMaterial = tile.TileMainMaterial?.GetType(); // old material before updating it ITileBackground overworldTileBaseGround = (OverworldTileBaseGround)tile.GetBackgrounds().FirstOrDefault(background => background is OverworldTileBaseGround); OverworldTileBaseGround oldOverworldTileBaseGround = (OverworldTileBaseGround)tile.GetBackgrounds().FirstOrDefault(background => background is OverworldTileBaseGround); if (oldMainMaterial != typeof(GroundMainMaterial)) { List <ITileAttribute> attributes = tile.GetAttributes(); for (int i = 0; i < attributes.Count; i++) { tileAttributeRemover.Remove(attributes[i]); } //if (oldMainMaterial == typeof(WaterMainMaterial) || tile.TileMainMaterial == null) //{ // tileBackgroundRemover.RemoveBackground<OverworldTileBaseWater>(); //} //if(overworldTileBaseGround == null) //{ // tileBackgroundPlacer.PlaceBackground<OverworldTileBaseGround>(); //} //else //{ // tileBackgroundPlacer.UpdateGroundConnectionsOnNeighbours(new OverworldDefaultGroundType()); //} if (oldOverworldTileBaseGround != null && oldOverworldTileBaseGround.ConnectionScore != 16) { tileBackgroundRemover.RemoveBackground <OverworldTileBaseGround>(); } OverworldTileBaseGround newMazeTileBaseGround = tileBackgroundPlacer.PlaceBackground <OverworldTileBaseGround>(); // Remove water from the tile that is fully covered by land if (newMazeTileBaseGround.ConnectionScore == 16) { tileBackgroundRemover.RemoveBackground <OverworldTileBaseWater>(); } } // Place corner fillers TileCornerFillerRegister.TryPlaceCornerFillers(tile); TileCornerFillerRegister.TryPlaceCornerFillersForNeighbours(tile); }