Lil improvements

This commit is contained in:
ThomasCharester committed 2026-10-31 02:59:29 +03:00
1 parent 31850e77bc
commit d00ce7bb0e
59 files changed
+79385 -23141

No files matched your search

@@ -1,147 +1,81 @@
// using System.Linq;
// using System.Threading;
// using Code.Infrastructure.Input;
// using Code.Infrastructure.Utils;
// using Code.OfficeGame.BattleMode.Actions.Deciders;
// using Code.OfficeGame.BattleMode.Actions.HoloCopy;
// using Code.OfficeGame.BattleMode.HitBoxes;
// using Cysharp.Threading.Tasks;
// using Reflex.Attributes;
// using UnityEngine;
// using UnityEngine.InputSystem;
//
// namespace Code.OfficeGame.BattleMode.Actions.Attacks
// {
// public class BattleActionPlayerAttackMMA : BattleAction
// {
// [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, IInputService inputService)
// {
// _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);
//
// 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;
//
// public override bool Tick(float tickDelta, EntityProperties entity)
// {
// if (Finished) return;
//
// if (_currentFrame == 0)
// {
// // TODO Root Motion не должен быть использован в нормальных анимациях
// animator.applyRootMotion = true;
// animator.Play(_attackData.StateHash, 0, 0f);
// }
//
// _currentFrame++;
//
// if (_currentFrame >= _attackData.HitboxStartFrame && _currentFrame <= _attackData.HitboxEndFrame)
// {
// _entityHitBoxes.CheckHitsForCurrentFrame(OnEnemyHit, HitBoxPartType.LArm);
// }
//
// if (_currentFrame >= _attackData.TotalFrames)
// {
// CompleteOrInterruptAction();
// }
// }
//
// public override DeciderType DeciderType => DeciderType.Position;
//
// private void OnEnemyHit(Collider enemyCollider)
// {
// Debug.Log($"Попадание в {enemyCollider.name} на {_currentFrame}-м кадре! Урон: {_attackData.Damage}");
// var entityActor = enemyCollider.GetComponentInParent<EntityTimelineActor>();
// entityActor.ForceDecideAction(BattleActionType.Stugger);
// }
//
// public void CompleteOrInterruptAction()
// {
// animator.Play(EntryStateHash, 0, 0f); // Создать None State и кинуть эту штуку туда
// animator.Update(0f);
//
// // TODO С нормальными анимациями не нужен будет рут моушен√
// animator.applyRootMotion = false;
// animator.transform.localPosition = Vector3.zero;
// animator.transform.localRotation = Quaternion.identity;
//
// Finished = true;
// }
//
// // HoloCopy
//
// private bool TickHoloCopy(HoloCop holoCop, float tickDelta)
// {
// if (_currentFrame == 0)
// {
// holoCop.Animator.applyRootMotion = true;
// holoCop.Animator.Play(_attackData.StateHash, 0, 0f);
// }
//
// _currentFrame++;
//
// if(_currentFrame >= _attackData.TotalFrames)
// {
// _currentFrame = 0;
// holoCop.Animator.applyRootMotion = false;
// return true;
// }
//
// return false;
// }
// }
// }
using System.Linq;
using Code.Infrastructure.Utils;
using Code.OfficeGame.BattleMode.Actions.Deciders;
using Code.OfficeGame.BattleMode.HitBoxes;
using UnityEngine;
namespace Code.OfficeGame.BattleMode.Actions.Attacks
{
public class BattleActionPlayerAttackMMA : BattleAction
{
private AttackActionConfig _attackData;
public int EntryStateHash => Animator.StringToHash("WalkBlend");
public BattleActionPlayerAttackMMA(MultipleConfig<BattleActionParameters> attackData)
{
_attackData = (AttackActionConfig)
attackData.Configs.SingleOrDefault(x=>x.ActionType == ActionType);
}
public override BattleActionType ActionType => BattleActionType.PlayerAttackMMA;
public override bool Tick(float tickDelta,
EntityProperties entity,
BattleActionDecisionResult battleActionDecisionResult,
BattleActionData battleActionData)
{
if (battleActionData is not AttackBattleActionData actionData) return true;
if (actionData.CurrentFrame == 0)
{
var entityAnimator = entity.animator;
// TODO Root Motion не должен быть использован в нормальных анимациях
entityAnimator.Play(EntryStateHash, 0, 0f); // Создать None State и кинуть эту штуку туда
entityAnimator.Update(0f);
entityAnimator.applyRootMotion = false;
entityAnimator.transform.localPosition = Vector3.zero;
entityAnimator.transform.localRotation = Quaternion.identity;
entityAnimator.applyRootMotion = true;
entityAnimator.Play(_attackData.StateHash, 0, 0f);
}
actionData.CurrentFrame++;
if (actionData.CurrentFrame >= _attackData.HitboxStartFrame
&& actionData.CurrentFrame <= _attackData.HitboxEndFrame)
{
entity.EntityHitBoxes.CheckHitsForCurrentFrame(OnEnemyHit, HitBoxPartType.LArm);
}
if (actionData.CurrentFrame >= _attackData.TotalFrames)
{
var entityAnimator = entity.animator;
entityAnimator.Play(EntryStateHash, 0, 0f); // Создать None State и кинуть эту штуку туда
entityAnimator.Update(0f);
// TODO С нормальными анимациями не нужен будет рут моушен√
entityAnimator.applyRootMotion = false;
entityAnimator.transform.localPosition = Vector3.zero;
entityAnimator.transform.localRotation = Quaternion.identity;
return true;
}
return false;
}
public override DeciderType DeciderType => DeciderType.Position;
public override BattleActionData MountAndGetFrames(EntityProperties entity, BattleActionDecisionResult result)
{
return new AttackBattleActionData() { TotalFrames = _attackData.TotalFrames };
}
private void OnEnemyHit(Collider enemyCollider)
{
Debug.Log($"Попадание в {enemyCollider.name}! Урон: {_attackData.Damage}");
}
}
}