Barebones inventory menu addition

This commit is contained in:
2024-09-01 13:22:40 -07:00
parent b1ef3dbaab
commit 4dd89e2035
6 changed files with 89 additions and 11 deletions

View File

@@ -24,6 +24,8 @@ public partial class Game : Node3D, IGame
[Dependency] public IAppRepo AppRepo => this.DependOn<IAppRepo>();
[Node] public IInventoryMenu InventoryMenu { get; set; } = default!;
[Node] public Control MiniMap { get; set; } = default!;
public void Setup()
@@ -40,6 +42,8 @@ public partial class Game : Node3D, IGame
GameBinding
.Handle((in GameLogic.Output.StartGame _) => { GameRepo.Resume(); })
.Handle((in GameLogic.Output.SetPauseMode output) => { CallDeferred(nameof(SetPauseMode), output.IsPaused); })
.Handle((in GameLogic.Output.SetInventoryMode _) => { InventoryMenu.PopulateItems(_.Inventory); InventoryMenu.Show(); })
.Handle((in GameLogic.Output.HideInventory _) => { InventoryMenu.Hide(); InventoryMenu.ClearItems(); })
.Handle((in GameLogic.Output.ShowMiniMap _) => { MiniMap.Show(); })
.Handle((in GameLogic.Output.HideMiniMap _) => { MiniMap.Hide(); })
.Handle((in GameLogic.Output.GameOver _) => { AppRepo.OnGameOver(); });

View File

@@ -1,10 +1,11 @@
[gd_scene load_steps=10 format=3 uid="uid://33ek675mfb5n"]
[gd_scene load_steps=11 format=3 uid="uid://33ek675mfb5n"]
[ext_resource type="Script" path="res://src/game/Game.cs" id="1_ytcii"]
[ext_resource type="PackedScene" uid="uid://wg25dg65ksgg" path="res://src/map/dungeon/DungeonGenerator.tscn" id="2_cgboj"]
[ext_resource type="PackedScene" uid="uid://cfecvvav8kkp6" path="res://src/player/Player.tscn" id="3_kk6ly"]
[ext_resource type="PackedScene" uid="uid://dhpwwqow1ahrc" path="res://src/map/dungeon/rooms/Room1.tscn" id="4_56rmd"]
[ext_resource type="PackedScene" uid="uid://bbwgmqy3evhh2" path="res://src/map/dungeon/rooms/Room2.tscn" id="4_clpvl"]
[ext_resource type="PackedScene" uid="uid://dlj8qdg1c5048" path="res://src/inventory_menu/InventoryMenu.tscn" id="4_wk8gw"]
[ext_resource type="PackedScene" uid="uid://bwbofurcvf3yh" path="res://src/minimap/Minimap.tscn" id="6_owlf4"]
[sub_resource type="Environment" id="Environment_fke5g"]
@@ -40,6 +41,10 @@ shape = SubResource("BoxShape3D_s2hwi")
unique_name_in_owner = true
visible = false
[node name="InventoryMenu" parent="." instance=ExtResource("4_wk8gw")]
unique_name_in_owner = true
visible = false
[node name="OmniLight3D" type="OmniLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 24.5244, 0)
layers = 3

View File

@@ -23,10 +23,6 @@ public interface IGameRepo : IDisposable
void SetPlayerGlobalPosition(Vector3 playerGlobalPosition);
void SetNavigationRegion(NavigationRegion3D region);
IAutoProp<NavigationRegion3D> NavigationRegion3D { get; }
public Weapon EquippedWeapon { get; }
}
@@ -50,9 +46,6 @@ public class GameRepo : IGameRepo
private Weapon _equippedWeapon;
public Weapon EquippedWeapon => _equippedWeapon;
private AutoProp<NavigationRegion3D> _navigationRegion3D;
public IAutoProp<NavigationRegion3D> NavigationRegion3D => _navigationRegion3D;
private bool _disposedValue;
public GameRepo()
@@ -62,7 +55,6 @@ public class GameRepo : IGameRepo
_isPaused = new AutoProp<bool>(false);
_playerGlobalPosition = new AutoProp<Vector3>(Vector3.Zero);
_equippedWeapon = new Weapon() { InventoryInfo = WeaponInfo.Default };
_navigationRegion3D = new AutoProp<NavigationRegion3D>(new NavigationRegion3D());
}
public void Pause()
@@ -79,8 +71,6 @@ public class GameRepo : IGameRepo
public void SetPlayerGlobalPosition(Vector3 playerGlobalPosition) => _playerGlobalPosition.OnNext(playerGlobalPosition);
public void SetNavigationRegion(NavigationRegion3D region) => _navigationRegion3D.OnNext(region);
public void OnGameEnded()
{
Pause();