Skip to content

Instantly share code, notes, and snippets.

@AG-Dan
Created September 28, 2021 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AG-Dan/7e5b2ee72514ba2b5b7ffab0343b1b65 to your computer and use it in GitHub Desktop.
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.
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