Removed hard coded stuff

BranchPathMultiSim system now works with all dungeons
This commit is contained in:
LadyAliceMargatroid 2024-09-01 18:43:43 -07:00
parent b7a70f56d6
commit b46908ec51
4 changed files with 24 additions and 36 deletions

View File

@ -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)]

View File

@ -45,16 +45,6 @@ namespace DunGenPlus.DevTools.Panels.Collections {
var tilesHashSet = new HashSet<NullObject<GameObject>>() { new NullObject<GameObject>(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){
foreach(var x in tiles) {
tilesHashSet.Add(x);

View File

@ -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;

View File

@ -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);