mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 19:15:55 +00:00
Chest contents in trenchbroom
This commit is contained in:
parent
54eefc2961
commit
4cc7a0c004
7 changed files with 509 additions and 452 deletions
|
|
@ -1,19 +1,33 @@
|
|||
using Cirno.Scripts.Interactables;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts.Interactables;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Components.Actors._3D;
|
||||
|
||||
[Tool]
|
||||
public partial class Chest3D : Interactable3D
|
||||
{
|
||||
[Export] public Array<LootItem> LootTable = [];
|
||||
|
||||
[Export] public Array<StringName> LootKeys = [];
|
||||
|
||||
[Export] public ChestState State = ChestState.Closed;
|
||||
|
||||
[Signal] public delegate void OpenChestEventHandler();
|
||||
[Signal] public delegate void CloseChestEventHandler();
|
||||
|
||||
public void _func_godot_apply_properties(Dictionary<string, string> props)
|
||||
{
|
||||
if (props.TryGetValue("items", out var items) && !string.IsNullOrWhiteSpace(items))
|
||||
{
|
||||
var itemsArray = items.Split(',');
|
||||
LootKeys = new Array<StringName>(itemsArray.Select(x => new StringName(x)));
|
||||
}
|
||||
//TargetFunc = props["targetfunc"];
|
||||
//TargetName = props["targetname"];
|
||||
}
|
||||
|
||||
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
GD.Print("Attempting to open chest");
|
||||
|
|
@ -23,6 +37,11 @@ public partial class Chest3D : Interactable3D
|
|||
{
|
||||
InventoryManager.Instance.AddItem(item);
|
||||
}
|
||||
|
||||
foreach (var key in LootKeys)
|
||||
{
|
||||
InventoryManager.Instance.AddItem(key);
|
||||
}
|
||||
|
||||
EmitSignalOpenChest();
|
||||
//_sprite.Play("Opening");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue