public override void PlaceGround(IBaseBackgroundType groundType, TileConnectionScoreInfo connectionScoreInfo) { GameObject groundGO = GameObject.Instantiate(OverworldGameplayManager.Instance.GetTileBackgroundPrefab <OverworldTileBaseGround>(), Tile.BackgroundsContainer); OverworldTileBaseGround mazeTileBaseGround = groundGO.GetComponent <OverworldTileBaseGround>(); mazeTileBaseGround.WithType(groundType); mazeTileBaseGround.WithConnectionScoreInfo(connectionScoreInfo); mazeTileBaseGround.SetTile(Tile); Tile.AddBackground(mazeTileBaseGround); }
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); }