Files
Hasebe/Assets/Code/OfficeGame/BattleMode/Actions/BattleActionStugger.cs
T
2026-10-26 19:06:01 +03:00

61 lines
1.8 KiB
C#

using System.Linq;
using Code.Infrastructure.Utils;
using Code.OfficeGame.BattleMode.HitBoxes;
using Cysharp.Threading.Tasks;
using Reflex.Attributes;
using UnityEngine;
namespace Code.OfficeGame.BattleMode.Actions
{
public class BattleActionStugger : BattleAction
{
private Animator _animator;
private EntityHitBoxes _entityHitBoxes;
private int EntryStateHash => Animator.StringToHash("WalkBlend");
private int StuggerStateHash => Animator.StringToHash("Stugger");
private BattleActionParameters _actionParameters;
private int _currentFrame;
[Inject]
public void Construct(MultipleConfig<BattleActionParameters> actionData)
{
_animator = GetComponentInChildren<Animator>();
_entityHitBoxes = GetComponent<EntityHitBoxes>();
_actionParameters = actionData.Configs.SingleOrDefault(x => x.ActionType == ActionType);
}
public override async UniTask<BattleActionDecisionResultCode> DecideAction()
{
_currentFrame = 0;
Finished = false;
return BattleActionDecisionResultCode.Decided;
}
public override BattleActionType ActionType => BattleActionType.Stugger;
public override void Tick(float tickDelta)
{
if (Finished) return;
if (_currentFrame == 0)
{
_animator.Play(StuggerStateHash, 0, 0f);
}
_currentFrame++;
if (_currentFrame >= _actionParameters.TotalFrames)
{
CompleteOrInterruptAction();
}
}
public void CompleteOrInterruptAction()
{
_animator.Play(EntryStateHash, 0, 0f); // Создать None State и кинуть эту штуку туда
Finished = true;
}
}
}