51 lines
1.8 KiB
C#
51 lines
1.8 KiB
C#
using System.Threading;
|
|
using Code.OfficeGame.BattleMode.UI;
|
|
using Cysharp.Threading.Tasks;
|
|
using Reflex.Attributes;
|
|
using UnityEngine;
|
|
|
|
namespace Code.OfficeGame.BattleMode.Actions.Player
|
|
{
|
|
public class PlayerControlledTimelineActor : EntityTimelineActor
|
|
{
|
|
[Inject] private BattleActionDecisionPanel _battleActionDecisionPanel;
|
|
|
|
public override async UniTask DecideAction(CancellationToken ctx)
|
|
{
|
|
_battleActionDecisionPanel.SetEntityInfo(BattleActions);
|
|
|
|
BattleActionType decidedAction = BattleActionType.None;
|
|
|
|
while (decidedAction == BattleActionType.None || ctx.IsCancellationRequested)
|
|
{
|
|
Cursor.lockState = CursorLockMode.Confined;
|
|
|
|
await _battleActionDecisionPanel.Open(ctx);
|
|
|
|
decidedAction = await _battleActionDecisionPanel.GetDecision(ctx);
|
|
var decision = BattleActionDecisionResultCode.Deciding;
|
|
|
|
while (decidedAction != BattleActionType.None
|
|
&& decision == BattleActionDecisionResultCode.Deciding
|
|
&& !ctx.IsCancellationRequested)
|
|
{
|
|
Cursor.lockState = CursorLockMode.Locked;
|
|
|
|
await _battleActionDecisionPanel.Close(ctx);
|
|
|
|
decision = await BattleActions[decidedAction].DecideAction();
|
|
|
|
if (decision == BattleActionDecisionResultCode.CancelDecision)
|
|
decidedAction = BattleActionType.None;
|
|
}
|
|
}
|
|
CurrentAction = BattleActions[decidedAction];
|
|
}
|
|
|
|
public override void ForceDecideAction(BattleActionType actionType)
|
|
{
|
|
CurrentAction = BattleActions[actionType];
|
|
CurrentAction.DecideAction();
|
|
}
|
|
}
|
|
} |