Traveller/scripts/item/Packsack.cs

50 lines
1.2 KiB
C#
Raw Normal View History

2024-06-13 06:18:11 +00:00
using ColdMint.scripts.inventory;
using ColdMint.scripts.pickable;
using ColdMint.scripts.utils;
using Godot;
2024-06-13 06:18:11 +00:00
namespace ColdMint.scripts.item;
/// <summary>
/// <para>packsack</para>
/// <para>背包</para>
/// </summary>
public partial class Packsack : PickAbleTemplate
{
private PackedScene? _packedScene;
private PacksackUi? _packsackUi;
2024-06-13 03:04:51 +00:00
public override void Destroy()
2024-06-13 03:04:51 +00:00
{
if (ItemContainer == null) return;
foreach (var itemSlot in ItemContainer)
2024-06-13 03:04:51 +00:00
{
itemSlot.ClearSlot();
}
QueueFree();
}
public override void Use(Node2D? owner, Vector2 targetGlobalPosition)
{
if (_packedScene == null)
{
return;
}
if (_packsackUi == null)
{
_packsackUi = NodeUtils.InstantiatePackedScene<PacksackUi>(_packedScene,this);
}
_packsackUi?.Show();
}
public IItemContainer? ItemContainer { get; private set; }
public override void _Ready()
{
base._Ready();
ItemContainer = new UniversalItemContainer();
_packedScene = GD.Load<PackedScene>("res://prefab/ui/packsackUI.tscn");
}
}