diff --git a/DunGenPlus/DunGenPlus/API.cs b/DunGenPlus/DunGenPlus/API.cs
index 45d91e1..89aa1de 100644
--- a/DunGenPlus/DunGenPlus/API.cs
+++ b/DunGenPlus/DunGenPlus/API.cs
@@ -96,6 +96,24 @@ namespace DunGenPlus
return null;
}
+ ///
+ /// Returns true if the Dungeon Generation Plus logic is active for .
+ ///
+ ///
+ ///
+ public static bool IsDunGenExtenderActive(DungeonFlow dungeonFlow){
+ return IsDunGenExtenderActive(GetDunGenExtender(dungeonFlow));
+ }
+
+ ///
+ /// Returns true if the Dungeon Generation Plus logic is active for .
+ ///
+ ///
+ ///
+ public static bool IsDunGenExtenderActive(DunGenExtender extender){
+ return extender != null && extender == DunGenPlusGenerator.Instance;
+ }
+
///
/// Creates and returns an empty .
///
@@ -108,5 +126,13 @@ namespace DunGenPlus
return extender;
}
+ ///
+ /// DO NOT USE!
+ ///
+ ///
+ public static void AddTileToMainPathDictionary(Dictionary dictionary){
+ DunGenPlusGenerator.AddTileToMainPathDictionary(dictionary);
+ }
+
}
}
diff --git a/DunGenPlus/DunGenPlus/Collections/DunGenExtenderPropertiesCollection.cs b/DunGenPlus/DunGenPlus/Collections/DunGenExtenderPropertiesCollection.cs
index 7cc1ffc..6d4f127 100644
--- a/DunGenPlus/DunGenPlus/Collections/DunGenExtenderPropertiesCollection.cs
+++ b/DunGenPlus/DunGenPlus/Collections/DunGenExtenderPropertiesCollection.cs
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using static DunGenPlus.Collections.DunGenExtenderProperties;
using UnityEngine;
using DunGen;
+using DunGen.Graph;
namespace DunGenPlus.Collections {
@@ -16,6 +17,7 @@ namespace DunGenPlus.Collections {
internal const string MainRoomTilePrefabTooltip = "The Tile prefab where the additional main paths will start from.\n\nCannot be null if MainPathCount is more than 1.";
internal const string CopyNodeBehaviourTooltip = "Defines how the nodes list is copied onto the additional main paths.\n\nCopyFromMainPathPosition: nodes will copy based on the MainRoomTilePrefab's position in the main path.\nCopyFromNodeList: nodes will copy based on the MainRoomTilePrefab's position in the node list + 1.";
internal const string MainPathDetailsTooltip = "Overrides certain DungeonFlow values during the main path generation.\n\nThe order of items in this list correspond to the order of the main paths being generated.\nThe first item in this list will activate for the first main path, the second item for the second main path, and so on. If there are more main paths than items in this list, the last item is used instead.";
+ internal const string LocalMainPathGlobalPropsTooltip = "Limits the amount of Global Props that can spawn on a single main path.\n\nThis does not afffect the global limit defined in DungeonFlow.";
[Tooltip(MainPathCountTooltip)]
@@ -27,6 +29,8 @@ namespace DunGenPlus.Collections {
public CopyNodeBehaviour CopyNodeBehaviour = CopyNodeBehaviour.CopyFromMainPathPosition;
[Tooltip(MainPathDetailsTooltip)]
public List MainPathDetails = new List();
+ [Tooltip(LocalMainPathGlobalPropsTooltip)]
+ public List LocalMainPathGlobalProps = new List();
public MainPathExtender GetMainPathDetails(int index) {
var count = MainPathDetails.Count;
@@ -40,6 +44,7 @@ namespace DunGenPlus.Collections {
MainRoomTilePrefab = props.MainRoomTilePrefab;
CopyNodeBehaviour = props.CopyNodeBehaviour;
MainPathDetails = props.MainPathDetails;
+ LocalMainPathGlobalProps = props.LocalMainPathGlobalProps;
}
internal MainPathProperties Copy() {
diff --git a/DunGenPlus/DunGenPlus/DunGenPlus/DunGenPlus.dll b/DunGenPlus/DunGenPlus/DunGenPlus/DunGenPlus.dll
index 75d4778..18fac0c 100644
Binary files a/DunGenPlus/DunGenPlus/DunGenPlus/DunGenPlus.dll and b/DunGenPlus/DunGenPlus/DunGenPlus/DunGenPlus.dll differ
diff --git a/DunGenPlus/DunGenPlus/Generation/DunGenPlusGenerator.cs b/DunGenPlus/DunGenPlus/Generation/DunGenPlusGenerator.cs
index 08ea045..404d9aa 100644
--- a/DunGenPlus/DunGenPlus/Generation/DunGenPlusGenerator.cs
+++ b/DunGenPlus/DunGenPlus/Generation/DunGenPlusGenerator.cs
@@ -87,19 +87,50 @@ namespace DunGenPlus.Generation {
}
private static Dictionary tileProxyMainPath = new Dictionary();
+ private static Dictionary tileMainPath = new Dictionary();
public static int GetMainPathIndexFromTileProxy(TileProxy tileProxy){
return tileProxyMainPath[tileProxy];
}
- private static void AddTileProxyToMainPathDictionary(IEnumerable tileProxies, int index) {
+ public static int GetMainPathIndexFromTile(Tile tile){
+ return tileMainPath[tile];
+ }
+
+ public static void AddTileProxy(TileProxy tileProxy, int index) {
+ //Plugin.logger.LogWarning($"Adding: {tileProxy.Prefab.name} ({tileProxy.Placement.IsOnMainPath}): {index}");
+ tileProxyMainPath.Add(tileProxy, index);
+ }
+
+ public static void AddMainPathTileProxies(IEnumerable tileProxies, int index){
var totalLength = (float)tileProxies.Last().Placement.PathDepth;
foreach(var t in tileProxies) {
- tileProxyMainPath.Add(t, index);
+ AddTileProxy(t, index);
t.Placement.NormalizedPathDepth = t.Placement.PathDepth / totalLength;
}
}
+ public static void BuildBranchPathTileProxiesDictionary(DungeonProxy dungeonProxy){
+ var lastIndex = 0;
+ foreach(var connection in dungeonProxy.Connections){
+ var aTileProxy = connection.A.TileProxy;
+ if (aTileProxy.Placement.IsOnMainPath) {
+ lastIndex = GetMainPathIndexFromTileProxy(aTileProxy);
+ }
+
+ var bTileProxy = connection.B.TileProxy;
+ if (!bTileProxy.Placement.IsOnMainPath){
+ AddTileProxy(bTileProxy, lastIndex);
+ }
+ }
+ }
+
+ public static void AddTileToMainPathDictionary(Dictionary dictionary){
+ foreach(var pair in dictionary){
+ tileMainPath.Add(pair.Value, GetMainPathIndexFromTileProxy(pair.Key));
+ }
+ }
+
public static IEnumerator GenerateAlternativeMainPaths(DungeonGenerator gen) {
// default behaviour
@@ -112,6 +143,10 @@ namespace DunGenPlus.Generation {
var altCount = Properties.MainPathProperties.MainPathCount - 1;
tileProxyMainPath.Clear();
+ tileMainPath.Clear();
+
+ var firstMainPathTiles = gen.proxyDungeon.MainPathTiles.ToList();
+ AddMainPathTileProxies(firstMainPathTiles, 0);
var mainRoomTilePrefab = Properties.MainPathProperties.MainRoomTilePrefab;
var copyNodeBehaviour = Properties.MainPathProperties.CopyNodeBehaviour;
@@ -127,9 +162,7 @@ namespace DunGenPlus.Generation {
}
var allMainPathTiles = new List>();
- var firstMainPathTiles = gen.proxyDungeon.MainPathTiles.ToList();
allMainPathTiles.Add(firstMainPathTiles);
- AddTileProxyToMainPathDictionary(firstMainPathTiles, 0);
// main room is the true main room and not the fake room
// this MUST have multiple doorways as you can imagine
@@ -267,7 +300,7 @@ namespace DunGenPlus.Generation {
if (gen.ShouldSkipFrame(true)) yield return gen.GetRoomPause();
}
- AddTileProxyToMainPathDictionary(newMainPathTiles, b + 1);
+ AddMainPathTileProxies(newMainPathTiles, b + 1);
allMainPathTiles.Add(newMainPathTiles);
}
@@ -291,13 +324,17 @@ namespace DunGenPlus.Generation {
yield return gen.Wait(GenerateMultiBranchPaths(gen));
GenerateBranchBoostedPathsStopWatch.Stop();
GenerateBranchBoostedPathsTime += (float)GenerateBranchBoostedPathsStopWatch.Elapsed.TotalMilliseconds;
+ } else {
+ yield return gen.Wait(gen.GenerateBranchPaths());
}
- else yield return gen.Wait(gen.GenerateBranchPaths());
}
ActiveAlternative = true;
-
gen.proxyDungeon.MainPathTiles = allMainPathTiles[0];
+
+ if (!Properties.BranchPathMultiSimulationProperties.UseBranchPathMultiSim){
+ BuildBranchPathTileProxiesDictionary(gen.proxyDungeon);
+ }
AddForcedTiles(gen);
}
@@ -312,6 +349,7 @@ namespace DunGenPlus.Generation {
yield return gen.Wait(gen.GenerateBranchPaths());
ActiveAlternative = true;
+ BuildBranchPathTileProxiesDictionary(gen.proxyDungeon);
AddForcedTiles(gen);
}
diff --git a/DunGenPlus/DunGenPlus/Generation/DunGenPlusGeneratorBranchLoop.cs b/DunGenPlus/DunGenPlus/Generation/DunGenPlusGeneratorBranchLoop.cs
index b1f4aa7..20bef46 100644
--- a/DunGenPlus/DunGenPlus/Generation/DunGenPlusGeneratorBranchLoop.cs
+++ b/DunGenPlus/DunGenPlus/Generation/DunGenPlusGeneratorBranchLoop.cs
@@ -191,7 +191,7 @@ namespace DunGenPlus.Generation
gen.injectedTiles = bestPath.injectedTiles;
gen.tilesPendingInjection = bestPath.tilesPendingInjection;
- AddTileProxyToMainPathDictionary(bestPath.list.Select(x => x.tileProxy), bestPath.mainPathIndex);
+ AddMainPathTileProxies(bestPath.list.Select(x => x.tileProxy), bestPath.mainPathIndex);
if (gen.ShouldSkipFrame(true)){
yield return gen.GetRoomPause();
diff --git a/DunGenPlus/DunGenPlus/Generation/DunGenPlusGeneratorMiscellaneous.cs b/DunGenPlus/DunGenPlus/Generation/DunGenPlusGeneratorMiscellaneous.cs
index d64a88f..f19fe34 100644
--- a/DunGenPlus/DunGenPlus/Generation/DunGenPlusGeneratorMiscellaneous.cs
+++ b/DunGenPlus/DunGenPlus/Generation/DunGenPlusGeneratorMiscellaneous.cs
@@ -2,10 +2,13 @@
using DunGen.Graph;
using DunGenPlus.DevTools;
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using UnityEngine;
+using static UnityEngine.Rendering.DebugUI;
namespace DunGenPlus.Generation {
internal partial class DunGenPlusGenerator {
@@ -33,6 +36,7 @@ namespace DunGenPlus.Generation {
var tileProxy = gen.AddTile(t, item.TileSets, t.Placement.NormalizedDepth, null, TilePlacementResult.None);
if (tileProxy == null) continue;
+ AddTileProxy(tileProxy, GetMainPathIndexFromTileProxy(t));
tileProxy.Placement.BranchDepth = t.Placement.BranchDepth;
tileProxy.Placement.NormalizedBranchDepth = t.Placement.NormalizedDepth;
tileProxy.Placement.GraphNode = t.Placement.GraphNode;
@@ -92,5 +96,133 @@ namespace DunGenPlus.Generation {
return defaultState || DevDebugManager.IsActive;
}
+ // Copied and pasted from DunGen
+ public static void ProcessGlobalPropsPerMainPath(DungeonGenerator dungeonGenerator){
+ var localIDs = Properties.MainPathProperties.LocalMainPathGlobalProps.Select(x => x.ID).ToHashSet();
+
+ // first parameter int is the GlobalProp ID
+ // second parameter is the List of GameObjectChanceTable indexed by the main path index
+ var localDictionary = new Dictionary>();
+
+ // default dictionary
+ var globalDictionary = new Dictionary();
+
+ foreach(var tile in dungeonGenerator.CurrentDungeon.AllTiles){
+ foreach(var globalProp in tile.GetComponentsInChildren()){
+ GameObjectChanceTable gameObjectChanceTable;
+ if (localIDs.Contains(globalProp.PropGroupID)){
+ if (!localDictionary.TryGetValue(globalProp.PropGroupID, out var dictionary)){
+ dictionary = new Dictionary();
+ localDictionary.Add(globalProp.PropGroupID, dictionary);
+ }
+
+ // The game will softlock if it can't find the tile
+ // THIS IS SCARY!!!
+ var mainPathIndex = GetMainPathIndexFromTile(tile);
+ if (!dictionary.TryGetValue(mainPathIndex, out gameObjectChanceTable)){
+ gameObjectChanceTable = new GameObjectChanceTable();
+ dictionary.Add(mainPathIndex, gameObjectChanceTable);
+ }
+ } else {
+ if (!globalDictionary.TryGetValue(globalProp.PropGroupID, out gameObjectChanceTable)){
+ gameObjectChanceTable = new GameObjectChanceTable();
+ globalDictionary.Add(globalProp.PropGroupID, gameObjectChanceTable);
+ }
+ }
+
+ var num = tile.Placement.IsOnMainPath ? globalProp.MainPathWeight : globalProp.BranchPathWeight;
+ num *= globalProp.DepthWeightScale.Evaluate(tile.Placement.NormalizedDepth);
+ gameObjectChanceTable.Weights.Add(new GameObjectChance(globalProp.gameObject, num, 0f, null));
+
+ }
+ }
+
+ foreach(var dictionary in localDictionary.Values){
+ foreach(var table2 in dictionary.Values){
+ foreach(var gameObjectChance in table2.Weights){
+ gameObjectChance.Value.SetActive(false);
+ }
+ }
+ }
+
+ foreach(var table2 in globalDictionary.Values){
+ foreach(var gameObjectChance in table2.Weights){
+ gameObjectChance.Value.SetActive(false);
+ }
+ }
+
+ var list = new List(localDictionary.Count + globalDictionary.Count);
+
+ int ProcessGlobalPropID(GameObjectChanceTable table, int localMax, int globalCount, int globalMax){
+ localMax = Mathf.Clamp(localMax, 0, table.Weights.Count);
+ var i = 0;
+ while(i < localMax && i + globalCount < globalMax){
+ var random = table.GetRandom(dungeonGenerator.RandomStream, true, 0f, null, true, true);
+ if (random != null && random.Value != null) {
+ random.Value.SetActive(true);
+ }
+ ++i;
+ }
+ return i;
+ }
+
+ using(var enumerator = globalDictionary.GetEnumerator()){
+ while(enumerator.MoveNext()){
+ var pair = enumerator.Current;
+ if (list.Contains(pair.Key)){
+ Plugin.logger.LogWarning("Dungeon Flow contains multiple entries for the global prop group ID: " + pair.Key.ToString() + ". Only the first entry will be used.");
+ } else {
+ //Plugin.logger.LogWarning($"{pair.Key}: Global");
+
+ var globalPropSettings = dungeonGenerator.DungeonFlow.GlobalProps
+ .Where(x => x.ID == pair.Key)
+ .FirstOrDefault();
+
+ if (globalPropSettings != null){
+ var tableClone = pair.Value.Clone();
+ var globalMax = globalPropSettings.Count.GetRandom(dungeonGenerator.RandomStream);
+
+ var spawned = ProcessGlobalPropID(tableClone, globalMax, 0, globalMax);
+ //Plugin.logger.LogError($"Spawned {spawned} ({spawned}/{globalMax})");
+ list.Add(pair.Key);
+ }
+ }
+ }
+ }
+
+ using(var enumerator = localDictionary.GetEnumerator()){
+ while(enumerator.MoveNext()){
+ var pair = enumerator.Current;
+ if (list.Contains(pair.Key)){
+ Plugin.logger.LogWarning("Dungeon Flow contains multiple entries for the global prop group ID: " + pair.Key.ToString() + ". Only the first entry will be used.");
+ } else {
+ //Plugin.logger.LogWarning($"{pair.Key}: Local");
+
+ var globalPropSettings = dungeonGenerator.DungeonFlow.GlobalProps
+ .Where(x => x.ID == pair.Key)
+ .FirstOrDefault();
+ var localPropSettings = Properties.MainPathProperties.LocalMainPathGlobalProps
+ .Where(x => x.ID == pair.Key)
+ .FirstOrDefault();
+
+ if (globalPropSettings != null && localPropSettings != null){
+ var globalCount = 0;
+ foreach(var path in pair.Value.Values){
+ var tableClone = path.Clone();
+ var globalMax = globalPropSettings.Count.GetRandom(dungeonGenerator.RandomStream);
+ var localMax = localPropSettings.Count.GetRandom(dungeonGenerator.RandomStream);
+
+ var spawned = ProcessGlobalPropID(tableClone, localMax, globalCount, globalMax);
+ globalCount += spawned;
+ //Plugin.logger.LogError($"Spawned {spawned} ({globalCount}/{globalMax})");
+ }
+ list.Add(pair.Key);
+ }
+ }
+ }
+ }
+
+ }
+
}
}
diff --git a/DunGenPlus/DunGenPlus/Patches/DungeonGeneratorPatch.cs b/DunGenPlus/DunGenPlus/Patches/DungeonGeneratorPatch.cs
index 1cefec8..694e6d4 100644
--- a/DunGenPlus/DunGenPlus/Patches/DungeonGeneratorPatch.cs
+++ b/DunGenPlus/DunGenPlus/Patches/DungeonGeneratorPatch.cs
@@ -20,6 +20,24 @@ using DunGenPlus.Components;
namespace DunGenPlus.Patches {
internal class DungeonGeneratorPatch {
+ [HarmonyPriority(Priority.First)]
+ [HarmonyPatch(typeof(DungeonGenerator), "Generate")]
+ [HarmonyPrefix]
+ public static void GeneratePatch(ref DungeonGenerator __instance){
+ DunGenPlusGenerator.Deactivate();
+
+ var flow = __instance.DungeonFlow;
+ var extender = API.GetDunGenExtender(flow);
+ if (extender && extender.Active) {
+ Plugin.logger.LogInfo($"Loading DunGenExtender for {flow.name}");
+ DunGenPlusGenerator.Activate(__instance, extender);
+ return;
+ }
+
+ Plugin.logger.LogInfo($"Did not load a DunGenExtenderer");
+ DunGenPlusGenerator.Deactivate();
+ }
+
[HarmonyPostfix]
[HarmonyPatch(typeof(DungeonGenerator), "InnerGenerate")]
public static void InnerGeneratePatch(ref DungeonGenerator __instance, bool isRetry, ref IEnumerator __result){
@@ -325,6 +343,49 @@ namespace DunGenPlus.Patches {
lastTilePlacementResult = result;
}
+ [HarmonyTranspiler]
+ [HarmonyPatch(typeof(Dungeon), "FromProxy")]
+ public static IEnumerable FromProxyPatch(IEnumerable instructions){
+
+ var endSequence = new InstructionSequenceStandard("Forloop End");
+ endSequence.AddBasicLocal(OpCodes.Ldloca_S, 1);
+ endSequence.AddBasic(OpCodes.Constrained);
+ endSequence.AddBasic(OpCodes.Callvirt);
+ endSequence.AddBasic(OpCodes.Endfinally);
+
+ foreach(var instruction in instructions){
+ if (endSequence.VerifyStage(instruction)) {
+ yield return instruction;
+
+ var specialFunction = typeof(DunGenPlusGenerator).GetMethod("AddTileToMainPathDictionary", BindingFlags.Static | BindingFlags.Public);
+
+ yield return new CodeInstruction(OpCodes.Ldloc_0);
+ yield return new CodeInstruction(OpCodes.Call, specialFunction);
+
+ continue;
+ }
+ yield return instruction;
+ }
+
+ endSequence.ReportComplete();
+ }
+
+ [HarmonyPrefix]
+ [HarmonyPatch(typeof(DungeonGenerator), "ProcessGlobalProps")]
+ public static bool ProcessGlobalPropsPatch(ref DungeonGenerator __instance){
+ if (DunGenPlusGenerator.Active){
+ var list = DunGenPlusGenerator.Properties.MainPathProperties.LocalMainPathGlobalProps;
+ if (list != null && list.Count > 0) {
+ Plugin.logger.LogDebug("Performing Local Global Props algorithm");
+ DunGenPlusGenerator.ProcessGlobalPropsPerMainPath(__instance);
+ return false;
+ }
+
+ }
+ return true;
+ }
+
+
/*
[HarmonyTranspiler]
[HarmonyPatch(typeof(DungeonGenerator), "GenerateMainPath", MethodType.Enumerator)]
diff --git a/DunGenPlus/DunGenPlus/Plugin.cs b/DunGenPlus/DunGenPlus/Plugin.cs
index 4f4f326..f35cfa2 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.2.0";
+ private const string modVersion = "1.2.1";
internal readonly Harmony Harmony = new Harmony(modGUID);
@@ -58,25 +58,8 @@ namespace DunGenPlus {
Assets.LoadAssets();
Assets.LoadAssetBundle();
- DungeonManager.GlobalDungeonEvents.onBeforeDungeonGenerate.AddListener(OnDunGenExtenderLoad);
DoorwayManager.onMainEntranceTeleportSpawnedEvent.AddEvent("DoorwayCleanup", DoorwayManager.onMainEntranceTeleportSpawnedFunction);
}
- void OnDunGenExtenderLoad(RoundManager roundManager) {
- DunGenPlusGenerator.Deactivate();
-
- var generator = roundManager.dungeonGenerator.Generator;
- var flow = generator.DungeonFlow;
- var extender = API.GetDunGenExtender(flow);
- if (extender && extender.Active) {
- Plugin.logger.LogInfo($"Loading DunGenExtender for {flow.name}");
- DunGenPlusGenerator.Activate(generator, extender);
- return;
- }
-
- Plugin.logger.LogInfo($"Did not load a DunGenExtenderer");
- DunGenPlusGenerator.Deactivate();
- }
-
}
}
diff --git a/DunGenPlus/DunGenPlus/Utils/TranspilerUtilities.cs b/DunGenPlus/DunGenPlus/Utils/TranspilerUtilities.cs
index a0cc7ca..bb19449 100644
--- a/DunGenPlus/DunGenPlus/Utils/TranspilerUtilities.cs
+++ b/DunGenPlus/DunGenPlus/Utils/TranspilerUtilities.cs
@@ -255,11 +255,15 @@ namespace DunGenPlus.Utils {
public static void PrintInstructions(IEnumerable instructions) {
foreach(var i in instructions){
- var opString = i.opcode.ToString();
- var objString = i.operand != null ? i.operand.ToString() : "NULL";
- Plugin.logger.LogInfo($"{opString}: {objString}");
+ PrintInstruction(i);
}
}
+ public static void PrintInstruction(CodeInstruction inst) {
+ var opString = inst.opcode.ToString();
+ var objString = inst.operand != null ? inst.operand.ToString() : "NULL";
+ Plugin.logger.LogInfo($"{opString}: {objString}");
+ }
+
}
}
diff --git a/LoadstonePatch/LoadstoneNighty.sln b/LoadstonePatch/LoadstoneNighty.sln
new file mode 100644
index 0000000..24bcf79
--- /dev/null
+++ b/LoadstonePatch/LoadstoneNighty.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.10.35122.118
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoadstoneNighty", "LoadstoneNighty\LoadstoneNighty.csproj", "{B7C6EABD-16DB-4DE8-8013-1FA7DA6E8DE8}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {B7C6EABD-16DB-4DE8-8013-1FA7DA6E8DE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B7C6EABD-16DB-4DE8-8013-1FA7DA6E8DE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B7C6EABD-16DB-4DE8-8013-1FA7DA6E8DE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B7C6EABD-16DB-4DE8-8013-1FA7DA6E8DE8}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {874E9212-EB26-4670-8F00-EE17E1F48E01}
+ EndGlobalSection
+EndGlobal
diff --git a/LoadstonePatch/LoadstoneNighty/LoadstoneNighty.csproj b/LoadstonePatch/LoadstoneNighty/LoadstoneNighty.csproj
new file mode 100644
index 0000000..9a7c7f5
--- /dev/null
+++ b/LoadstonePatch/LoadstoneNighty/LoadstoneNighty.csproj
@@ -0,0 +1,76 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {B7C6EABD-16DB-4DE8-8013-1FA7DA6E8DE8}
+ Library
+ Properties
+ LoadstoneNighty
+ LoadstoneNighty
+ v4.8
+ 512
+ true
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\..\..\Libraries\0Harmony.dll
+
+
+ ..\..\..\Libraries\Assembly-CSharp-firstpass.dll
+
+
+ ..\..\..\Libraries\Assembly-CSharp-publicized.dll
+
+
+ ..\..\..\Libraries\BepInEx.dll
+
+
+ ..\..\..\Libraries\BepInEx.Harmony.dll
+
+
+ ..\..\..\Libraries\com.adibtw.loadstone.dll
+
+
+ ..\..\..\Libraries\DunGenPlus.dll
+
+
+
+
+
+
+
+
+
+
+ ..\..\..\Libraries\UnityEngine.dll
+
+
+ ..\..\..\Libraries\UnityEngine.CoreModule.dll
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LoadstonePatch/LoadstoneNighty/Patch.cs b/LoadstonePatch/LoadstoneNighty/Patch.cs
new file mode 100644
index 0000000..a853d3d
--- /dev/null
+++ b/LoadstonePatch/LoadstoneNighty/Patch.cs
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using DunGen;
+using DunGen.Graph;
+using DunGenPlus;
+using DunGenPlus.Collections;
+using HarmonyLib;
+
+namespace LoadstoneNighty {
+
+ public class Patch {
+
+ public static void Activate(){
+ Loadstone.Patches.DungenOptimizationPatches.tileCollectors.Add(GetTiles);
+ }
+
+ private static HashSet GetTiles(DungeonGenerator generator) {
+ var flow = generator.DungeonFlow;
+ var extender = API.GetDunGenExtender(flow);
+ var hashset = new HashSet();
+
+ if (API.IsDunGenExtenderActive(extender)){
+ Plugin.logger.LogDebug("Creating custom hashset for Loadstone");
+ var props = extender.Properties;
+ GenerateTileHashSet(ref hashset, props.MainPathProperties.MainPathDetails);
+ GenerateTileHashSet(ref hashset, props.AdditionalTilesProperties.AdditionalTileSets);
+ GenerateTileHashSet(ref hashset, props.NormalNodeArchetypesProperties.NormalNodeArchetypes);
+ GenerateTileHashSet(ref hashset, props.LineRandomizerProperties.Archetypes);
+ }
+ return hashset;
+ }
+
+ static void GenerateTileHashSet(ref HashSet tiles, List nodes) {
+ foreach (var n in nodes) {
+ GenerateTileHashSet(ref tiles, n.Archetypes);
+ }
+ }
+
+ static void GenerateTileHashSet(ref HashSet tiles, List list) {
+ foreach (var l in list) {
+ GenerateTileHashSet(ref tiles, l.TileSets);
+ }
+ }
+
+ static void GenerateTileHashSet(ref HashSet tiles, List extenders) {
+ foreach (var ext in extenders) {
+ GenerateTileHashSet(ref tiles, ext.Nodes.Value);
+ GenerateTileHashSet(ref tiles, ext.Lines.Value);
+ }
+ }
+
+ static void GenerateTileHashSet(ref HashSet tiles, List nodes) {
+ foreach (var n in nodes) {
+ GenerateTileHashSet(ref tiles, n.TileSets);
+ }
+ }
+
+ static void GenerateTileHashSet(ref HashSet tiles, List lines) {
+ foreach (var l in lines) {
+ GenerateTileHashSet(ref tiles, l.DungeonArchetypes);
+ }
+ }
+
+ static void GenerateTileHashSet(ref HashSet tiles, List archetypes) {
+ foreach (var a in archetypes) {
+ GenerateTileHashSet(ref tiles, a.TileSets);
+ GenerateTileHashSet(ref tiles, a.BranchCapTileSets);
+ }
+ }
+
+ static void GenerateTileHashSet(ref HashSet tiles, List tileSets) {
+ foreach (var tileSet in tileSets) {
+ foreach (var tileChance in tileSet.TileWeights.Weights) {
+ var tile = tileChance.Value.GetComponent();
+ if (tile != null) tiles.Add(tile);
+ }
+ }
+ }
+
+ [HarmonyPrefix]
+ [HarmonyPatch(typeof(Loadstone.Patches.FromProxyPatches), "FromProxyEnd")]
+ public static void FromProxyEndPatch(Dictionary dictionary){
+ DunGenPlus.API.AddTileToMainPathDictionary(dictionary);
+ }
+
+ }
+}
diff --git a/LoadstonePatch/LoadstoneNighty/Plugin.cs b/LoadstonePatch/LoadstoneNighty/Plugin.cs
new file mode 100644
index 0000000..927d11b
--- /dev/null
+++ b/LoadstonePatch/LoadstoneNighty/Plugin.cs
@@ -0,0 +1,61 @@
+using BepInEx.Bootstrap;
+using BepInEx.Logging;
+using BepInEx;
+using HarmonyLib;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace LoadstoneNighty {
+ [BepInPlugin(modGUID, modName, modVersion)]
+
+ [BepInDependency("dev.ladyalice.dungenplus", "1.2.1")]
+ [BepInDependency(targetModGUID, BepInDependency.DependencyFlags.SoftDependency)]
+
+ public class Plugin : BaseUnityPlugin {
+
+ public const string modGUID = "dev.ladyalice.dungenplus.loadstonepatch";
+ private const string modName = "Dungeon Generation Plus Loadstone Patch";
+ private const string modVersion = "1.0.0";
+
+ public const string targetModGUID = "com.adibtw.loadstone.Nightly";
+ public const string targetModVersion = "0.1.16";
+
+ public readonly Harmony harmony = new Harmony(modGUID);
+ public static Plugin Instance {get; private set;}
+ public static ManualLogSource logger { get; internal set; }
+
+ void Awake(){
+ if (Instance == null) Instance = this;
+
+ logger = BepInEx.Logging.Logger.CreateLogSource(modGUID);
+
+ var modLoaded = Chainloader.PluginInfos.ContainsKey(targetModGUID);
+ if (!modLoaded) return;
+
+ bool validVersion;
+ var pluginInfo = Chainloader.PluginInfos[targetModGUID];
+ var loadedVersion = pluginInfo.Metadata.Version;
+ if (string.IsNullOrWhiteSpace(targetModVersion)){
+ validVersion = true;
+ } else {
+ var requiredVersion = new Version(targetModVersion);
+ validVersion = loadedVersion >= requiredVersion;
+ }
+
+ if (validVersion){
+ logger.LogInfo($"Plugin {modName} has been added!");
+
+ try {
+ harmony.PatchAll(typeof(Patch));
+ } catch {
+
+ }
+
+ Patch.Activate();
+ }
+ }
+ }
+}
diff --git a/LoadstonePatch/LoadstoneNighty/Properties/AssemblyInfo.cs b/LoadstonePatch/LoadstoneNighty/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..9c52b5f
--- /dev/null
+++ b/LoadstonePatch/LoadstoneNighty/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// アセンブリに関する一般情報は以下を通して制御されます
+// 制御されます。アセンブリに関連付けられている情報を変更するには、
+// これらの属性値を変更してください。
+[assembly: AssemblyTitle("LoadstoneNighty")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("LoadstoneNighty")]
+[assembly: AssemblyCopyright("Copyright © 2024")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// ComVisible を false に設定すると、このアセンブリ内の型は COM コンポーネントから
+// 参照できなくなります。COM からこのアセンブリ内の型にアクセスする必要がある場合は、
+// その型の ComVisible 属性を true に設定してください。
+[assembly: ComVisible(false)]
+
+// このプロジェクトが COM に公開される場合、次の GUID が typelib の ID になります
+[assembly: Guid("b7c6eabd-16db-4de8-8013-1fa7da6e8de8")]
+
+// アセンブリのバージョン情報は、以下の 4 つの値で構成されています:
+//
+// メジャー バージョン
+// マイナー バージョン
+// ビルド番号
+// リビジョン
+//
+// すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
+// 既定値にすることができます:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]