-
-
Save AG-Dan/7e5b2ee72514ba2b5b7ffab0343b1b65 to your computer and use it in GitHub Desktop.
A script to replace the tile sets used for the start node in a dungeon flow.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using DunGen; | |
using DunGen.Graph; | |
using UnityEngine; | |
public class ReplaceStartTiles : MonoBehaviour | |
{ | |
public RuntimeDungeon DungeonGenerator; | |
public TileSet ReplacementStartTiles; | |
private DungeonFlow originalFlow; | |
public void Generate() | |
{ | |
// Keep a reference to the original flow asset | |
if (originalFlow == null) | |
originalFlow = DungeonGenerator.Generator.DungeonFlow; | |
// We make a copy of the dungeon flow before modifying any settings. | |
// If we just modify the original, we'd permanently change the settings | |
// on that asset in our project. | |
// NOTE: This has to be done for any asset we want to modify (tile sets, archetypes, etc) | |
// to avoid changing the original | |
var modifiedFlow = Instantiate(originalFlow); | |
// Find the start node, and replace all of the tile sets | |
// with our replacement TileSet | |
var startNode = modifiedFlow.Nodes[0]; | |
startNode.TileSets.Clear(); | |
startNode.TileSets.Add(ReplacementStartTiles); | |
// Apply the modified flow and generate | |
DungeonGenerator.Generator.DungeonFlow = modifiedFlow; | |
DungeonGenerator.Generate(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment