diff --git a/ColdMint.Traveler.csproj b/ColdMint.Traveler.csproj index c893429..ec53ff3 100644 --- a/ColdMint.Traveler.csproj +++ b/ColdMint.Traveler.csproj @@ -8,4 +8,7 @@ enable 12 + + + \ No newline at end of file diff --git a/locals/Item.en.translation b/locals/Item.en.translation index 1c8ae52..f16d6d9 100644 Binary files a/locals/Item.en.translation and b/locals/Item.en.translation differ diff --git a/locals/Item.ja.translation b/locals/Item.ja.translation index 27c8bbc..29758ae 100644 Binary files a/locals/Item.ja.translation and b/locals/Item.ja.translation differ diff --git a/locals/Item.zh.translation b/locals/Item.zh.translation index b775a9f..013e7ca 100644 Binary files a/locals/Item.zh.translation and b/locals/Item.zh.translation differ diff --git a/prefab/packsacks/packsack.tscn b/prefab/packsacks/packsack.tscn index 3599009..9520244 100644 --- a/prefab/packsacks/packsack.tscn +++ b/prefab/packsacks/packsack.tscn @@ -10,6 +10,7 @@ size = Vector2(41, 57) collision_layer = 8 collision_mask = 38 script = ExtResource("1_8ehup") +Id = "packsack" metadata/Id = "Packsack" metadata/MaxStackQuantity = 1 metadata/Icon = ExtResource("2_e1ale") diff --git a/scripts/character/Player.cs b/scripts/character/Player.cs index 66a2fae..cc8b4b9 100644 --- a/scripts/character/Player.cs +++ b/scripts/character/Player.cs @@ -6,6 +6,7 @@ using ColdMint.scripts.damage; using ColdMint.scripts.deathInfo; using ColdMint.scripts.debug; using ColdMint.scripts.inventory; +using ColdMint.scripts.item; using ColdMint.scripts.map.events; using ColdMint.scripts.utils; using ColdMint.scripts.item.weapon; diff --git a/scripts/inventory/Packsack.cs b/scripts/inventory/Packsack.cs index 31dcbc8..bd517da 100644 --- a/scripts/inventory/Packsack.cs +++ b/scripts/inventory/Packsack.cs @@ -1,5 +1,8 @@ using System; + using ColdMint.scripts.debug; +using ColdMint.scripts.item; + using Godot; namespace ColdMint.scripts.inventory; @@ -10,26 +13,41 @@ namespace ColdMint.scripts.inventory; /// public partial class Packsack : RigidBody2D, IItem { - public string? Id { get; set; } - public int Quantity { get; set; } - public int MaxStackQuantity { get; set; } - public Texture2D? Icon { get; set; } - public new string? Name { get; set; } - public string? Description { get; set; } - public Action? OnUse { get; set; } - public Func? OnInstantiation { get; set; } + [Export] public string Id { get; protected set; } = "place_holder_id"; + + protected Texture2D? UniqueIcon { get; set; } + public Texture2D Icon => UniqueIcon ?? ItemTypeManager.DefaultIconOf(Id); + + protected string? UniqueName { get; set; } + public new string Name => UniqueName ?? ItemTypeManager.DefaultNameOf(Id); + + protected string? UniqueDescription { get; set; } + public string? Description => UniqueDescription ?? ItemTypeManager.DefaultDescriptionOf(Id); + + public void Use(Node2D? owner, Vector2 targetGlobalPosition) { } + + public void Destroy() + { + if (_itemContainer == null) return; + foreach (var itemSlot in _itemContainer) + { + itemSlot.ClearSlot(); + } + + QueueFree(); + } private IItemContainer? _itemContainer; public override void _Ready() { base._Ready(); - Id = GetMeta("ID", "1").AsString(); - Quantity = GetMeta("Quantity", "1").AsInt32(); - MaxStackQuantity = GetMeta("MaxStackQuantity", Config.MaxStackQuantity).AsInt32(); - Icon = GetMeta("Icon", "").As(); - Name = GetMeta("Name", "").AsString(); - Description = GetMeta("Description", "").AsString(); + // Id = GetMeta("ID", "1").AsString(); + // Quantity = GetMeta("Quantity", "1").AsInt32(); + // MaxStackQuantity = GetMeta("MaxStackQuantity", Config.MaxStackQuantity).AsInt32(); + // Icon = GetMeta("Icon", "").As(); + // Name = GetMeta("Name", "").AsString(); + // Description = GetMeta("Description", "").AsString(); _itemContainer = new UniversalItemContainer(); } diff --git a/scripts/item/ItemTypeManager.cs b/scripts/item/ItemTypeManager.cs index 663d736..c2e116d 100644 --- a/scripts/item/ItemTypeManager.cs +++ b/scripts/item/ItemTypeManager.cs @@ -12,8 +12,15 @@ public static class ItemTypeManager public static void StaticRegister() { var staffOfTheUndeadScene = ResourceLoader.Load("res://prefab/weapons/staffOfTheUndead.tscn"); - var staffOfTheUndead = new ItemType("staff_of_the_undead", () => staffOfTheUndeadScene.Instantiate(), null, 1); + var staffOfTheUndeadIcon = ResourceLoader.Load("res://sprites/weapon/staffOfTheUndead.png"); + var staffOfTheUndead = + new ItemType("staff_of_the_undead", () => staffOfTheUndeadScene.Instantiate(), staffOfTheUndeadIcon, 1); Register(staffOfTheUndead); + + var packsackScene = ResourceLoader.Load("res://prefab/packsacks/packsack.tscn"); + var packsackIcon = ResourceLoader.Load("res://sprites/Player.png"); + var packsack = new ItemType("packsack", () => packsackScene.Instantiate(), packsackIcon, 1); + Register(packsack); } private static Dictionary Registry { get; } = []; diff --git a/scripts/item/weapon/WeaponTemplate.cs b/scripts/item/weapon/WeaponTemplate.cs index e8bd693..b4be423 100644 --- a/scripts/item/weapon/WeaponTemplate.cs +++ b/scripts/item/weapon/WeaponTemplate.cs @@ -20,7 +20,7 @@ public abstract partial class WeaponTemplate : RigidBody2D, IItem //Implements IItem [Export] public virtual string Id { get; private set; } = "ID"; - protected virtual Texture2D? UniqueIcon { get; set; } + protected Texture2D? UniqueIcon { get; set; } public Texture2D Icon => UniqueIcon ?? ItemTypeManager.DefaultIconOf(Id); protected string? UniqueName { get; set; }