diff --git a/DunGenPlus/DunGenPlus/Collections/ExtenderEvent.cs b/DunGenPlus/DunGenPlus/Collections/ExtenderEvent.cs index ba799f4..00afd06 100644 --- a/DunGenPlus/DunGenPlus/Collections/ExtenderEvent.cs +++ b/DunGenPlus/DunGenPlus/Collections/ExtenderEvent.cs @@ -5,6 +5,18 @@ using System.Text; using System.Threading.Tasks; namespace DunGenPlus.Collections { + + + public struct EventCallbackScenario { + public bool IsDevDebug; + + public EventCallbackScenario(bool isDevDebug){ + IsDevDebug = isDevDebug; + } + + } + + public class ExtenderEvent { internal event ParameterEvent onParameterEvent; @@ -13,8 +25,8 @@ namespace DunGenPlus.Collections { /// Calls listeners. /// /// - public void Invoke(T param) { - onParameterEvent?.Invoke(param); + public void Invoke(T param1, EventCallbackScenario param2) { + onParameterEvent?.Invoke(param1, param2); } /// @@ -33,6 +45,7 @@ namespace DunGenPlus.Collections { onParameterEvent -= listener; } - public delegate void ParameterEvent(T param); + public delegate void ParameterEvent(T param1, EventCallbackScenario param2); } + } diff --git a/DunGenPlus/DunGenPlus/DevTools/DevDebugManagerUI.cs b/DunGenPlus/DunGenPlus/DevTools/DevDebugManagerUI.cs index edb42b5..a246690 100644 --- a/DunGenPlus/DunGenPlus/DevTools/DevDebugManagerUI.cs +++ b/DunGenPlus/DunGenPlus/DevTools/DevDebugManagerUI.cs @@ -127,6 +127,11 @@ namespace DunGenPlus.DevTools { return CreateOptionsUIField(parentTransform, titleParameter, baseValue, setAction, (i) => assetCache.tiles.list[i].Item, assetCache.tiles.options); } + public DropdownInputField CreateTileSetsOptionsUIField(Transform parentTransform, TitleParameter titleParameter, int baseValue, Action setAction){ + var assetCache = DunGenPlusPanel.Instance.selectedAssetCache; + return CreateOptionsUIField(parentTransform, titleParameter, baseValue, setAction, (i) => assetCache.tileSets.list[i].Item, assetCache.tileSets.options); + } + public DropdownInputField CreateArchetypeOptionsUIField(Transform parentTransform, TitleParameter titleParameter, int baseValue, Action setAction){ var assetCache = DunGenPlusPanel.Instance.selectedAssetCache; return CreateOptionsUIField(parentTransform, titleParameter, baseValue, setAction, (i) => assetCache.archetypes.list[i].Item, assetCache.archetypes.options); @@ -137,5 +142,39 @@ namespace DunGenPlus.DevTools { return CreateOptionsUIField(parentTransform, titleParameter, baseValue, setAction, (i) => (DunGenExtenderProperties.CopyNodeBehaviour)i, options); } + public DropdownInputField CreateAnimationCurveOptionsUIField(Transform parentTransform, TitleParameter titleParameter, AnimationCurve baseValue, Action setAction){ + var result = CreateAnimationCurves(baseValue); + var curves = result.animationCurves; + var options = result.options; + setAction.Invoke(curves[0]); + return CreateOptionsUIField(parentTransform, titleParameter, 0, setAction, (i) => curves[i], options); + } + + private (List animationCurves, List options) CreateAnimationCurves(AnimationCurve custom){ + var curves = new List(); + var options = new List(); + if (custom != null){ + curves.Add(custom); + options.Add("Custom"); + } + + curves.Add(AnimationCurve.Constant(0f, 1f, 1f)); + options.Add("Constant 1"); + + curves.Add(AnimationCurve.Linear(0f, 0f, 1f, 1f)); + options.Add("Linear 0-1"); + + curves.Add(AnimationCurve.Linear(1f, 1f, 0f, 0f)); + options.Add("Linear 1-0"); + + curves.Add(AnimationCurve.EaseInOut(0f, 0f, 1f, 1f)); + options.Add("EaseInOut 0-1"); + + curves.Add(AnimationCurve.EaseInOut(1f, 1f, 0f, 0f)); + options.Add("EaseInOut 1-0"); + + return (curves, options); + } + } } diff --git a/DunGenPlus/DunGenPlus/DevTools/Panels/Collections/DungeonFlowCacheAssets.cs b/DunGenPlus/DunGenPlus/DevTools/Panels/Collections/DungeonFlowCacheAssets.cs new file mode 100644 index 0000000..5d5c4cf --- /dev/null +++ b/DunGenPlus/DunGenPlus/DevTools/Panels/Collections/DungeonFlowCacheAssets.cs @@ -0,0 +1,96 @@ +using DunGen; +using DunGenPlus.Collections; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace DunGenPlus.DevTools.Panels.Collections { + internal class DungeonFlowCacheAssets { + public DunGenExtenderProperties originalProperties; + + // Albino said that readonly is safer + public struct Collection { + public ReadOnlyCollection list; + public ReadOnlyDictionary dictionary; + public ReadOnlyCollection options; + + public Collection(List list) { + this.list = new ReadOnlyCollection(list); + + var tempDictionary = new Dictionary(); + for(var i = 0; i < list.Count; i++) { + tempDictionary.Add(list[i], i); + } + dictionary = new ReadOnlyDictionary(tempDictionary); + + options = new ReadOnlyCollection(list.Select(l => l.ToString()).ToList()); + } + } + + public readonly Collection> tileSets; + public readonly Collection> tiles; + public readonly Collection> archetypes; + + public DungeonFlowCacheAssets(DunGenExtender extender){ + originalProperties = extender.Properties.Copy(); + + var tileSetsHashSet = new HashSet>() { new NullObject(null) }; + var tilesHashSet = new HashSet>() { new NullObject(null) }; + var archetypesHashSet = new HashSet>() { new NullObject(null) }; + + foreach(var t in extender.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; + } + } + + } + + foreach(var t in extender.DungeonFlow.Nodes.SelectMany(n => n.TileSets)) { + tileSetsHashSet.Add(t); + foreach(var x in t.TileWeights.Weights) { + tilesHashSet.Add(x.Value); + } + } + foreach(var a in extender.DungeonFlow.Lines.SelectMany(l => l.DungeonArchetypes)) { + archetypesHashSet.Add(a); + foreach(var t in a.TileSets) { + tileSetsHashSet.Add(t); + foreach(var x in t.TileWeights.Weights) { + tilesHashSet.Add(x.Value); + } + } + } + + foreach(var n in extender.Properties.NormalNodeArchetypes) { + foreach(var a in n.archetypes){ + archetypesHashSet.Add(a); + + foreach(var t in a.TileSets){ + tileSetsHashSet.Add(t); + foreach(var x in t.TileWeights.Weights){ + tilesHashSet.Add(x.Value); + } + } + } + } + + foreach(var t in extender.Properties.ForcedTileSets.SelectMany(l => l.Tilesets)){ + tileSetsHashSet.Add(t); + foreach(var x in t.TileWeights.Weights){ + tilesHashSet.Add(x.Value); + } + } + + tileSets = new Collection>(tileSetsHashSet.ToList()); + tiles = new Collection>(tilesHashSet.ToList()); + archetypes = new Collection>(archetypesHashSet.ToList()); + } + } +} diff --git a/DunGenPlus/DunGenPlus/DevTools/Panels/DunGenPlusPanel.cs b/DunGenPlus/DunGenPlus/DevTools/Panels/DunGenPlusPanel.cs index e8c9da6..ada8c27 100644 --- a/DunGenPlus/DunGenPlus/DevTools/Panels/DunGenPlusPanel.cs +++ b/DunGenPlus/DunGenPlus/DevTools/Panels/DunGenPlusPanel.cs @@ -12,7 +12,7 @@ using UnityEngine; using UnityEngine.UI; using DunGenPlus.DevTools.UIElements; using DunGenPlus.DevTools.UIElements.Collections; -using System.Collections.ObjectModel; +using DunGenPlus.DevTools.Panels.Collections; namespace DunGenPlus.DevTools.Panels { internal class DunGenPlusPanel : BasePanel { @@ -26,87 +26,17 @@ namespace DunGenPlus.DevTools.Panels { [Header("Panel References")] public GameObject createGameObject; public GameObject selectedGameObject; + public GameObject selectedListGameObject; [Header("Dungeon Bounds Helper")] public GameObject dungeonBoundsHelperGameObject; - [Header("Selected Panel References")] - public Toggle activateDunGenPlusToggle; - private GameObject mainPathParentGameobject; private GameObject dungeonBoundsParentGameobject; private GameObject archetypesNodesParentGameobject; - - public class DungeonFlowCacheAssets { - public DunGenExtenderProperties originalProperties; - - // Albino said that readonly is safer - public struct Collection { - public ReadOnlyCollection list; - public ReadOnlyDictionary dictionary; - public ReadOnlyCollection options; - - public Collection(List list) { - this.list = new ReadOnlyCollection(list); - - var tempDictionary = new Dictionary(); - for(var i = 0; i < list.Count; i++) { - tempDictionary.Add(list[i], i); - } - dictionary = new ReadOnlyDictionary(tempDictionary); - - options = new ReadOnlyCollection(list.Select(l => l.ToString()).ToList()); - } - } - - public readonly Collection> tileSets; - public readonly Collection> tiles; - public readonly Collection> archetypes; - - public DungeonFlowCacheAssets(DunGenExtender extender){ - originalProperties = extender.Properties.Copy(); - - var tileSetsHashSet = new HashSet>() { new NullObject(null) }; - var tilesHashSet = new HashSet>() { new NullObject(null) }; - var archetypesHashSet = new HashSet>() { new NullObject(null) }; - - foreach(var t in extender.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; - } - } - - } - - foreach(var t in extender.DungeonFlow.Nodes.SelectMany(n => n.TileSets)) { - tileSetsHashSet.Add(t); - foreach(var x in t.TileWeights.Weights) { - tilesHashSet.Add(x.Value); - } - } - foreach(var a in extender.DungeonFlow.Lines.SelectMany(l => l.DungeonArchetypes)) { - archetypesHashSet.Add(a); - foreach(var t in a.TileSets) { - tileSetsHashSet.Add(t); - foreach(var x in t.TileWeights.Weights) { - tilesHashSet.Add(x.Value); - } - } - } - - foreach(var n in extender.Properties.NormalNodeArchetypes) { - foreach(var a in n.archetypes){ - archetypesHashSet.Add(a); - } - } - - tileSets = new Collection>(tileSetsHashSet.ToList()); - tiles = new Collection>(tilesHashSet.ToList()); - archetypes = new Collection>(archetypesHashSet.ToList()); - } - } + private GameObject forcedTilesParentGameobject; + private GameObject branchLoopBoostParentGameobject; + private GameObject maxShadowsParentGameobject; public Dictionary cacheDictionary = new Dictionary(); @@ -160,7 +90,7 @@ namespace DunGenPlus.DevTools.Panels { selectedExtenderer = extender; selectedAssetCache = cache; - var parentTransform = selectedGameObject.transform; + var parentTransform = selectedListGameObject.transform; var properties = selectedExtenderer.Properties; manager.CreateBoolInputField(parentTransform, "Activate DunGenPlus", selectedExtenderer.Active, SetActivateDunGenPlus); manager.CreateSpaceUIField(parentTransform); @@ -193,12 +123,43 @@ namespace DunGenPlus.DevTools.Panels { manager.CreateListUIField(archetypesTransform, "Normal Node Archetypes", properties.NormalNodeArchetypes); manager.CreateSpaceUIField(parentTransform); + var forcedTilesTransform = manager.CreateVerticalLayoutUIField(parentTransform); + forcedTilesParentGameobject = forcedTilesTransform.gameObject; + manager.CreateHeaderUIField(parentTransform, "Forced Tiles"); + manager.CreateBoolInputField(parentTransform, "Use Forced Tiles", properties.UseForcedTiles, SetUseForcedTiles); + forcedTilesTransform.SetAsLastSibling(); + manager.CreateListUIField(forcedTilesTransform, "Forced Tile Sets", properties.ForcedTileSets); + manager.CreateSpaceUIField(parentTransform); + + var branchLoopTransform = manager.CreateVerticalLayoutUIField(parentTransform); + branchLoopBoostParentGameobject = branchLoopTransform.gameObject; + manager.CreateHeaderUIField(parentTransform, "Branch Loop Boost"); + manager.CreateBoolInputField(parentTransform, "Use Branch Loop Boost", properties.UseBranchLoopBoost, SetUseBranchLoopBoost); + branchLoopTransform.SetAsLastSibling(); + manager.CreateIntInputField(branchLoopTransform, "Tile Search Count", new IntParameter(properties.BranchLoopBoostTileSearch, 1, 100, 1), SetTileBoostSearch); + manager.CreateFloatInputField(branchLoopTransform, "Tile Boost Search", new FloatParameter(properties.BranchLoopBoostTileScale, 0f, 2f, 0f), SetTileBoostScale); + manager.CreateSpaceUIField(parentTransform); + + var maxShadowsTransform = manager.CreateVerticalLayoutUIField(parentTransform); + maxShadowsParentGameobject = maxShadowsTransform.gameObject; + manager.CreateHeaderUIField(parentTransform, "Max Shadows Request"); + manager.CreateBoolInputField(parentTransform, "Use Max Shadows Request", properties.UseMaxShadowsRequestUpdate, SetUseMaxShadows); + maxShadowsTransform.SetAsLastSibling(); + manager.CreateIntInputField(maxShadowsTransform, "Shadows Request Amount", new IntParameter(properties.MaxShadowsRequestAmount, 4, 20, 4), SetMaxShadowsAmount); + manager.CreateSpaceUIField(parentTransform); + + // miss + manager.CreateHeaderUIField(parentTransform, "Miscellaneous"); + manager.CreateBoolInputField(parentTransform, "Use Doorway Sisters", properties.UseDoorwaySisters, SetUseDoorwaySisters); + manager.CreateBoolInputField(parentTransform, "Use Random Guaranteed Scrap", properties.UseRandomGuaranteedScrapSpawn, SetUseRandomGuaranteedScrap); + manager.CreateSpaceUIField(parentTransform); + dungeonBoundsHelperGameObject.SetActive(selectedExtenderer.Properties.UseDungeonBounds); UpdateDungeonBoundsHelper(); } public void ClearPanel(){ - manager.ClearTransformChildren(selectedGameObject.transform); + manager.ClearTransformChildren(selectedListGameObject.transform); } public void SetActivateDunGenPlus(bool state){ @@ -258,5 +219,44 @@ namespace DunGenPlus.DevTools.Panels { archetypesNodesParentGameobject.SetActive(state); } + public void SetUseForcedTiles(bool state){ + selectedExtenderer.Properties.UseForcedTiles = state; + forcedTilesParentGameobject.SetActive(state); + } + + public void SetUseBranchLoopBoost(bool state){ + selectedExtenderer.Properties.UseBranchLoopBoost = state; + branchLoopBoostParentGameobject.SetActive(state); + } + + public void SetTileBoostSearch(int value){ + selectedExtenderer.Properties.BranchLoopBoostTileSearch = value; + } + + public void SetTileBoostScale(float value){ + selectedExtenderer.Properties.BranchLoopBoostTileScale = value; + } + + public void SetUseMaxShadows(bool state){ + selectedExtenderer.Properties.UseMaxShadowsRequestUpdate = state; + maxShadowsParentGameobject.SetActive(state); + } + + public void SetMaxShadowsAmount(int value){ + selectedExtenderer.Properties.MaxShadowsRequestAmount = value; + } + + public void SetUseDoorwaySisters(bool state){ + selectedExtenderer.Properties.UseDoorwaySisters = state; + } + + public void SetUseRandomGuaranteedScrap(bool state){ + selectedExtenderer.Properties.UseRandomGuaranteedScrapSpawn = state; + } + + public void RestoreOriginalState(){ + selectedExtenderer.Properties.CopyFrom(selectedAssetCache.originalProperties); + } + } } diff --git a/DunGenPlus/DunGenPlus/DevTools/UIElements/IntSliderField.cs b/DunGenPlus/DunGenPlus/DevTools/UIElements/IntSliderField.cs index 7692cc1..884ff5a 100644 --- a/DunGenPlus/DunGenPlus/DevTools/UIElements/IntSliderField.cs +++ b/DunGenPlus/DunGenPlus/DevTools/UIElements/IntSliderField.cs @@ -26,6 +26,7 @@ namespace DunGenPlus.DevTools.UIElements { private void SetValue(Action setAction, float value) { Plugin.logger.LogInfo($"Setting {title} to {value}"); setAction.Invoke((int)value); + textMesh.text = value.ToString(); } public override void Set(int value){ diff --git a/DunGenPlus/DunGenPlus/DevTools/UIElements/ListUIElement.cs b/DunGenPlus/DunGenPlus/DevTools/UIElements/ListUIElement.cs index 6f13cc4..d28e6f0 100644 --- a/DunGenPlus/DunGenPlus/DevTools/UIElements/ListUIElement.cs +++ b/DunGenPlus/DunGenPlus/DevTools/UIElements/ListUIElement.cs @@ -37,10 +37,14 @@ namespace DunGenPlus.DevTools.UIElements { public void AddElement() { object item = null; - if (listType == typeof(DungeonArchetype)) { + if (listType == typeof(DungeonArchetype) || listType == typeof(TileSet)) { item = null; } else if (listType == typeof(NodeArchetype)) { item = new NodeArchetype(); + } else if (listType == typeof(ForcedTileSetList)){ + var forcedTileset = new ForcedTileSetList(); + forcedTileset.DepthWeightScale = null; + item = forcedTileset; } list.Add(item); @@ -63,12 +67,28 @@ namespace DunGenPlus.DevTools.UIElements { DevDebugManager.Instance.CreateArchetypeOptionsUIField(copyParentTransform, new TitleParameter("Archetype", layoutOffset + 24f), baseValue, (t) => list[index] = t); } + else if (listType == typeof(TileSet)){ + var entry = (TileSet)list[index]; + var baseValue = DunGenPlusPanel.Instance.selectedAssetCache.tileSets.dictionary[entry]; + DevDebugManager.Instance.CreateTileSetsOptionsUIField(copyParentTransform, new TitleParameter("Tile Set", layoutOffset + 24f), baseValue, (t) => list[index] = t); + } + else if (listType == typeof(NodeArchetype)) { var entry = (NodeArchetype)list[index]; DevDebugManager.Instance.CreateStringInputField(copyParentTransform, new TitleParameter("Label", layoutOffset + 24f), entry.label, (t) => entry.label = t); DevDebugManager.Instance.CreateListUIField(copyParentTransform, new TitleParameter("Archetypes", layoutOffset + 24f), entry.archetypes); } + else if (listType == typeof(ForcedTileSetList)) { + var entry = (ForcedTileSetList)list[index]; + DevDebugManager.Instance.CreateFloatInputField(copyParentTransform, new TitleParameter("Main Path Weight", layoutOffset + 24f), entry.MainPathWeight, (t) => entry.MainPathWeight = t); + DevDebugManager.Instance.CreateFloatInputField(copyParentTransform, new TitleParameter("Branch Path Weight", layoutOffset + 24f), entry.BranchPathWeight, (t) => entry.BranchPathWeight = t); + + // depth is weird cause we have to account for every entry's unique depth curve, even if they don't have one + DevDebugManager.Instance.CreateAnimationCurveOptionsUIField(copyParentTransform, new TitleParameter("Depth Weight Scale", layoutOffset + 24f), entry.DepthWeightScale, (t) => entry.DepthWeightScale = t); + DevDebugManager.Instance.CreateListUIField(copyParentTransform, new TitleParameter("Tile Sets", layoutOffset + 24f), entry.Tilesets); + } + copy.SetActive(true); } @@ -78,5 +98,7 @@ namespace DunGenPlus.DevTools.UIElements { return copy; } + + } } diff --git a/DunGenPlus/DunGenPlus/DunGenPlus.csproj b/DunGenPlus/DunGenPlus/DunGenPlus.csproj index fd9a5f8..93d47c9 100644 --- a/DunGenPlus/DunGenPlus/DunGenPlus.csproj +++ b/DunGenPlus/DunGenPlus/DunGenPlus.csproj @@ -149,6 +149,7 @@ + diff --git a/DunGenPlus/DunGenPlus/Generation/DunGenPlusGenerator.cs b/DunGenPlus/DunGenPlus/Generation/DunGenPlusGenerator.cs index 0844580..81b8710 100644 --- a/DunGenPlus/DunGenPlus/Generation/DunGenPlusGenerator.cs +++ b/DunGenPlus/DunGenPlus/Generation/DunGenPlusGenerator.cs @@ -16,6 +16,7 @@ using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using BepInEx.Logging; using static UnityEngine.Rendering.HighDefinition.ScalableSettingLevelParameter; +using DunGenPlus.DevTools; [assembly: SecurityPermission( SecurityAction.RequestMinimum, SkipVerification = true )] namespace DunGenPlus.Generation { @@ -34,7 +35,8 @@ namespace DunGenPlus.Generation { ActiveAlternative = true; var props = extender.Properties.Copy(); - Instance.Events.OnModifyDunGenExtenderProperties.Invoke(props); + var callback = new EventCallbackScenario(DevDebugManager.Instance); + Instance.Events.OnModifyDunGenExtenderProperties.Invoke(props, callback); props.SetupProperties(generator); Properties = props; diff --git a/DunGenPlus/DunGenPlus/dungen b/DunGenPlus/DunGenPlus/dungen index 090273d..cadddbb 100644 Binary files a/DunGenPlus/DunGenPlus/dungen and b/DunGenPlus/DunGenPlus/dungen differ