cirnogodot/Scripts/Components/Actors/3D/Chest3D.cs
2025-06-23 17:47:58 +02:00

43 lines
No EOL
1 KiB
C#

using Cirno.Scripts.Interactables;
using Cirno.Scripts.Resources;
using Godot;
using Godot.Collections;
namespace Cirno.Scripts.Components.Actors._3D;
public partial class Chest3D : Interactable3D
{
[Export] public Array<LootItem> LootTable = [];
[Export] public ChestState State = ChestState.Closed;
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
{
GD.Print("Attempting to open chest");
if (State != ChestState.Closed) return false;
if (!MeetsRequirements()) return false;
foreach (var item in LootTable)
{
InventoryManager.Instance.AddItem(item);
}
//_sprite.Play("Opening");
State = ChestState.Open;
return true;
}
public override void _Ready()
{
base._Ready();
//_sprite = GetNode<AnimatedSprite2D>("AnimatedSprite2D");
}
public override bool CanActivate()
{
return State == ChestState.Closed;
}
}