Massive refactor (inventory menu still a little broken but its Good Enough)

This commit is contained in:
2024-09-12 02:24:14 -07:00
parent 149c8d9571
commit b4662a0c7b
94 changed files with 1066 additions and 825 deletions

View File

@@ -11,18 +11,18 @@ public partial class ThrowableItem : Node3D, IInventoryItem
{
public override void _Notification(int what) => this.Notify(what);
public Guid ID { get; } = new Guid();
[Dependency] public IGameRepo GameRepo => this.DependOn<IGameRepo>();
[Node] public IAnimationPlayer AnimationPlayer { get; set; } = default!;
[Node] public IHitbox Hitbox { get; set; } = default!;
public InventoryItemInfo Info => ThrowableItemInfo;
public InventoryItemStats Info => ThrowableItemInfo;
public int Count { get; }
[Export]
public ThrowableItemInfo ThrowableItemInfo { get; set; }
public ThrowableItemStats ThrowableItemInfo { get; set; }
[Node] public Sprite3D Sprite { get; set; } = default!;
@@ -37,22 +37,19 @@ public partial class ThrowableItem : Node3D, IInventoryItem
public void Throw()
{
GameRepo.InventoryItems.Value.Remove(this);
GameRepo.PlayerData.Inventory.Remove(this);
}
public void Drop()
{
GameRepo.InventoryItems.Value.Remove(this);
GameRepo.PlayerData.Inventory.Remove(this);
}
public void OnEntered(Node3D body)
{
if (GameRepo.InventoryItems.Value.Count() >= GameRepo.MaxItemSize)
return;
var inventoryList = GameRepo.InventoryItems.Value.Append(this).ToList();
GameRepo.InventoryItems.OnNext(inventoryList);
QueueFree();
var isAdded = GameRepo.PlayerData.Inventory.TryAdd(this);
if (isAdded)
QueueFree();
}
private void OnAnimationFinished(StringName animName)

View File

@@ -3,7 +3,7 @@
namespace GameJamDungeon;
[GlobalClass]
public partial class ThrowableItemInfo : InventoryItemInfo
public partial class ThrowableItemStats : InventoryItemStats
{
[Export]
public Godot.Collections.Array<ThrowableItemTag> ThrowableItemTags { get; set; } = new Godot.Collections.Array<ThrowableItemTag>();

View File

@@ -1,6 +1,6 @@
[gd_resource type="Resource" script_class="ThrowableItemInfo" load_steps=3 format=3 uid="uid://bph8c6by4s047"]
[gd_resource type="Resource" script_class="ThrowableItemStats" load_steps=3 format=3 uid="uid://bph8c6by4s047"]
[ext_resource type="Script" path="res://src/items/throwable/ThrowableItemInfo.cs" id="1_ewck5"]
[ext_resource type="Script" path="res://src/items/throwable/ThrowableItemStats.cs" id="1_ewck5"]
[ext_resource type="Texture2D" uid="uid://mi70lolgtf3n" path="res://src/items/throwable/textures/GEOMANCER-DICE.png" id="1_jhits"]
[resource]

View File

@@ -1,7 +1,7 @@
[gd_resource type="Resource" script_class="ThrowableItemInfo" load_steps=3 format=3 uid="uid://qqg0gdcb8fwg"]
[ext_resource type="Texture2D" uid="uid://dhfn51smm818x" path="res://src/items/throwable/textures/spell sign - luck.PNG" id="1_3605p"]
[ext_resource type="Script" path="res://src/items/throwable/ThrowableItemInfo.cs" id="1_s3pq7"]
[ext_resource type="Script" path="res://src/items/throwable/ThrowableItemStats.cs" id="1_s3pq7"]
[resource]
script = ExtResource("1_s3pq7")