Add debug menu, add ability to load next floor or spawn item
This commit is contained in:
1
Zennysoft.Game.Ma/src/ui/pause_menu/DebugMenu.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/ui/pause_menu/DebugMenu.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://0jfd7fcxyuq1
|
||||
5
Zennysoft.Game.Ma/src/ui/pause_menu/IDebugMenu.cs
Normal file
5
Zennysoft.Game.Ma/src/ui/pause_menu/IDebugMenu.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public interface IDebugMenu : IControl;
|
||||
1
Zennysoft.Game.Ma/src/ui/pause_menu/IDebugMenu.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/ui/pause_menu/IDebugMenu.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dkibl33wtc58k
|
||||
58
Zennysoft.Game.Ma/src/ui/pause_menu/PauseDebugMenu.cs
Normal file
58
Zennysoft.Game.Ma/src/ui/pause_menu/PauseDebugMenu.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class PauseDebugMenu : Control, IDebugMenu
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency] private IMap _map => this.DependOn<IMap>(() => new Map());
|
||||
|
||||
[Dependency] private IPlayer _player => this.DependOn<IPlayer>();
|
||||
|
||||
[Node] public Button LoadNextFloorButton { get; set; } = default!;
|
||||
|
||||
[Node] public OptionButton SpawnItemDropDown { get; set; } = default;
|
||||
|
||||
private ImmutableList<InventoryItem> SpawnableItems;
|
||||
|
||||
private ItemDatabase _itemDatabase;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
VisibilityChanged += PauseDebugMenu_VisibilityChanged;
|
||||
LoadNextFloorButton.Pressed += LoadNextFloorButton_Pressed;
|
||||
_itemDatabase = new ItemDatabase();
|
||||
SpawnableItems = _itemDatabase.Items;
|
||||
foreach (var item in SpawnableItems)
|
||||
SpawnItemDropDown.AddItem(item.ItemName, SpawnableItems.IndexOf(item));
|
||||
SpawnItemDropDown.ItemSelected += SpawnItemDropDown_ItemSelected;
|
||||
}
|
||||
|
||||
private void SpawnItemDropDown_ItemSelected(long index)
|
||||
{
|
||||
var itemToSpawn = SpawnableItems.ElementAt((int)index);
|
||||
var duplicated = itemToSpawn.Duplicate((int)DuplicateFlags.UseInstantiation) as Node3D;
|
||||
duplicated.GlobalPosition = new Vector3(_player.CurrentPosition.X, _player.CurrentPosition.Y + 1, _player.CurrentPosition.Z) + (-_player.CurrentBasis.Z * 2);
|
||||
AddChild(duplicated);
|
||||
}
|
||||
|
||||
private void LoadNextFloorButton_Pressed()
|
||||
{
|
||||
_map.SpawnNextFloor();
|
||||
}
|
||||
|
||||
private void PauseDebugMenu_VisibilityChanged()
|
||||
{
|
||||
if (Visible)
|
||||
LoadNextFloorButton.GrabFocus();
|
||||
else
|
||||
ReleaseFocus();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://l1v4ppubryd3
|
||||
@@ -1,8 +1,7 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://blbqgw3wosc1w"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_ccrq3"]
|
||||
resource_name = "fade_out"
|
||||
length = 0.5
|
||||
[sub_resource type="Animation" id="Animation_f1eqn"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
@@ -10,10 +9,10 @@ tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 7.7),
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
|
||||
"values": [Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_bium7"]
|
||||
@@ -32,8 +31,9 @@ tracks/0/keys = {
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_f1eqn"]
|
||||
length = 0.001
|
||||
[sub_resource type="Animation" id="Animation_ccrq3"]
|
||||
resource_name = "fade_out"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
@@ -41,17 +41,17 @@ tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"times": PackedFloat32Array(0, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 7.7),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1)]
|
||||
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_pmp7u"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_f1eqn"),
|
||||
"fade_in": SubResource("Animation_bium7"),
|
||||
"fade_out": SubResource("Animation_ccrq3")
|
||||
&"RESET": SubResource("Animation_f1eqn"),
|
||||
&"fade_in": SubResource("Animation_bium7"),
|
||||
&"fade_out": SubResource("Animation_ccrq3")
|
||||
}
|
||||
|
||||
[node name="PauseMenu" type="Control"]
|
||||
@@ -66,7 +66,7 @@ grow_vertical = 2
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_pmp7u")
|
||||
&"": SubResource("AnimationLibrary_pmp7u")
|
||||
}
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
|
||||
Reference in New Issue
Block a user