2024-06-13 06:18:11 +00:00
|
|
|
|
using ColdMint.scripts.inventory;
|
2024-06-14 04:22:44 +00:00
|
|
|
|
using ColdMint.scripts.item.itemStacks;
|
2024-06-12 15:42:35 +00:00
|
|
|
|
using Godot;
|
|
|
|
|
|
2024-06-13 06:18:11 +00:00
|
|
|
|
namespace ColdMint.scripts.item;
|
2024-06-12 15:42:35 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>packsack</para>
|
|
|
|
|
/// <para>背包</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class Packsack : RigidBody2D, IItem
|
|
|
|
|
{
|
2024-06-13 03:04:51 +00:00
|
|
|
|
[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()
|
|
|
|
|
{
|
2024-06-14 04:22:44 +00:00
|
|
|
|
if (ItemContainer == null) return;
|
|
|
|
|
foreach (var itemSlot in ItemContainer)
|
2024-06-13 03:04:51 +00:00
|
|
|
|
{
|
|
|
|
|
itemSlot.ClearSlot();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QueueFree();
|
|
|
|
|
}
|
2024-06-12 15:42:35 +00:00
|
|
|
|
|
2024-06-13 05:53:10 +00:00
|
|
|
|
public bool CanStackWith(IItem item) => false;
|
|
|
|
|
|
2024-06-14 16:14:17 +00:00
|
|
|
|
public IItemStack SpecialStack()
|
2024-06-12 15:42:35 +00:00
|
|
|
|
{
|
2024-06-14 04:22:44 +00:00
|
|
|
|
return new PacksackStack(this);
|
2024-06-12 15:42:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-14 04:22:44 +00:00
|
|
|
|
|
|
|
|
|
public IItemContainer? ItemContainer { get; private set; }
|
|
|
|
|
|
|
|
|
|
public override void _Ready()
|
2024-06-12 15:42:35 +00:00
|
|
|
|
{
|
2024-06-14 04:22:44 +00:00
|
|
|
|
base._Ready();
|
|
|
|
|
ItemContainer = new UniversalItemContainer();
|
2024-06-12 15:42:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|