Removed hard coded stuff
BranchPathMultiSim system now works with all dungeons
This commit is contained in:
parent
b7a70f56d6
commit
b46908ec51
|
@ -149,7 +149,7 @@ namespace DunGenPlus.Collections {
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class ForcedTilesProperties {
|
public class ForcedTilesProperties {
|
||||||
|
|
||||||
internal const string UseForcedTilesTooltip = "If enabled, attempts to forcefully spawn tiles from ForcedTileSets after branching paths are generated.\n\nCan only be used if MainPathCount > 1.";
|
internal const string UseForcedTilesTooltip = "If enabled, attempts to forcefully spawn tiles from ForcedTileSets after branching paths are generated.";
|
||||||
internal const string ForcedTileSetsTooltip = "The list of tiles that will be attempted to forcefully spawn. Each entry will spawn only one tile from it's list.\n\nIf the tile cannot be forcefully spawned, the dungeon generation will not restart.";
|
internal const string ForcedTileSetsTooltip = "The list of tiles that will be attempted to forcefully spawn. Each entry will spawn only one tile from it's list.\n\nIf the tile cannot be forcefully spawned, the dungeon generation will not restart.";
|
||||||
|
|
||||||
[Tooltip(UseForcedTilesTooltip)]
|
[Tooltip(UseForcedTilesTooltip)]
|
||||||
|
|
|
@ -45,16 +45,6 @@ namespace DunGenPlus.DevTools.Panels.Collections {
|
||||||
var tilesHashSet = new HashSet<NullObject<GameObject>>() { new NullObject<GameObject>(null) };
|
var tilesHashSet = new HashSet<NullObject<GameObject>>() { new NullObject<GameObject>(null) };
|
||||||
var archetypesHashSet = new HashSet<NullObject<DungeonArchetype>>() { new NullObject<DungeonArchetype>(null) };
|
var archetypesHashSet = new HashSet<NullObject<DungeonArchetype>>() { new NullObject<DungeonArchetype>(null) };
|
||||||
|
|
||||||
foreach(var t in dungeonFlow.Nodes) {
|
|
||||||
var label = t.Label.ToLowerInvariant();
|
|
||||||
if (label == "lchc gate" || label == "goal"){
|
|
||||||
foreach(var n in t.TileSets.SelectMany(x => x.TileWeights.Weights)) {
|
|
||||||
n.Value.GetComponent<Tile>().RepeatMode = TileRepeatMode.Allow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddTiles(IEnumerable<GameObject> tiles){
|
void AddTiles(IEnumerable<GameObject> tiles){
|
||||||
foreach(var x in tiles) {
|
foreach(var x in tiles) {
|
||||||
tilesHashSet.Add(x);
|
tilesHashSet.Add(x);
|
||||||
|
|
|
@ -67,6 +67,7 @@ namespace DunGenPlus.Generation {
|
||||||
|
|
||||||
|
|
||||||
DoorwayManager.ResetList();
|
DoorwayManager.ResetList();
|
||||||
|
DoorwayManager.onMainEntranceTeleportSpawnedEvent.ClearTemporaryActionList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Deactivate(){
|
public static void Deactivate(){
|
||||||
|
@ -99,14 +100,7 @@ namespace DunGenPlus.Generation {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerator GenerateAlternativeMainPaths(DungeonGenerator gen) {
|
public static IEnumerator GenerateAlternativeMainPaths(DungeonGenerator gen) {
|
||||||
|
// default behaviour
|
||||||
var altCount = Properties.MainPathProperties.MainPathCount - 1;
|
|
||||||
tileProxyMainPath.Clear();
|
|
||||||
|
|
||||||
var mainRoomTilePrefab = Properties.MainPathProperties.MainRoomTilePrefab;
|
|
||||||
var copyNodeBehaviour = Properties.MainPathProperties.CopyNodeBehaviour;
|
|
||||||
|
|
||||||
// default behaviour in case the multiple main paths are not considered
|
|
||||||
if (!Active) {
|
if (!Active) {
|
||||||
ActiveAlternative = false;
|
ActiveAlternative = false;
|
||||||
yield return gen.Wait(gen.GenerateBranchPaths());
|
yield return gen.Wait(gen.GenerateBranchPaths());
|
||||||
|
@ -114,19 +108,19 @@ namespace DunGenPlus.Generation {
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var altCount = Properties.MainPathProperties.MainPathCount - 1;
|
||||||
|
tileProxyMainPath.Clear();
|
||||||
|
|
||||||
|
var mainRoomTilePrefab = Properties.MainPathProperties.MainRoomTilePrefab;
|
||||||
|
var copyNodeBehaviour = Properties.MainPathProperties.CopyNodeBehaviour;
|
||||||
|
|
||||||
if (altCount <= 0) {
|
if (altCount <= 0) {
|
||||||
Plugin.logger.LogInfo($"Switching to default dungeon branch generation due to MainPathCount being {altCount + 1}");
|
yield return gen.Wait(GenerateBranchPaths(gen, $"MainPathCount being {altCount + 1}", LogLevel.Info));
|
||||||
ActiveAlternative = false;
|
|
||||||
yield return gen.Wait(gen.GenerateBranchPaths());
|
|
||||||
ActiveAlternative = true;
|
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mainRoomTilePrefab == null) {
|
if (mainRoomTilePrefab == null) {
|
||||||
Plugin.logger.LogWarning($"Switching to default dungeon branch generation due to MainRoomTilePrefab being null");
|
yield return gen.Wait(GenerateBranchPaths(gen, $"MainRoomTilePrefab being null", LogLevel.Warning));
|
||||||
ActiveAlternative = false;
|
|
||||||
yield return gen.Wait(gen.GenerateBranchPaths());
|
|
||||||
ActiveAlternative = true;
|
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,10 +133,7 @@ namespace DunGenPlus.Generation {
|
||||||
// this MUST have multiple doorways as you can imagine
|
// this MUST have multiple doorways as you can imagine
|
||||||
var mainRoom = gen.proxyDungeon.MainPathTiles.FirstOrDefault(t => t.Prefab == mainRoomTilePrefab);
|
var mainRoom = gen.proxyDungeon.MainPathTiles.FirstOrDefault(t => t.Prefab == mainRoomTilePrefab);
|
||||||
if (mainRoom == null) {
|
if (mainRoom == null) {
|
||||||
Plugin.logger.LogWarning($"Switching to default dungeon branch generation due to MainRoomTilePrefab not spawning on the main path");
|
yield return gen.Wait(GenerateBranchPaths(gen, $"MainRoomTilePrefab not spawning on the main path", LogLevel.Warning));
|
||||||
ActiveAlternative = false;
|
|
||||||
yield return gen.Wait(gen.GenerateBranchPaths());
|
|
||||||
ActiveAlternative = true;
|
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,10 +149,7 @@ namespace DunGenPlus.Generation {
|
||||||
startingNodeIndexCache = nodesSorted.FindIndex(n => n.TileSets.SelectMany(t => t.TileWeights.Weights).Any(t => t.Value == mainRoomTilePrefab));
|
startingNodeIndexCache = nodesSorted.FindIndex(n => n.TileSets.SelectMany(t => t.TileWeights.Weights).Any(t => t.Value == mainRoomTilePrefab));
|
||||||
|
|
||||||
if (startingNodeIndexCache == -1) {
|
if (startingNodeIndexCache == -1) {
|
||||||
Plugin.logger.LogWarning($"Switching to default dungeon branch generation due to CopyNodeBehaviour being CopyFromNodeList AND MainRoomTilePrefab not existing in the Nodes' tilesets");
|
yield return gen.Wait(GenerateBranchPaths(gen, $"CopyNodeBehaviour being CopyFromNodeList AND MainRoomTilePrefab not existing in the Nodes' tilesets", LogLevel.Warning));
|
||||||
ActiveAlternative = false;
|
|
||||||
yield return gen.Wait(gen.GenerateBranchPaths());
|
|
||||||
ActiveAlternative = true;
|
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,6 +301,16 @@ namespace DunGenPlus.Generation {
|
||||||
AddForcedTiles(gen);
|
AddForcedTiles(gen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IEnumerator GenerateBranchPaths(DungeonGenerator gen, string message, LogLevel logLevel){
|
||||||
|
Plugin.logger.Log(logLevel, $"Switching to default dungeon branch generation: {message}");
|
||||||
|
|
||||||
|
ActiveAlternative = false;
|
||||||
|
yield return gen.Wait(gen.GenerateBranchPaths());
|
||||||
|
ActiveAlternative = true;
|
||||||
|
|
||||||
|
AddForcedTiles(gen);
|
||||||
|
}
|
||||||
|
|
||||||
public static void FixDoorwaysToAllFloors(TileProxy mainRoom, MainRoomDoorwayGroups doorwayGroups) {
|
public static void FixDoorwaysToAllFloors(TileProxy mainRoom, MainRoomDoorwayGroups doorwayGroups) {
|
||||||
var first = doorwayGroups.doorwayListFirst;
|
var first = doorwayGroups.doorwayListFirst;
|
||||||
if (first == null) return;
|
if (first == null) return;
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace DunGenPlus {
|
||||||
|
|
||||||
internal const string modGUID = "dev.ladyalice.dungenplus";
|
internal const string modGUID = "dev.ladyalice.dungenplus";
|
||||||
private const string modName = "Dungeon Generation Plus";
|
private const string modName = "Dungeon Generation Plus";
|
||||||
private const string modVersion = "1.1.0";
|
private const string modVersion = "1.1.2";
|
||||||
|
|
||||||
internal readonly Harmony Harmony = new Harmony(modGUID);
|
internal readonly Harmony Harmony = new Harmony(modGUID);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue