diff --git a/DunGenPlus/DunGenPlus/Collections/DunGenExtenderPropertiesCollection.cs b/DunGenPlus/DunGenPlus/Collections/DunGenExtenderPropertiesCollection.cs index 8e972fe..7cc1ffc 100644 --- a/DunGenPlus/DunGenPlus/Collections/DunGenExtenderPropertiesCollection.cs +++ b/DunGenPlus/DunGenPlus/Collections/DunGenExtenderPropertiesCollection.cs @@ -15,7 +15,7 @@ namespace DunGenPlus.Collections { internal const string MainPathCountTooltip = "The number of main paths.\n\n1 means no additional main paths\n3 means two additional main paths\netc."; 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 = "Tooltip"; + 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."; [Tooltip(MainPathCountTooltip)] @@ -184,8 +184,8 @@ namespace DunGenPlus.Collections { [System.Serializable] public class AdditionalTilesProperties { - internal const string UseAdditionalTilesTooltip = "If enabled, attempts to forcefully spawn tiles from ForcedTileSets after branching paths are generated."; - internal const string AdditionalTileSetsTooltip = "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 UseAdditionalTilesTooltip = "If enabled, attempts to generate additional tiles from AdditionalTileSets after main and branching paths are generated."; + internal const string AdditionalTileSetsTooltip = "The list of tiles that will be attempted to generate. Each entry will spawn only one tile from it's list.\n\nEven if the tile cannot be generated, the dungeon generation will not restart."; [Tooltip(UseAdditionalTilesTooltip)] public bool UseAdditionalTiles = false; diff --git a/DunGenPlus/DunGenPlus/Collections/ForcedTileSetList.cs b/DunGenPlus/DunGenPlus/Collections/ForcedTileSetList.cs index e9fec50..69644a7 100644 --- a/DunGenPlus/DunGenPlus/Collections/ForcedTileSetList.cs +++ b/DunGenPlus/DunGenPlus/Collections/ForcedTileSetList.cs @@ -29,7 +29,7 @@ namespace DunGenPlus.Collections { [System.Serializable] public class AdditionalTileSetList { - internal const string TileSetsTooltip = "List of tiles to be forcefully spawned."; + internal const string TileSetsTooltip = "List of tiles to be generated."; internal const string DepthWeightScaleTooltip = "The weight based on the path's depth."; internal const string MainPathWeightTooltip = "The weight for the tile spawning on the main path."; internal const string BranchPathWeightTooltip = "The weight for the tile spawning on the branch path."; diff --git a/DunGenPlus/DunGenPlus/DevTools/DevDebugManagerUI.cs b/DunGenPlus/DunGenPlus/DevTools/DevDebugManagerUI.cs index 09acdb3..5dbd226 100644 --- a/DunGenPlus/DunGenPlus/DevTools/DevDebugManagerUI.cs +++ b/DunGenPlus/DunGenPlus/DevTools/DevDebugManagerUI.cs @@ -138,6 +138,11 @@ namespace DunGenPlus.DevTools { return CreateOptionsUIField(parentTransform, titleParameter, baseValue, setAction, (i) => mainPanel.levels[i], mainPanel.levelOptions); } + public DropdownInputField CreateMainPathExtenderUIField(Transform parentTransform, TitleParameter titleParameter, int baseValue, Action setAction){ + var assetCache = DevDebugManager.Instance.selectedAssetCache; + return CreateOptionsUIField(parentTransform, titleParameter, baseValue, setAction, (i) => assetCache.mainPathExtenders.list[i].Item, assetCache.mainPathExtenders.options); + } + public DropdownInputField CreateTileOptionsUIField(Transform parentTransform, TitleParameter titleParameter, int baseValue, Action setAction){ var assetCache = DevDebugManager.Instance.selectedAssetCache; return CreateOptionsUIField(parentTransform, titleParameter, baseValue, setAction, (i) => assetCache.tiles.list[i].Item, assetCache.tiles.options); diff --git a/DunGenPlus/DunGenPlus/DevTools/DevDebugOpen.cs b/DunGenPlus/DunGenPlus/DevTools/DevDebugOpen.cs index aff4e08..e4f9505 100644 --- a/DunGenPlus/DunGenPlus/DevTools/DevDebugOpen.cs +++ b/DunGenPlus/DunGenPlus/DevTools/DevDebugOpen.cs @@ -20,15 +20,13 @@ namespace DunGenPlus.DevTools { } public void Update(){ - if (IfKeyPress(Keyboard.current.mKey) && DevDebugManager.Instance == null && IsSinglePlayerInShip()){ + if (IfKeyPress(Keyboard.current.mKey, Keyboard.current.leftAltKey) && DevDebugManager.Instance == null && IsSinglePlayerInShip()){ Instantiate(Assets.DevDebugPrefab); } } - bool IfKeyPress(params KeyControl[] keys){ - foreach(var k in keys){ - if (k.wasPressedThisFrame) return true; - } + bool IfKeyPress(KeyControl key, KeyControl hold){ + if (hold.isPressed && key.wasPressedThisFrame) return true; return false; } diff --git a/DunGenPlus/DunGenPlus/DevTools/Panels/Collections/DungeonFlowCacheAssets.cs b/DunGenPlus/DunGenPlus/DevTools/Panels/Collections/DungeonFlowCacheAssets.cs index b626685..d8f11da 100644 --- a/DunGenPlus/DunGenPlus/DevTools/Panels/Collections/DungeonFlowCacheAssets.cs +++ b/DunGenPlus/DunGenPlus/DevTools/Panels/Collections/DungeonFlowCacheAssets.cs @@ -35,6 +35,7 @@ namespace DunGenPlus.DevTools.Panels.Collections { public readonly Collection> tileSets; public readonly Collection> tiles; public readonly Collection> archetypes; + public readonly Collection> mainPathExtenders; public DungeonFlowCacheAssets(DungeonFlow dungeonFlow, DunGenExtender extender){ if (extender){ @@ -45,6 +46,19 @@ namespace DunGenPlus.DevTools.Panels.Collections { var tileSetsHashSet = new HashSet>() { new NullObject(null) }; var tilesHashSet = new HashSet>() { new NullObject(null) }; var archetypesHashSet = new HashSet>() { new NullObject(null) }; + var mainPathExtenderHashSet = new HashSet>() { new NullObject(null) }; + + void AddNodes(IEnumerable nodes){ + foreach(var n in nodes){ + AddTileSets(n.TileSets); + } + } + + void AddLines(IEnumerable lines){ + foreach(var n in lines){ + AddArchetypes(n.DungeonArchetypes); + } + } void AddTiles(IEnumerable tiles){ foreach(var x in tiles) { @@ -61,19 +75,29 @@ namespace DunGenPlus.DevTools.Panels.Collections { void AddTileSets(IEnumerable tileSets){ foreach(var x in tileSets){ tileSetsHashSet.Add(x); - AddTilesW(x.TileWeights.Weights); + if (x != null) AddTilesW(x.TileWeights.Weights); } } void AddArchetypes(IEnumerable archetypes){ foreach(var x in archetypes){ archetypesHashSet.Add(x); - AddTileSets(x.TileSets); + if (x != null) AddTileSets(x.TileSets); } } - AddTileSets(dungeonFlow.Nodes.SelectMany(n => n.TileSets)); - AddArchetypes(dungeonFlow.Lines.SelectMany(l => l.DungeonArchetypes)); + void AddMainPathExtenders(IEnumerable mainPaths){ + foreach(var x in mainPaths) { + mainPathExtenderHashSet.Add(x); + if (x != null) { + AddNodes(x.Nodes.Value); + AddLines(x.Lines.Value); + } + } + } + + AddNodes(dungeonFlow.Nodes); + AddLines(dungeonFlow.Lines); AddTileSets(dungeonFlow.TileInjectionRules.Select(n => n.TileSet)); if (extender) { @@ -83,11 +107,14 @@ namespace DunGenPlus.DevTools.Panels.Collections { AddTiles(extender.Properties.AssetCacheTileList); AddTileSets(extender.Properties.AssetCacheTileSetList); AddArchetypes(extender.Properties.AssetCacheArchetypeList); + + AddMainPathExtenders(extender.Properties.MainPathProperties.MainPathDetails); } tileSets = new Collection>(tileSetsHashSet.ToList()); tiles = new Collection>(tilesHashSet.ToList()); archetypes = new Collection>(archetypesHashSet.ToList()); + mainPathExtenders = new Collection>(mainPathExtenderHashSet.ToList()); } } } diff --git a/DunGenPlus/DunGenPlus/DevTools/Panels/DunGenPlusPanel.cs b/DunGenPlus/DunGenPlus/DevTools/Panels/DunGenPlusPanel.cs index 381fa0d..3e0d9c5 100644 --- a/DunGenPlus/DunGenPlus/DevTools/Panels/DunGenPlusPanel.cs +++ b/DunGenPlus/DunGenPlus/DevTools/Panels/DunGenPlusPanel.cs @@ -90,6 +90,7 @@ namespace DunGenPlus.DevTools.Panels { mainPathTransform.SetAsLastSibling(); manager.CreateTileOptionsUIField(mainPathTransform, ("Main Room Tile Prefab", MainPathProperties.MainRoomTilePrefabTooltip), selectedAssetCache.tiles.dictionary[properties.MainPathProperties.MainRoomTilePrefab], SetMainRoom); manager.CreateEnumOptionsUIField(mainPathTransform, ("Copy Node Behaviour", MainPathProperties.CopyNodeBehaviourTooltip), (int)properties.MainPathProperties.CopyNodeBehaviour, SetCopyNodeBehaviour); + manager.CreateListUIField(mainPathTransform, ("Main Path Details", MainPathProperties.MainPathDetailsTooltip), properties.MainPathProperties.MainPathDetails); manager.CreateSpaceUIField(parentTransform); var dungeonBoundsTransform = manager.CreateVerticalLayoutUIField(parentTransform); diff --git a/DunGenPlus/DunGenPlus/DevTools/UIElements/Collections/ListEntryType.cs b/DunGenPlus/DunGenPlus/DevTools/UIElements/Collections/ListEntryType.cs index 280a2fc..7d7bafc 100644 --- a/DunGenPlus/DunGenPlus/DevTools/UIElements/Collections/ListEntryType.cs +++ b/DunGenPlus/DunGenPlus/DevTools/UIElements/Collections/ListEntryType.cs @@ -36,6 +36,16 @@ namespace DunGenPlus.DevTools.UIElements.Collections { } } + internal class ListEntryMainPathExtender : ListEntryType { + public override object CreateEmptyObject() => null; + + public override void CreateEntry(IList list, int index, Transform parentTransform, float layoutOffset) { + var entry = (MainPathExtender)list[index]; + var baseValue = DevDebugManager.Instance.selectedAssetCache.mainPathExtenders.dictionary[entry]; + DevDebugManager.Instance.CreateMainPathExtenderUIField(parentTransform, new TitleParameter("Main Path Extender", layoutOffset), baseValue, (t) => list[index] = t); + } + } + internal class ListEntryNodeArchetype : ListEntryType { public override object CreateEmptyObject() => new NodeArchetype(); diff --git a/DunGenPlus/DunGenPlus/DevTools/UIElements/ListUIElement.cs b/DunGenPlus/DunGenPlus/DevTools/UIElements/ListUIElement.cs index 0d56e23..17a49d7 100644 --- a/DunGenPlus/DunGenPlus/DevTools/UIElements/ListUIElement.cs +++ b/DunGenPlus/DunGenPlus/DevTools/UIElements/ListUIElement.cs @@ -30,7 +30,8 @@ namespace DunGenPlus.DevTools.UIElements { { typeof(AdditionalTileSetList), new ListEntryAdditionalTileSetList() }, { typeof(TileInjectionRule), new ListEntryTileInjectionRule() }, { typeof(GraphNode), new ListEntryGraphNode() }, - { typeof(GraphLine), new ListEntryGraphLine() } + { typeof(GraphLine), new ListEntryGraphLine() }, + { typeof(MainPathExtender), new ListEntryMainPathExtender() } }; public void SetupList(TitleParameter titleParameter, List list) { diff --git a/DunGenPlus/DunGenPlus/DunGenPlus/DunGenPlus.dll b/DunGenPlus/DunGenPlus/DunGenPlus/DunGenPlus.dll index 8ad051f..26a5776 100644 Binary files a/DunGenPlus/DunGenPlus/DunGenPlus/DunGenPlus.dll and b/DunGenPlus/DunGenPlus/DunGenPlus/DunGenPlus.dll differ diff --git a/DunGenPlus/DunGenPlus/DunGenPlus/DunGenPlusEditor.dll b/DunGenPlus/DunGenPlus/DunGenPlus/DunGenPlusEditor.dll index 082303d..6bf3722 100644 Binary files a/DunGenPlus/DunGenPlus/DunGenPlus/DunGenPlusEditor.dll and b/DunGenPlus/DunGenPlus/DunGenPlus/DunGenPlusEditor.dll differ diff --git a/DunGenPlus/DunGenPlusEditor/DunGenExtenderPropertyDrawer.cs b/DunGenPlus/DunGenPlusEditor/DunGenExtenderPropertyDrawer.cs index e01e57f..036bb05 100644 --- a/DunGenPlus/DunGenPlusEditor/DunGenExtenderPropertyDrawer.cs +++ b/DunGenPlus/DunGenPlusEditor/DunGenExtenderPropertyDrawer.cs @@ -70,15 +70,15 @@ namespace DunGenPlusEditor { } - [CustomPropertyDrawer(typeof(ForcedTilesProperties))] + [CustomPropertyDrawer(typeof(AdditionalTilesProperties))] public class ForcedTilesPropertiesPropertyDrawer : PropertyDrawer { public override VisualElement CreatePropertyGUI(SerializedProperty property) { var container = new VisualElement(); - var box = PropertyDrawerUtility.CreateDropdown(property, "Forced Tiles"); - PropertyDrawerUtility.SetupItemsBoolProperty(box.container, property, "UseForcedTiles", "Disabled"); + var box = PropertyDrawerUtility.CreateDropdown(property, "Additional Tiles"); + PropertyDrawerUtility.SetupItemsBoolProperty(box.container, property, "UseAdditionalTiles", "Disabled"); container.Add(box.parent); return container;