mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Automatic box deselection
This commit is contained in:
parent
cc5376e94e
commit
ad985ce1ac
6 changed files with 73 additions and 19 deletions
|
|
@ -8,19 +8,46 @@ public partial class Chest : Interactable
|
|||
{
|
||||
|
||||
[Export] public Array<LootItem> LootTable = new Array<LootItem>();
|
||||
|
||||
[Export] public ChestState State = ChestState.Closed;
|
||||
|
||||
public override void Activate()
|
||||
private AnimatedSprite2D _sprite;
|
||||
|
||||
public override bool Activate()
|
||||
{
|
||||
if (!MeetsRequirements()) return;
|
||||
GD.Print("Attempting to open chest");
|
||||
if (State != ChestState.Closed) return false;
|
||||
if (!MeetsRequirements()) return false;
|
||||
foreach (var item in LootTable)
|
||||
{
|
||||
_inventoryManager.AddItem(item.Item, item.Amount);
|
||||
}
|
||||
|
||||
_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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum ChestState
|
||||
{
|
||||
Closed,
|
||||
Open,
|
||||
Destroyed
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue