mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 02:25:54 +00:00
Chests
This commit is contained in:
parent
04ea9dd191
commit
b89043cd8c
11 changed files with 789 additions and 648 deletions
43
Scripts/Components/Actors/3D/Chest3D.cs
Normal file
43
Scripts/Components/Actors/3D/Chest3D.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
1
Scripts/Components/Actors/3D/Chest3D.cs.uid
Normal file
1
Scripts/Components/Actors/3D/Chest3D.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://fm00gyh0hgmj
|
||||
Loading…
Add table
Add a link
Reference in a new issue