Big fix of inventory system, add accessory item type
This commit is contained in:
@@ -2,14 +2,11 @@
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using System.Linq;
|
||||
|
||||
namespace GameJamDungeon
|
||||
{
|
||||
public interface IInventoryItem : INode3D
|
||||
{
|
||||
public abstract InventoryItemInfo InventoryInfo { get; set; }
|
||||
|
||||
public IGameRepo GameRepo { get; }
|
||||
}
|
||||
|
||||
@@ -17,10 +14,9 @@ namespace GameJamDungeon
|
||||
public abstract partial class InventoryItem : Node3D, IInventoryItem
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency] public IGameRepo GameRepo => this.DependOn<IGameRepo>();
|
||||
|
||||
public abstract InventoryItemInfo InventoryInfo { get; set; }
|
||||
internal abstract InventoryItemInfo Info { get; set; }
|
||||
|
||||
[Node] public Area3D Pickup { get; set; } = default!;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class InventoryItemInfo : Resource
|
||||
|
||||
30
src/items/accessory/Accessory.cs
Normal file
30
src/items/accessory/Accessory.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using GameJamDungeon;
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class Accessory : InventoryItem
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
public AccessoryInfo AccessoryInfo { get => (AccessoryInfo)Info; }
|
||||
|
||||
[Export]
|
||||
internal override InventoryItemInfo Info { get; set; }
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
Pickup.BodyEntered += OnEntered;
|
||||
}
|
||||
|
||||
public void OnEntered(Node3D body)
|
||||
{
|
||||
var inventoryList = GameRepo.InventoryItems.Value.Append(this).ToList();
|
||||
GameRepo.InventoryItems.OnNext(inventoryList);
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
}
|
||||
31
src/items/accessory/Accessory.tscn
Normal file
31
src/items/accessory/Accessory.tscn
Normal file
@@ -0,0 +1,31 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://1bbmod6680c2"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/items/accessory/Accessory.cs" id="1_jq0hu"]
|
||||
[ext_resource type="Texture2D" uid="uid://d0yqm7ars827b" path="res://src/items/accessory/accessory.png" id="1_sfkuo"]
|
||||
[ext_resource type="Script" path="res://src/items/accessory/AccessoryInfo.cs" id="2_kejmw"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_lu6du"]
|
||||
script = ExtResource("2_kejmw")
|
||||
Name = "Basic Accessory"
|
||||
Description = ""
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_uavx4"]
|
||||
radius = 0.470016
|
||||
height = 0.940032
|
||||
|
||||
[node name="Accessory" type="Node3D"]
|
||||
script = ExtResource("1_jq0hu")
|
||||
Info = SubResource("Resource_lu6du")
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||
billboard = 2
|
||||
texture_filter = 0
|
||||
texture = ExtResource("1_sfkuo")
|
||||
|
||||
[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_uavx4")
|
||||
10
src/items/accessory/AccessoryInfo.cs
Normal file
10
src/items/accessory/AccessoryInfo.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
namespace GameJamDungeon;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class AccessoryInfo : InventoryItemInfo
|
||||
{
|
||||
// TODO: List all possible status effects here
|
||||
}
|
||||
BIN
src/items/accessory/accessory.png
Normal file
BIN
src/items/accessory/accessory.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
35
src/items/accessory/accessory.png.import
Normal file
35
src/items/accessory/accessory.png.import
Normal file
@@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://d0yqm7ars827b"
|
||||
path.s3tc="res://.godot/imported/accessory.png-04ec32093cb21658c9558ccc9e7c09b2.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://src/items/accessory/accessory.png"
|
||||
dest_files=["res://.godot/imported/accessory.png-04ec32093cb21658c9558ccc9e7c09b2.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
||||
@@ -10,7 +10,9 @@ public partial class Armor : InventoryItem
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Export]
|
||||
public override InventoryItemInfo InventoryInfo { get; set; }
|
||||
internal override InventoryItemInfo Info { get; set; }
|
||||
|
||||
public ArmorInfo ArmorInfo { get => (ArmorInfo)Info; }
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
@@ -19,7 +21,7 @@ public partial class Armor : InventoryItem
|
||||
|
||||
public void OnEntered(Node3D body)
|
||||
{
|
||||
var inventoryList = GameRepo.InventoryItems.Value.Append(InventoryInfo).ToList();
|
||||
var inventoryList = GameRepo.InventoryItems.Value.Append(this).ToList();
|
||||
GameRepo.InventoryItems.OnNext(inventoryList);
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://dorr7v1tkeiy0"]
|
||||
[gd_scene load_steps=5 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="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."
|
||||
[ext_resource type="Resource" uid="uid://chjmkb3aiomvr" path="res://src/items/armor/resources/PatheticCoat.tres" id="2_eftit"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_1gpxo"]
|
||||
radius = 0.470016
|
||||
@@ -16,7 +10,7 @@ height = 0.940032
|
||||
|
||||
[node name="Armor" type="Node3D"]
|
||||
script = ExtResource("1_cmjpq")
|
||||
InventoryInfo = SubResource("Resource_o1cok")
|
||||
Info = ExtResource("2_eftit")
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||
billboard = 2
|
||||
|
||||
@@ -7,17 +7,17 @@ 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;
|
||||
Info = new WeaponInfo() { Damage = 1 };
|
||||
}
|
||||
|
||||
[Export]
|
||||
private WeaponInfo _inventoryInfo { get; set; }
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
public override InventoryItemInfo InventoryInfo { get => _inventoryInfo; set => _inventoryInfo = value as WeaponInfo; }
|
||||
[Export]
|
||||
internal override InventoryItemInfo Info { get; set; }
|
||||
|
||||
public WeaponInfo WeaponInfo { get => (WeaponInfo)Info; }
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
@@ -26,7 +26,7 @@ public partial class Weapon : InventoryItem
|
||||
|
||||
public void OnEntered(Node3D body)
|
||||
{
|
||||
var inventoryList = GameRepo.InventoryItems.Value.Append(InventoryInfo).ToList();
|
||||
var inventoryList = GameRepo.InventoryItems.Value.Append(this).ToList();
|
||||
GameRepo.InventoryItems.OnNext(inventoryList);
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,4 @@ public partial class WeaponInfo : InventoryItemInfo
|
||||
|
||||
[Export]
|
||||
public double IgneousDamageBonus { get; set; }
|
||||
|
||||
public static WeaponInfo Default => new WeaponInfo() { Damage = 1 };
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ height = 0.940032
|
||||
|
||||
[node name="CommonSword" type="Node3D"]
|
||||
script = ExtResource("1_sr3bh")
|
||||
_inventoryInfo = ExtResource("2_krjts")
|
||||
Info = ExtResource("2_krjts")
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||
billboard = 2
|
||||
|
||||
@@ -10,7 +10,7 @@ height = 0.940032
|
||||
|
||||
[node name="RareSword" type="Node3D"]
|
||||
script = ExtResource("1_f8v7v")
|
||||
_inventoryInfo = ExtResource("2_6nmyd")
|
||||
Info = ExtResource("2_6nmyd")
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||
billboard = 2
|
||||
|
||||
@@ -10,7 +10,7 @@ height = 0.940032
|
||||
|
||||
[node name="UncommonSword" type="Node3D"]
|
||||
script = ExtResource("1_3o4dy")
|
||||
_inventoryInfo = ExtResource("2_ga52m")
|
||||
Info = ExtResource("2_ga52m")
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||
billboard = 2
|
||||
|
||||
Reference in New Issue
Block a user