Files
Hasebe/Assets/Code/OfficeGame/BattleMode/Actions/Player/PlayerTimelineActor.cs
T
2026-10-23 16:15:02 +03:00

63 lines
2.2 KiB
C#

using System.Threading;
using Code.Game.Gameplay.Player;
using Code.Infrastructure.Camera;
using Code.Infrastructure.Input;
using Code.OfficeGame.BattleMode.UI;
using Cysharp.Threading.Tasks;
using Reflex.Attributes;
using UnityEngine;
namespace Code.OfficeGame.BattleMode.Actions.Player
{
public class PlayerTimelineActor : EntityTimelineActor
{
[Inject] private BattleActionDecisionPanel _battleActionDecisionPanel;
[Inject]
private void Construct(
CameraStateMachine cameraStateMachine,
IInputService inputService,
PlayerMovementController playerMovementController)
{
BattleActions.Add(BattleActionType.Wait, new BattleActionWait());
BattleActions.Add(BattleActionType.Move,
new BattleActionMove(cameraStateMachine, inputService, playerMovementController));
}
public override async UniTask DecideAction(CancellationToken ctx)
{
BattleActionDecisionResultCode decision = BattleActionDecisionResultCode.Deciding;
_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);
while (decidedAction != BattleActionType.None
&& decision == BattleActionDecisionResultCode.Deciding
&& !ctx.IsCancellationRequested)
{
Cursor.lockState = CursorLockMode.Locked;
await _battleActionDecisionPanel.Close(ctx);
// Панель UI здесь
decision = await BattleActions[decidedAction].DecideAction();
if (decision == BattleActionDecisionResultCode.CancelDecision)
decidedAction = BattleActionType.None;
}
}
CurrentAction = BattleActions[decidedAction];
}
}
}