HoloCop in progress

This commit is contained in:
ThomasCharester committed 2026-10-28 14:02:58 +03:00
1 parent 2697212f05
commit 430b250075
79 files changed
+120745 -45077

No files matched your search

@@ -1,35 +1,77 @@
using System.Linq;
using System.Threading;
using Code.Infrastructure.Input;
using Code.Infrastructure.Utils;
using Code.OfficeGame.BattleMode.Actions.HoloCopy;
using Code.OfficeGame.BattleMode.HitBoxes;
using Cysharp.Threading.Tasks;
using Reflex.Attributes;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Serialization;
namespace Code.OfficeGame.BattleMode.Actions.Attacks
{
public class BattleActionPlayerAttackMMA : BattleAction
{
private Animator _animator;
[SerializeField] private HoloCop holoCop;
[SerializeField] private Animator animator;
private EntityHitBoxes _entityHitBoxes;
private AttackActionConfig _attackData;
public int EntryStateHash => Animator.StringToHash("WalkBlend");
private int _currentFrame;
private IInputService _inputService;
private CancellationTokenSource _waitForEnterTokenSource;
private BattleActionDecisionResultCode _decisionResultCode;
[Inject]
public void Construct(MultipleConfig<BattleActionParameters> attackData)
public void Construct(MultipleConfig<BattleActionParameters> attackData, IInputService inputService)
{
_animator = GetComponentInChildren<Animator>();
_inputService = inputService;
_entityHitBoxes = GetComponent<EntityHitBoxes>();
_attackData = (AttackActionConfig) attackData.Configs.SingleOrDefault(x=>x.ActionType == ActionType);
}
public override async UniTask<BattleActionDecisionResult> DecideAction()
{
_currentFrame = 0;
Finished = false;
_waitForEnterTokenSource = new CancellationTokenSource();
_decisionResultCode = BattleActionDecisionResultCode.CancelDecision;
_inputService.BindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Confirm,
ConfirmAttack);
_inputService.BindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Cancel,
CancelAttack);
return new() { ResultCode = BattleActionDecisionResultCode.Decided, FrameDuration = _attackData.TotalFrames};
holoCop.Simulate(TickHoloCopy, _waitForEnterTokenSource.Token).Forget();
await UniTask.WaitUntilCanceled(_waitForEnterTokenSource.Token).SuppressCancellationThrow();
_inputService.UnbindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Confirm,
ConfirmAttack);
_inputService.UnbindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Cancel,
CancelAttack);
_currentFrame = 0;
return new() { ResultCode = _decisionResultCode, FrameDuration = _attackData.TotalFrames};
}
private void CancelAttack(InputAction.CallbackContext obj)
{
_decisionResultCode = BattleActionDecisionResultCode.CancelDecision;
_waitForEnterTokenSource?.Cancel();
}
private void ConfirmAttack(InputAction.CallbackContext obj)
{
_decisionResultCode = BattleActionDecisionResultCode.Decided;
_waitForEnterTokenSource?.Cancel();
}
public override BattleActionType ActionType => BattleActionType.PlayerAttackMMA;
@@ -40,7 +82,7 @@ namespace Code.OfficeGame.BattleMode.Actions.Attacks
if (_currentFrame == 0)
{
_animator.Play(_attackData.StateHash, 0, 0f);
animator.Play(_attackData.StateHash, 0, 0f);
}
_currentFrame++;
@@ -70,9 +112,23 @@ namespace Code.OfficeGame.BattleMode.Actions.Attacks
public void CompleteOrInterruptAction()
{
_animator.Play(EntryStateHash, 0, 0f); // Создать None State и кинуть эту штуку туда
animator.Play(EntryStateHash, 0, 0f); // Создать None State и кинуть эту штуку туда
_entityHitBoxes.DisableAllHitboxes();
Finished = true;
}
// HoloCopy
private bool TickHoloCopy(HoloCop holoCop, float tickDelta)
{
if (_currentFrame == 0)
{
holoCop.Animator.Play(_attackData.StateHash, 0, 0f);
}
_currentFrame++;
return _currentFrame >= _attackData.TotalFrames;
}
}
}