public void AddBackgroundSprites(SerialisableTile serialisableTile, EditorOverworldTile tile) { EditorOverworldTileBackgroundPlacer tileBackgroundPlacer = new EditorOverworldTileBackgroundPlacer(tile); foreach (SerialisableTileBackground serialisableTileBackground in serialisableTile.TileBackgrounds) { Type type = Type.GetType(serialisableTileBackground.BackgroundType); if (type.Equals(typeof(SerialisableTilePathBackground))) { SerialisableTilePathBackground serialisableTilePathBackground = (SerialisableTilePathBackground)JsonUtility.FromJson(serialisableTileBackground.SerialisedData, type); tileBackgroundPlacer.PlacePath(new OverworldDefaultPathType(), new TileConnectionScoreInfo(serialisableTilePathBackground.TileConnectionScore)); } else if (type.Equals(typeof(SerialisableTileBaseGround))) { SerialisableTileBaseGround serialisableTileBaseGround = (SerialisableTileBaseGround)JsonUtility.FromJson(serialisableTileBackground.SerialisedData, type); tileBackgroundPlacer.PlaceGround(new OverworldDefaultGroundType(), new TileConnectionScoreInfo(serialisableTileBaseGround.TileConnectionScore)); } else if (type.Equals(typeof(SerialisableTileBaseWater))) { tileBackgroundPlacer.PlaceCoveringBaseWater(); //tileBackgroundPlacer.PlaceBackground<OverworldTileBaseWater>(); } else { Logger.Error($"Unknown TileBackgroundType {serialisableTileBackground.BackgroundType}"); } } }
public override void PlaceBackground(EditorOverworldTile tile) { if (tile.TileMainMaterial.GetType() != typeof(GroundMainMaterial)) { return; } EditorOverworldTileBackgroundPlacer tileBackgroundPlacer = new EditorOverworldTileBackgroundPlacer(tile); OverworldTileBackgroundRemover tileBackgroundRemover = new OverworldTileBackgroundRemover(tile); ITileBackground overworldTilePath = (OverworldTilePath)tile.GetBackgrounds().FirstOrDefault(background => background is OverworldTilePath); if (overworldTilePath == null) { OverworldTileAttributeRemover tileAttributeRemover = new OverworldTileAttributeRemover(tile); tileAttributeRemover.RemoveTileObstacle(); tileBackgroundPlacer.PlacePath(new OverworldDefaultPathType()); return; } // This path already exists on this tile, so remove it tileBackgroundRemover.RemovePath(); }