Add map loading logic and spawn rate control
This commit is contained in:
@@ -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<string, float> LayoutWithSpawnRate { get; private set; }
|
||||
|
||||
[Export]
|
||||
public Dictionary<EnemyType, float> 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<string, float>();
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://ci7o3nn4mdo8o
|
||||
@@ -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<Script>("res://addons/dungeon_floor_layout/DungeonFloorLayout.cs");
|
||||
var texture = GD.Load<Texture2D>("res://addons/dungeon_floor_layout/icon_door.png");
|
||||
AddCustomType(nameof(DungeonFloorLayout), nameof(LayoutType), script, texture);
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
// Clean-up of the plugin goes here.
|
||||
RemoveCustomType(nameof(DungeonFloorLayout));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1 @@
|
||||
uid://f87ejxatyy2n
|
||||
BIN
Zennysoft.Game.Ma/addons/dungeon_floor_layout/icon_door.png
Normal file
BIN
Zennysoft.Game.Ma/addons/dungeon_floor_layout/icon_door.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 161 B |
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cgd2d4fusp4pg"
|
||||
path="res://.godot/imported/icon_door.png-437da3e7d1cb55961e6afceef56e9ea2.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/dungeon_floor_layout/icon_door.png"
|
||||
dest_files=["res://.godot/imported/icon_door.png-437da3e7d1cb55961e6afceef56e9ea2.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
||||
7
Zennysoft.Game.Ma/addons/dungeon_floor_layout/plugin.cfg
Normal file
7
Zennysoft.Game.Ma/addons/dungeon_floor_layout/plugin.cfg
Normal file
@@ -0,0 +1,7 @@
|
||||
[plugin]
|
||||
|
||||
name="Dungeon Floor Layout"
|
||||
description=""
|
||||
author="Zenny"
|
||||
version=""
|
||||
script="DungeonFloorLayoutNode.cs"
|
||||
@@ -0,0 +1,25 @@
|
||||
using Godot;
|
||||
using Zennysoft.Game.Ma;
|
||||
|
||||
[Tool]
|
||||
public partial class SpecialFloorLayout : LayoutType
|
||||
{
|
||||
[Export]
|
||||
public SpecialFloorType FloorName { get; set; }
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
base._EnterTree();
|
||||
}
|
||||
|
||||
public enum SpecialFloorType
|
||||
{
|
||||
Overworld,
|
||||
Altar,
|
||||
BossFloorA,
|
||||
BossFloorB,
|
||||
GoddessOfGuidanceFloor,
|
||||
TrueGoddessOfGuidanceFloor,
|
||||
FinalFloor
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://cabvj6s31iucg
|
||||
@@ -0,0 +1,23 @@
|
||||
#if TOOLS
|
||||
using Godot;
|
||||
using System;
|
||||
using Zennysoft.Game.Ma;
|
||||
|
||||
[Tool]
|
||||
public partial class SpecialFloorLayoutNode : EditorPlugin
|
||||
{
|
||||
public override void _EnterTree()
|
||||
{
|
||||
// Initialization of the plugin goes here.
|
||||
var script = GD.Load<Script>("res://addons/special_floor_layout_node/SpecialFloorLayout.cs");
|
||||
var texture = GD.Load<Texture2D>("res://addons/special_floor_layout_node/icon_door.png");
|
||||
AddCustomType(nameof(SpecialFloorLayout), nameof(LayoutType), script, texture);
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
// Clean-up of the plugin goes here.
|
||||
RemoveCustomType(nameof(SpecialFloorLayout));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1 @@
|
||||
uid://uy8mygg0jtd8
|
||||
BIN
Zennysoft.Game.Ma/addons/special_floor_layout_node/icon_door.png
Normal file
BIN
Zennysoft.Game.Ma/addons/special_floor_layout_node/icon_door.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 161 B |
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://pxevsja7e3s0"
|
||||
path="res://.godot/imported/icon_door.png-d7e4ac87b8cdfac1c9f03b9aff4c7e79.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/special_floor_layout_node/icon_door.png"
|
||||
dest_files=["res://.godot/imported/icon_door.png-d7e4ac87b8cdfac1c9f03b9aff4c7e79.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
||||
@@ -0,0 +1,7 @@
|
||||
[plugin]
|
||||
|
||||
name="Special Floor Layout Node"
|
||||
description=""
|
||||
author="Zenny"
|
||||
version=""
|
||||
script="SpecialFloorLayoutNode.cs"
|
||||
Reference in New Issue
Block a user