cirnogodot/Scripts/Actors/VendingMachine.cs
2025-06-25 15:36:50 +02:00

41 lines
No EOL
905 B
C#

using System.Linq;
using Cirno.Scripts.Resources;
using Cirno.Scripts.UI;
using Cirno.Scripts.Utils;
using Godot;
using Godot.Collections;
namespace Cirno.Scripts.Actors;
public partial class VendingMachine : Interactable
{
[Export] public bool Infinite { get; private set; } = false;
[Export] public PackedScene UiScene { get; private set; }
[Export] public Array<LootItem> Items { get; set; }
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
{
GameStateManager.SetState(GameState.Shop);
var ui = UiScene.Instantiate<VendingMachineUi>();
ui.Machine = this;
ui.Items = new LootItem[3];
int i = 0;
foreach (var item in Items)
{
ui.Items[i] = item;
i++;
}
this.AddChild(ui);
return true;
}
}