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