62 lines
2.4 KiB
C#
62 lines
2.4 KiB
C#
using System.Threading;
|
|
using Code.Game.OfficeGame.BattleMode;
|
|
using Code.Infrastructure.Camera;
|
|
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;
|
|
[Inject] private CameraStateMachine _cameraStateMachine;
|
|
|
|
public override async UniTask DecideAction(CancellationToken ctx)
|
|
{
|
|
_battleActionDecisionPanel.SetEntityInfo(BattleActions);
|
|
|
|
BattleActionType decidedAction = BattleActionType.None;
|
|
|
|
BattleActionDecisionResult decision = new();
|
|
|
|
while (decidedAction == BattleActionType.None || ctx.IsCancellationRequested)
|
|
{
|
|
Cursor.lockState = CursorLockMode.Confined;
|
|
|
|
((CameraBattleModeState)_cameraStateMachine.CurrentBaseState).battleDeciding = true;
|
|
|
|
await _battleActionDecisionPanel.Open(ctx);
|
|
|
|
decidedAction = await _battleActionDecisionPanel.GetDecision(ctx);
|
|
|
|
while (decidedAction != BattleActionType.None
|
|
&& !ctx.IsCancellationRequested)
|
|
{
|
|
Cursor.lockState = CursorLockMode.Locked;
|
|
|
|
((CameraBattleModeState)_cameraStateMachine.CurrentBaseState).battleDeciding = false;
|
|
|
|
await _battleActionDecisionPanel.Close(ctx);
|
|
|
|
decision = await BattleActions[decidedAction].DecideAction();
|
|
|
|
if (decision.ResultCode == BattleActionDecisionResultCode.CancelDecision)
|
|
decidedAction = BattleActionType.None;
|
|
|
|
if (decision.ResultCode != BattleActionDecisionResultCode.Deciding)
|
|
break;
|
|
}
|
|
}
|
|
|
|
SetCurrentAction(BattleActions[decidedAction], decision.FrameDuration);
|
|
}
|
|
|
|
public override async UniTaskVoid ForceDecideAction(BattleActionType actionType)
|
|
{
|
|
var decision = await CurrentAction.DecideAction();
|
|
SetCurrentAction(BattleActions[actionType], decision.FrameDuration);
|
|
}
|
|
}
|
|
} |