From b46908ec514dc82cf458da0a4f060fbb74c3648c Mon Sep 17 00:00:00 2001 From: LadyAliceMargatroid Date: Sun, 1 Sep 2024 18:43:43 -0700 Subject: [PATCH] Removed hard coded stuff BranchPathMultiSim system now works with all dungeons --- .../DunGenExtenderPropertiesCollection.cs | 2 +- .../Collections/DungeonFlowCacheAssets.cs | 10 ---- .../Generation/DunGenPlusGenerator.cs | 46 +++++++++---------- DunGenPlus/DunGenPlus/Plugin.cs | 2 +- 4 files changed, 24 insertions(+), 36 deletions(-) diff --git a/DunGenPlus/DunGenPlus/Collections/DunGenExtenderPropertiesCollection.cs b/DunGenPlus/DunGenPlus/Collections/DunGenExtenderPropertiesCollection.cs index 188076b..3787a5c 100644 --- a/DunGenPlus/DunGenPlus/Collections/DunGenExtenderPropertiesCollection.cs +++ b/DunGenPlus/DunGenPlus/Collections/DunGenExtenderPropertiesCollection.cs @@ -149,7 +149,7 @@ namespace DunGenPlus.Collections { [System.Serializable] 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."; [Tooltip(UseForcedTilesTooltip)] diff --git a/DunGenPlus/DunGenPlus/DevTools/Panels/Collections/DungeonFlowCacheAssets.cs b/DunGenPlus/DunGenPlus/DevTools/Panels/Collections/DungeonFlowCacheAssets.cs index e1d0143..180ca5d 100644 --- a/DunGenPlus/DunGenPlus/DevTools/Panels/Collections/DungeonFlowCacheAssets.cs +++ b/DunGenPlus/DunGenPlus/DevTools/Panels/Collections/DungeonFlowCacheAssets.cs @@ -45,16 +45,6 @@ namespace DunGenPlus.DevTools.Panels.Collections { var tilesHashSet = new HashSet>() { new NullObject(null) }; var archetypesHashSet = new HashSet>() { new NullObject(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().RepeatMode = TileRepeatMode.Allow; - } - } - - } - void AddTiles(IEnumerable tiles){ foreach(var x in tiles) { tilesHashSet.Add(x); diff --git a/DunGenPlus/DunGenPlus/Generation/DunGenPlusGenerator.cs b/DunGenPlus/DunGenPlus/Generation/DunGenPlusGenerator.cs index 25fe5b1..bb74a4f 100644 --- a/DunGenPlus/DunGenPlus/Generation/DunGenPlusGenerator.cs +++ b/DunGenPlus/DunGenPlus/Generation/DunGenPlusGenerator.cs @@ -67,6 +67,7 @@ namespace DunGenPlus.Generation { DoorwayManager.ResetList(); + DoorwayManager.onMainEntranceTeleportSpawnedEvent.ClearTemporaryActionList(); } public static void Deactivate(){ @@ -99,14 +100,7 @@ namespace DunGenPlus.Generation { } public static IEnumerator GenerateAlternativeMainPaths(DungeonGenerator gen) { - - 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 + // default behaviour if (!Active) { ActiveAlternative = false; yield return gen.Wait(gen.GenerateBranchPaths()); @@ -114,19 +108,19 @@ namespace DunGenPlus.Generation { yield break; } + var altCount = Properties.MainPathProperties.MainPathCount - 1; + tileProxyMainPath.Clear(); + + var mainRoomTilePrefab = Properties.MainPathProperties.MainRoomTilePrefab; + var copyNodeBehaviour = Properties.MainPathProperties.CopyNodeBehaviour; + if (altCount <= 0) { - Plugin.logger.LogInfo($"Switching to default dungeon branch generation due to MainPathCount being {altCount + 1}"); - ActiveAlternative = false; - yield return gen.Wait(gen.GenerateBranchPaths()); - ActiveAlternative = true; + yield return gen.Wait(GenerateBranchPaths(gen, $"MainPathCount being {altCount + 1}", LogLevel.Info)); yield break; } if (mainRoomTilePrefab == null) { - Plugin.logger.LogWarning($"Switching to default dungeon branch generation due to MainRoomTilePrefab being null"); - ActiveAlternative = false; - yield return gen.Wait(gen.GenerateBranchPaths()); - ActiveAlternative = true; + yield return gen.Wait(GenerateBranchPaths(gen, $"MainRoomTilePrefab being null", LogLevel.Warning)); yield break; } @@ -139,10 +133,7 @@ namespace DunGenPlus.Generation { // this MUST have multiple doorways as you can imagine var mainRoom = gen.proxyDungeon.MainPathTiles.FirstOrDefault(t => t.Prefab == mainRoomTilePrefab); if (mainRoom == null) { - Plugin.logger.LogWarning($"Switching to default dungeon branch generation due to MainRoomTilePrefab not spawning on the main path"); - ActiveAlternative = false; - yield return gen.Wait(gen.GenerateBranchPaths()); - ActiveAlternative = true; + yield return gen.Wait(GenerateBranchPaths(gen, $"MainRoomTilePrefab not spawning on the main path", LogLevel.Warning)); 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)); 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"); - ActiveAlternative = false; - yield return gen.Wait(gen.GenerateBranchPaths()); - ActiveAlternative = true; + yield return gen.Wait(GenerateBranchPaths(gen, $"CopyNodeBehaviour being CopyFromNodeList AND MainRoomTilePrefab not existing in the Nodes' tilesets", LogLevel.Warning)); yield break; } @@ -313,6 +301,16 @@ namespace DunGenPlus.Generation { 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) { var first = doorwayGroups.doorwayListFirst; if (first == null) return; diff --git a/DunGenPlus/DunGenPlus/Plugin.cs b/DunGenPlus/DunGenPlus/Plugin.cs index 661c239..338d86d 100644 --- a/DunGenPlus/DunGenPlus/Plugin.cs +++ b/DunGenPlus/DunGenPlus/Plugin.cs @@ -25,7 +25,7 @@ namespace DunGenPlus { internal const string modGUID = "dev.ladyalice.dungenplus"; 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);