Fixes to DevDebug for AdditionalTiles and MainPathExtender

Changed entry to DevDebug mode to LeftAlt + M
This commit is contained in:
LadyAliceMargatroid 2024-10-30 07:31:53 -07:00
parent d955f6e930
commit cd9b233040
11 changed files with 59 additions and 17 deletions

View File

@ -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 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 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 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)] [Tooltip(MainPathCountTooltip)]
@ -184,8 +184,8 @@ namespace DunGenPlus.Collections {
[System.Serializable] [System.Serializable]
public class AdditionalTilesProperties { public class AdditionalTilesProperties {
internal const string UseAdditionalTilesTooltip = "If enabled, attempts to forcefully spawn tiles from ForcedTileSets after branching paths are generated."; 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 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 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)] [Tooltip(UseAdditionalTilesTooltip)]
public bool UseAdditionalTiles = false; public bool UseAdditionalTiles = false;

View File

@ -29,7 +29,7 @@ namespace DunGenPlus.Collections {
[System.Serializable] [System.Serializable]
public class AdditionalTileSetList { 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 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 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."; internal const string BranchPathWeightTooltip = "The weight for the tile spawning on the branch path.";

View File

@ -138,6 +138,11 @@ namespace DunGenPlus.DevTools {
return CreateOptionsUIField(parentTransform, titleParameter, baseValue, setAction, (i) => mainPanel.levels[i], mainPanel.levelOptions); return CreateOptionsUIField(parentTransform, titleParameter, baseValue, setAction, (i) => mainPanel.levels[i], mainPanel.levelOptions);
} }
public DropdownInputField CreateMainPathExtenderUIField(Transform parentTransform, TitleParameter titleParameter, int baseValue, Action<MainPathExtender> 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<GameObject> setAction){ public DropdownInputField CreateTileOptionsUIField(Transform parentTransform, TitleParameter titleParameter, int baseValue, Action<GameObject> setAction){
var assetCache = DevDebugManager.Instance.selectedAssetCache; var assetCache = DevDebugManager.Instance.selectedAssetCache;
return CreateOptionsUIField(parentTransform, titleParameter, baseValue, setAction, (i) => assetCache.tiles.list[i].Item, assetCache.tiles.options); return CreateOptionsUIField(parentTransform, titleParameter, baseValue, setAction, (i) => assetCache.tiles.list[i].Item, assetCache.tiles.options);

View File

@ -20,15 +20,13 @@ namespace DunGenPlus.DevTools {
} }
public void Update(){ 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); Instantiate(Assets.DevDebugPrefab);
} }
} }
bool IfKeyPress(params KeyControl[] keys){ bool IfKeyPress(KeyControl key, KeyControl hold){
foreach(var k in keys){ if (hold.isPressed && key.wasPressedThisFrame) return true;
if (k.wasPressedThisFrame) return true;
}
return false; return false;
} }

View File

@ -35,6 +35,7 @@ namespace DunGenPlus.DevTools.Panels.Collections {
public readonly Collection<NullObject<TileSet>> tileSets; public readonly Collection<NullObject<TileSet>> tileSets;
public readonly Collection<NullObject<GameObject>> tiles; public readonly Collection<NullObject<GameObject>> tiles;
public readonly Collection<NullObject<DungeonArchetype>> archetypes; public readonly Collection<NullObject<DungeonArchetype>> archetypes;
public readonly Collection<NullObject<MainPathExtender>> mainPathExtenders;
public DungeonFlowCacheAssets(DungeonFlow dungeonFlow, DunGenExtender extender){ public DungeonFlowCacheAssets(DungeonFlow dungeonFlow, DunGenExtender extender){
if (extender){ if (extender){
@ -45,6 +46,19 @@ namespace DunGenPlus.DevTools.Panels.Collections {
var tileSetsHashSet = new HashSet<NullObject<TileSet>>() { new NullObject<TileSet>(null) }; var tileSetsHashSet = new HashSet<NullObject<TileSet>>() { new NullObject<TileSet>(null) };
var tilesHashSet = new HashSet<NullObject<GameObject>>() { new NullObject<GameObject>(null) }; var tilesHashSet = new HashSet<NullObject<GameObject>>() { new NullObject<GameObject>(null) };
var archetypesHashSet = new HashSet<NullObject<DungeonArchetype>>() { new NullObject<DungeonArchetype>(null) }; var archetypesHashSet = new HashSet<NullObject<DungeonArchetype>>() { new NullObject<DungeonArchetype>(null) };
var mainPathExtenderHashSet = new HashSet<NullObject<MainPathExtender>>() { new NullObject<MainPathExtender>(null) };
void AddNodes(IEnumerable<GraphNode> nodes){
foreach(var n in nodes){
AddTileSets(n.TileSets);
}
}
void AddLines(IEnumerable<GraphLine> lines){
foreach(var n in lines){
AddArchetypes(n.DungeonArchetypes);
}
}
void AddTiles(IEnumerable<GameObject> tiles){ void AddTiles(IEnumerable<GameObject> tiles){
foreach(var x in tiles) { foreach(var x in tiles) {
@ -61,19 +75,29 @@ namespace DunGenPlus.DevTools.Panels.Collections {
void AddTileSets(IEnumerable<TileSet> tileSets){ void AddTileSets(IEnumerable<TileSet> tileSets){
foreach(var x in tileSets){ foreach(var x in tileSets){
tileSetsHashSet.Add(x); tileSetsHashSet.Add(x);
AddTilesW(x.TileWeights.Weights); if (x != null) AddTilesW(x.TileWeights.Weights);
} }
} }
void AddArchetypes(IEnumerable<DungeonArchetype> archetypes){ void AddArchetypes(IEnumerable<DungeonArchetype> archetypes){
foreach(var x in archetypes){ foreach(var x in archetypes){
archetypesHashSet.Add(x); archetypesHashSet.Add(x);
AddTileSets(x.TileSets); if (x != null) AddTileSets(x.TileSets);
} }
} }
AddTileSets(dungeonFlow.Nodes.SelectMany(n => n.TileSets)); void AddMainPathExtenders(IEnumerable<MainPathExtender> mainPaths){
AddArchetypes(dungeonFlow.Lines.SelectMany(l => l.DungeonArchetypes)); 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)); AddTileSets(dungeonFlow.TileInjectionRules.Select(n => n.TileSet));
if (extender) { if (extender) {
@ -83,11 +107,14 @@ namespace DunGenPlus.DevTools.Panels.Collections {
AddTiles(extender.Properties.AssetCacheTileList); AddTiles(extender.Properties.AssetCacheTileList);
AddTileSets(extender.Properties.AssetCacheTileSetList); AddTileSets(extender.Properties.AssetCacheTileSetList);
AddArchetypes(extender.Properties.AssetCacheArchetypeList); AddArchetypes(extender.Properties.AssetCacheArchetypeList);
AddMainPathExtenders(extender.Properties.MainPathProperties.MainPathDetails);
} }
tileSets = new Collection<NullObject<TileSet>>(tileSetsHashSet.ToList()); tileSets = new Collection<NullObject<TileSet>>(tileSetsHashSet.ToList());
tiles = new Collection<NullObject<GameObject>>(tilesHashSet.ToList()); tiles = new Collection<NullObject<GameObject>>(tilesHashSet.ToList());
archetypes = new Collection<NullObject<DungeonArchetype>>(archetypesHashSet.ToList()); archetypes = new Collection<NullObject<DungeonArchetype>>(archetypesHashSet.ToList());
mainPathExtenders = new Collection<NullObject<MainPathExtender>>(mainPathExtenderHashSet.ToList());
} }
} }
} }

View File

@ -90,6 +90,7 @@ namespace DunGenPlus.DevTools.Panels {
mainPathTransform.SetAsLastSibling(); mainPathTransform.SetAsLastSibling();
manager.CreateTileOptionsUIField(mainPathTransform, ("Main Room Tile Prefab", MainPathProperties.MainRoomTilePrefabTooltip), selectedAssetCache.tiles.dictionary[properties.MainPathProperties.MainRoomTilePrefab], SetMainRoom); manager.CreateTileOptionsUIField(mainPathTransform, ("Main Room Tile Prefab", MainPathProperties.MainRoomTilePrefabTooltip), selectedAssetCache.tiles.dictionary[properties.MainPathProperties.MainRoomTilePrefab], SetMainRoom);
manager.CreateEnumOptionsUIField<DunGenExtenderProperties.CopyNodeBehaviour>(mainPathTransform, ("Copy Node Behaviour", MainPathProperties.CopyNodeBehaviourTooltip), (int)properties.MainPathProperties.CopyNodeBehaviour, SetCopyNodeBehaviour); manager.CreateEnumOptionsUIField<DunGenExtenderProperties.CopyNodeBehaviour>(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); manager.CreateSpaceUIField(parentTransform);
var dungeonBoundsTransform = manager.CreateVerticalLayoutUIField(parentTransform); var dungeonBoundsTransform = manager.CreateVerticalLayoutUIField(parentTransform);

View File

@ -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 { internal class ListEntryNodeArchetype : ListEntryType {
public override object CreateEmptyObject() => new NodeArchetype(); public override object CreateEmptyObject() => new NodeArchetype();

View File

@ -30,7 +30,8 @@ namespace DunGenPlus.DevTools.UIElements {
{ typeof(AdditionalTileSetList), new ListEntryAdditionalTileSetList() }, { typeof(AdditionalTileSetList), new ListEntryAdditionalTileSetList() },
{ typeof(TileInjectionRule), new ListEntryTileInjectionRule() }, { typeof(TileInjectionRule), new ListEntryTileInjectionRule() },
{ typeof(GraphNode), new ListEntryGraphNode() }, { typeof(GraphNode), new ListEntryGraphNode() },
{ typeof(GraphLine), new ListEntryGraphLine() } { typeof(GraphLine), new ListEntryGraphLine() },
{ typeof(MainPathExtender), new ListEntryMainPathExtender() }
}; };
public void SetupList<T>(TitleParameter titleParameter, List<T> list) { public void SetupList<T>(TitleParameter titleParameter, List<T> list) {

View File

@ -70,15 +70,15 @@ namespace DunGenPlusEditor {
} }
[CustomPropertyDrawer(typeof(ForcedTilesProperties))] [CustomPropertyDrawer(typeof(AdditionalTilesProperties))]
public class ForcedTilesPropertiesPropertyDrawer : PropertyDrawer { public class ForcedTilesPropertiesPropertyDrawer : PropertyDrawer {
public override VisualElement CreatePropertyGUI(SerializedProperty property) { public override VisualElement CreatePropertyGUI(SerializedProperty property) {
var container = new VisualElement(); var container = new VisualElement();
var box = PropertyDrawerUtility.CreateDropdown(property, "Forced Tiles"); var box = PropertyDrawerUtility.CreateDropdown(property, "Additional Tiles");
PropertyDrawerUtility.SetupItemsBoolProperty(box.container, property, "UseForcedTiles", "Disabled"); PropertyDrawerUtility.SetupItemsBoolProperty(box.container, property, "UseAdditionalTiles", "Disabled");
container.Add(box.parent); container.Add(box.parent);
return container; return container;