From 6f582fcca115fbeebb5c05ed736b27e8c2873596 Mon Sep 17 00:00:00 2001 From: Zenny Date: Tue, 30 Sep 2025 02:32:03 -0700 Subject: [PATCH] Add map loading logic and spawn rate control --- .../Map/Floors.cs | 16 ---- .../Player/PlayerData.cs | 2 - .../Zennysoft.Ma.Adapter.csproj | 4 + .../DungeonFloorLayout.cs | 68 +++++++++++++++++ .../DungeonFloorLayout.cs.uid | 1 + .../DungeonFloorLayoutNode.cs | 22 ++++++ .../DungeonFloorLayoutNode.cs.uid | 1 + .../addons/dungeon_floor_layout/icon_door.png | Bin 0 -> 161 bytes .../dungeon_floor_layout/icon_door.png.import | 34 +++++++++ .../addons/dungeon_floor_layout/plugin.cfg | 7 ++ .../SpecialFloorLayout.cs | 25 +++++++ .../SpecialFloorLayout.cs.uid | 1 + .../SpecialFloorLayoutNode.cs | 23 ++++++ .../SpecialFloorLayoutNode.cs.uid | 1 + .../special_floor_layout_node/icon_door.png | Bin 0 -> 161 bytes .../icon_door.png.import | 34 +++++++++ .../special_floor_layout_node/plugin.cfg | 7 ++ Zennysoft.Game.Ma/project.godot | 2 +- Zennysoft.Game.Ma/src/enemy/EnemyDatabase.cs | 12 --- Zennysoft.Game.Ma/src/enemy/EnemyType.cs | 21 ++++++ Zennysoft.Game.Ma/src/enemy/EnemyType.cs.uid | 1 + .../src/enemy/EnemyTypeToEnemyConverter.cs | 56 ++++++++++++++ .../enemy/EnemyTypeToEnemyConverter.cs.uid | 1 + Zennysoft.Game.Ma/src/game/Game.cs | 3 +- Zennysoft.Game.Ma/src/game/IGame.cs | 2 +- Zennysoft.Game.Ma/src/map/IMap.cs | 2 - .../src/map/LayoutToScenePathConverter.cs | 49 ++++++++++++ .../src/map/LayoutToScenePathConverter.cs.uid | 1 + Zennysoft.Game.Ma/src/map/LayoutType.cs | 7 ++ Zennysoft.Game.Ma/src/map/LayoutType.cs.uid | 1 + Zennysoft.Game.Ma/src/map/Map.cs | 24 ++---- Zennysoft.Game.Ma/src/map/Map.tscn | 33 ++++++++- .../src/map/dungeon/code/DungeonFloor.cs | 14 ++-- .../src/map/dungeon/code/DungeonRoom.cs | 6 +- .../src/map/dungeon/code/ExitRoom.cs | 10 ++- .../src/map/dungeon/code/IDungeonRoom.cs | 2 - .../src/map/dungeon/code/MonsterRoom.cs | 70 ++++++++++-------- .../map/dungeon/floors/Floor00/Floor00.tres | 8 -- .../floors/SetAFloors/put_set_a_maps_here.txt | 0 .../floors/SetBFloors/put_set_b_maps_here.txt | 0 .../rooms/Set A/03. Antechamber A.tscn | 8 +- Zennysoft.Game.Ma/src/menu/DebugMenu.tscn | 5 ++ .../src/ui/pause_menu/PauseDebugMenu.cs | 4 + 43 files changed, 470 insertions(+), 118 deletions(-) delete mode 100644 Zennysoft.Game.Ma.Implementation/Map/Floors.cs create mode 100644 Zennysoft.Game.Ma/addons/dungeon_floor_layout/DungeonFloorLayout.cs create mode 100644 Zennysoft.Game.Ma/addons/dungeon_floor_layout/DungeonFloorLayout.cs.uid create mode 100644 Zennysoft.Game.Ma/addons/dungeon_floor_layout/DungeonFloorLayoutNode.cs create mode 100644 Zennysoft.Game.Ma/addons/dungeon_floor_layout/DungeonFloorLayoutNode.cs.uid create mode 100644 Zennysoft.Game.Ma/addons/dungeon_floor_layout/icon_door.png create mode 100644 Zennysoft.Game.Ma/addons/dungeon_floor_layout/icon_door.png.import create mode 100644 Zennysoft.Game.Ma/addons/dungeon_floor_layout/plugin.cfg create mode 100644 Zennysoft.Game.Ma/addons/special_floor_layout_node/SpecialFloorLayout.cs create mode 100644 Zennysoft.Game.Ma/addons/special_floor_layout_node/SpecialFloorLayout.cs.uid create mode 100644 Zennysoft.Game.Ma/addons/special_floor_layout_node/SpecialFloorLayoutNode.cs create mode 100644 Zennysoft.Game.Ma/addons/special_floor_layout_node/SpecialFloorLayoutNode.cs.uid create mode 100644 Zennysoft.Game.Ma/addons/special_floor_layout_node/icon_door.png create mode 100644 Zennysoft.Game.Ma/addons/special_floor_layout_node/icon_door.png.import create mode 100644 Zennysoft.Game.Ma/addons/special_floor_layout_node/plugin.cfg delete mode 100644 Zennysoft.Game.Ma/src/enemy/EnemyDatabase.cs create mode 100644 Zennysoft.Game.Ma/src/enemy/EnemyType.cs create mode 100644 Zennysoft.Game.Ma/src/enemy/EnemyType.cs.uid create mode 100644 Zennysoft.Game.Ma/src/enemy/EnemyTypeToEnemyConverter.cs create mode 100644 Zennysoft.Game.Ma/src/enemy/EnemyTypeToEnemyConverter.cs.uid create mode 100644 Zennysoft.Game.Ma/src/map/LayoutToScenePathConverter.cs create mode 100644 Zennysoft.Game.Ma/src/map/LayoutToScenePathConverter.cs.uid create mode 100644 Zennysoft.Game.Ma/src/map/LayoutType.cs create mode 100644 Zennysoft.Game.Ma/src/map/LayoutType.cs.uid delete mode 100644 Zennysoft.Game.Ma/src/map/dungeon/floors/Floor00/Floor00.tres create mode 100644 Zennysoft.Game.Ma/src/map/dungeon/floors/SetAFloors/put_set_a_maps_here.txt create mode 100644 Zennysoft.Game.Ma/src/map/dungeon/floors/SetBFloors/put_set_b_maps_here.txt diff --git a/Zennysoft.Game.Ma.Implementation/Map/Floors.cs b/Zennysoft.Game.Ma.Implementation/Map/Floors.cs deleted file mode 100644 index 307156c7..00000000 --- a/Zennysoft.Game.Ma.Implementation/Map/Floors.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Zennysoft.Ma.Adapter; -public enum Floor -{ - Overworld, - Altar, - BossFloorA, - BossFloorB, - GoddessOfGuidanceFloor, - VoidRoom, - FinalFloor, - Floor01, - Floor02, - Floor03, - Floor04, - Floor05, -} diff --git a/Zennysoft.Game.Ma.Implementation/Player/PlayerData.cs b/Zennysoft.Game.Ma.Implementation/Player/PlayerData.cs index 2de36400..c61a6ec4 100644 --- a/Zennysoft.Game.Ma.Implementation/Player/PlayerData.cs +++ b/Zennysoft.Game.Ma.Implementation/Player/PlayerData.cs @@ -17,6 +17,4 @@ public partial record PlayerData [Meta, Id("map_data")] public partial record MapData { - [Save("floor_list")] - public required Dictionary FloorScenes { get; init; } } diff --git a/Zennysoft.Game.Ma.Implementation/Zennysoft.Ma.Adapter.csproj b/Zennysoft.Game.Ma.Implementation/Zennysoft.Ma.Adapter.csproj index 01bc259a..310dc2de 100644 --- a/Zennysoft.Game.Ma.Implementation/Zennysoft.Ma.Adapter.csproj +++ b/Zennysoft.Game.Ma.Implementation/Zennysoft.Ma.Adapter.csproj @@ -28,4 +28,8 @@ + + + + diff --git a/Zennysoft.Game.Ma/addons/dungeon_floor_layout/DungeonFloorLayout.cs b/Zennysoft.Game.Ma/addons/dungeon_floor_layout/DungeonFloorLayout.cs new file mode 100644 index 00000000..20fe4f07 --- /dev/null +++ b/Zennysoft.Game.Ma/addons/dungeon_floor_layout/DungeonFloorLayout.cs @@ -0,0 +1,68 @@ +using Godot; +using Godot.Collections; +using System.Linq; +using Zennysoft.Game.Ma; + +[Tool] +public partial class DungeonFloorLayout : LayoutType +{ + [Export] + public DungeonFloorSetType SetType + { + get => _setType; + set + { + _setType = value; + LayoutWithSpawnRate = []; + NotifyPropertyListChanged(); + } + } + + [ExportToolButton("Populate Map Data")] + public Callable PopulateMapList => Callable.From(() => PopulateDictionary(SetType)); + + [Export] + public Dictionary LayoutWithSpawnRate { get; private set; } + + [Export] + public Dictionary EnemySpawnRates { get; set; } = default!; + + private string _floorPath = "res://src/map/dungeon/floors/"; + private DungeonFloorSetType _setType; + + private void PopulateDictionary(DungeonFloorSetType setType) + { + var floorPath = _floorPath; + var floorType = string.Empty; + if (setType == DungeonFloorSetType.SetA) + floorType = "SetAFloors"; + else if (setType == DungeonFloorSetType.SetB) + floorType = "SetBFloors"; + + var pathToScenes = $"{floorPath}/{floorType}"; + + var files = DirAccess.GetFilesAt(pathToScenes).Where(x => x.EndsWith(".tscn")); + + var newMaps = new Dictionary(); + foreach (var file in files) + { + if (LayoutWithSpawnRate.ContainsKey($"{floorType}/{file}")) + { + var spawnRate = LayoutWithSpawnRate.TryGetValue($"{floorType}/{file}", out var currentSpawnRate); + newMaps.Add($"{floorType}/{file}", currentSpawnRate); + } + else + newMaps.Add($"{floorType}/{file}", 1.0f); + } + + LayoutWithSpawnRate = newMaps; + + NotifyPropertyListChanged(); + } + + public enum DungeonFloorSetType + { + SetA, + SetB + } +} diff --git a/Zennysoft.Game.Ma/addons/dungeon_floor_layout/DungeonFloorLayout.cs.uid b/Zennysoft.Game.Ma/addons/dungeon_floor_layout/DungeonFloorLayout.cs.uid new file mode 100644 index 00000000..d70e47ef --- /dev/null +++ b/Zennysoft.Game.Ma/addons/dungeon_floor_layout/DungeonFloorLayout.cs.uid @@ -0,0 +1 @@ +uid://ci7o3nn4mdo8o diff --git a/Zennysoft.Game.Ma/addons/dungeon_floor_layout/DungeonFloorLayoutNode.cs b/Zennysoft.Game.Ma/addons/dungeon_floor_layout/DungeonFloorLayoutNode.cs new file mode 100644 index 00000000..16d4aec6 --- /dev/null +++ b/Zennysoft.Game.Ma/addons/dungeon_floor_layout/DungeonFloorLayoutNode.cs @@ -0,0 +1,22 @@ +#if TOOLS +using Godot; +using Zennysoft.Game.Ma; + +[Tool] +public partial class DungeonFloorLayoutNode : EditorPlugin +{ + public override void _EnterTree() + { + // Initialization of the plugin goes here. + var script = GD.Load