cirnogodot/Scripts/Actors/VendingMachine.cs

41 lines
905 B
C#
Raw Normal View History

2025-04-25 11:29:21 +02:00
using System.Linq;
using Cirno.Scripts.Resources;
using Cirno.Scripts.UI;
using Cirno.Scripts.Utils;
2025-04-25 11:29:21 +02:00
using Godot;
using Godot.Collections;
namespace Cirno.Scripts.Actors;
public partial class VendingMachine : Interactable
{
[Export] public bool Infinite { get; private set; } = false;
2025-04-25 11:29:21 +02:00
[Export] public PackedScene UiScene { get; private set; }
[Export] public Array<LootItem> Items { get; set; }
2025-04-25 11:29:21 +02:00
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
{
GameStateManager.SetState(GameState.Shop);
2025-04-25 11:29:21 +02:00
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++;
}
2025-04-25 11:29:21 +02:00
this.AddChild(ui);
return true;
}
}