You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.5 KiB
35 lines
1.5 KiB
using System.Linq;
|
|
using Godot;
|
|
|
|
namespace Babushka.scripts.CSharp.Common.Fight.UI;
|
|
|
|
public partial class ActionSelectUiSetup : CanvasLayer
|
|
{
|
|
// shortcuts
|
|
private FightWorld.FightHappeningData HappeningData =>
|
|
FightWorld.Instance.fightHappeningData ?? throw new NoFightHappeningException();
|
|
private FightWorld.Fighter CurrentFighter => HappeningData.fighterStack.Current;
|
|
|
|
// references
|
|
[Export] private Button _attackActionButton = null!;
|
|
[Export] private Button _summonActionButton = null!;
|
|
[Export] private Button _talkActionButton = null!;
|
|
[Export] private Button _fleeActionButton = null!;
|
|
|
|
// gets called from a state reaction enter (InputActionSelect)
|
|
public void StateEntered()
|
|
{
|
|
var actions = CurrentFighter.availableActions;
|
|
|
|
_attackActionButton.Visible = actions.Any(a => a.BindToActionButton() == FighterAction.AllyActionButton.Attack);
|
|
_summonActionButton.Visible = actions.Any(a => a.BindToActionButton() == FighterAction.AllyActionButton.Summon);
|
|
_talkActionButton.Visible = actions.Any(a => a.BindToActionButton() == FighterAction.AllyActionButton.Talk);
|
|
_fleeActionButton.Visible = actions.Any(a => a.BindToActionButton() == FighterAction.AllyActionButton.Flee);
|
|
}
|
|
|
|
public void SelectAction(FighterAction.AllyActionButton actionButton)
|
|
{
|
|
var action = CurrentFighter.availableActions.First(a => a.BindToActionButton() == actionButton);
|
|
FightHappening.Instance.ActionSelect(action);
|
|
}
|
|
} |