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,14 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using GameJamDungeon;
using Godot;
using System.Linq;
[Meta(typeof(IAutoNode))]
public partial class Weapon : InventoryItem
{
public override void _Notification(int what) => this.Notify(what);
public Weapon()
{
_inventoryInfo = WeaponInfo.Default;
@@ -12,4 +18,16 @@ public partial class Weapon : InventoryItem
private WeaponInfo _inventoryInfo { get; set; }
public override InventoryItemInfo InventoryInfo { get => _inventoryInfo; set => _inventoryInfo = value as WeaponInfo; }
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

@@ -0,0 +1,10 @@
using Godot;
[GlobalClass]
public partial class WeaponInfo : InventoryItemInfo
{
[Export]
public required int Damage { get; set; }
public static WeaponInfo Default => new WeaponInfo() { Damage = 1 };
}

View File

@@ -1,9 +1,13 @@
[gd_scene load_steps=4 format=3 uid="uid://b6atdgf2e6e2t"]
[gd_scene load_steps=5 format=3 uid="uid://b6atdgf2e6e2t"]
[ext_resource type="Script" path="res://src/items/weapons/Weapon.cs" id="1_sr3bh"]
[ext_resource type="Resource" uid="uid://dq8tdmjhrqsrh" path="res://src/items/weapons/resources/CommonSword.tres" id="2_krjts"]
[ext_resource type="Texture2D" uid="uid://wd6jh5q51e4k" path="res://src/items/weapons/models/sword.png" id="3_ixjdd"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_j2it8"]
radius = 0.470016
height = 0.940032
[node name="CommonSword" type="Node3D"]
script = ExtResource("1_sr3bh")
_inventoryInfo = ExtResource("2_krjts")
@@ -16,3 +20,11 @@ alpha_scissor_threshold = 0.511
alpha_antialiasing_mode = 1
texture_filter = 0
texture = ExtResource("3_ixjdd")
[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_j2it8")

View File

@@ -1,9 +1,13 @@
[gd_scene load_steps=4 format=3 uid="uid://c10nhqq8su6pp"]
[gd_scene load_steps=5 format=3 uid="uid://c10nhqq8su6pp"]
[ext_resource type="Script" path="res://src/items/weapons/Weapon.cs" id="1_f8v7v"]
[ext_resource type="Resource" uid="uid://b4oxsf4k3nr43" path="res://src/items/weapons/resources/RareSword.tres" id="2_6nmyd"]
[ext_resource type="Texture2D" uid="uid://wd6jh5q51e4k" path="res://src/items/weapons/models/sword.png" id="3_meaac"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_4ic28"]
radius = 0.470016
height = 0.940032
[node name="RareSword" type="Node3D"]
script = ExtResource("1_f8v7v")
_inventoryInfo = ExtResource("2_6nmyd")
@@ -16,3 +20,11 @@ alpha_scissor_threshold = 0.511
alpha_antialiasing_mode = 1
texture_filter = 0
texture = ExtResource("3_meaac")
[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_4ic28")

View File

@@ -1,9 +1,13 @@
[gd_scene load_steps=4 format=3 uid="uid://cbb1fxllrnlyr"]
[gd_scene load_steps=5 format=3 uid="uid://cbb1fxllrnlyr"]
[ext_resource type="Script" path="res://src/items/weapons/Weapon.cs" id="1_3o4dy"]
[ext_resource type="Resource" uid="uid://e0t7swnl2sfd" path="res://src/items/weapons/resources/UncommonSword.tres" id="2_ga52m"]
[ext_resource type="Texture2D" uid="uid://wd6jh5q51e4k" path="res://src/items/weapons/models/sword.png" id="3_r8wg3"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_cbafi"]
radius = 0.470016
height = 0.940032
[node name="UncommonSword" type="Node3D"]
script = ExtResource("1_3o4dy")
_inventoryInfo = ExtResource("2_ga52m")
@@ -16,3 +20,11 @@ alpha_scissor_threshold = 0.511
alpha_antialiasing_mode = 1
texture_filter = 0
texture = ExtResource("3_r8wg3")
[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_cbafi")

View File

@@ -1,9 +1,9 @@
[gd_resource type="Resource" script_class="WeaponInfo" load_steps=2 format=3 uid="uid://dq8tdmjhrqsrh"]
[ext_resource type="Script" path="res://src/items/WeaponInfo.cs" id="1_wc11x"]
[ext_resource type="Script" path="res://src/items/weapons/WeaponInfo.cs" id="1_k7yyo"]
[resource]
script = ExtResource("1_wc11x")
Damage = 2
Name = "Common Sword"
Description = "This is just a regular sword."
script = ExtResource("1_k7yyo")
Damage = 3
Name = "Common sword"
Description = "Common"

View File

@@ -1,9 +1,9 @@
[gd_resource type="Resource" script_class="WeaponInfo" load_steps=2 format=3 uid="uid://b4oxsf4k3nr43"]
[ext_resource type="Script" path="res://src/items/WeaponInfo.cs" id="1_ybm7s"]
[ext_resource type="Script" path="res://src/items/weapons/WeaponInfo.cs" id="1_oqgv2"]
[resource]
script = ExtResource("1_ybm7s")
script = ExtResource("1_oqgv2")
Damage = 7
Name = "Rare Sword"
Description = "Wow. How did you get this one?"
Name = "Rare sword"
Description = "Rare"

View File

@@ -1,9 +1,9 @@
[gd_resource type="Resource" script_class="WeaponInfo" load_steps=2 format=3 uid="uid://e0t7swnl2sfd"]
[ext_resource type="Script" path="res://src/items/WeaponInfo.cs" id="1_0u4lk"]
[ext_resource type="Script" path="res://src/items/weapons/WeaponInfo.cs" id="1_8os8m"]
[resource]
script = ExtResource("1_0u4lk")
Damage = 4
Name = "Uncommon Sword."
Description = "This one is a little bit better."
script = ExtResource("1_8os8m")
Damage = 5
Name = "Uncommon sword"
Description = "Uncommon"