Fix inventory menu, add armor as equippable item

This commit is contained in:
2024-09-07 01:01:50 -07:00
parent dc035eb1fe
commit b478ad39fe
23 changed files with 305 additions and 84 deletions

View File

@@ -1,8 +1,26 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using GameJamDungeon;
using Godot;
using System.Linq;
[Meta(typeof(IAutoNode))]
public partial class Armor : InventoryItem
{
public override void _Notification(int what) => this.Notify(what);
[Export]
public override InventoryItemInfo InventoryInfo { get; set; }
public void OnReady()
{
Pickup.BodyEntered += OnEntered;
}
public void OnEntered(Node3D body)
{
var inventoryList = GameRepo.InventoryItems.Value.Append(InventoryInfo).ToList();
GameRepo.InventoryItems.OnNext(inventoryList);
QueueFree();
}
}

View File

@@ -1,15 +1,33 @@
[gd_scene load_steps=4 format=3 uid="uid://dorr7v1tkeiy0"]
[gd_scene load_steps=6 format=3 uid="uid://dorr7v1tkeiy0"]
[ext_resource type="Script" path="res://src/items/armor/Armor.cs" id="1_cmjpq"]
[ext_resource type="Texture2D" uid="uid://cgoubcl86pib4" path="res://src/items/armor/armor.png" id="1_vpnem"]
[ext_resource type="Resource" uid="uid://chjmkb3aiomvr" path="res://src/items/armor/resources/PatheticCoat.tres" id="2_eftit"]
[ext_resource type="Script" path="res://src/items/armor/ArmorInfo.cs" id="2_cuhrp"]
[sub_resource type="Resource" id="Resource_o1cok"]
script = ExtResource("2_cuhrp")
Defense = 2
Name = "Pathetic"
Description = "A pathetic coat."
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_1gpxo"]
radius = 0.470016
height = 0.940032
[node name="Armor" type="Node3D"]
script = ExtResource("1_cmjpq")
InventoryInfo = ExtResource("2_eftit")
InventoryInfo = SubResource("Resource_o1cok")
[node name="Sprite3D" type="Sprite3D" parent="."]
billboard = 2
alpha_cut = 1
texture_filter = 0
texture = ExtResource("1_vpnem")
[node name="Pickup" type="Area3D" parent="."]
unique_name_in_owner = true
collision_layer = 4
collision_mask = 4
[node name="CollisionShape3D" type="CollisionShape3D" parent="Pickup"]
shape = SubResource("CapsuleShape3D_1gpxo")

View File

@@ -0,0 +1,10 @@
using Godot;
namespace GameJamDungeon;
[GlobalClass]
public partial class ArmorInfo : InventoryItemInfo
{
[Export]
public int Defense { get; set; }
}