TimelineImprovements

This commit is contained in:
ThomasCharester committed 2026-11-20 14:28:56 +03:00
1 parent e312131725
commit f927552adc
2211 files changed
+115416 -540944

No files matched your search

@@ -6,9 +6,10 @@ namespace Code.OfficeGame.BattleMode.Actions.AI
{
public abstract class EnemyDecider
{
public abstract UniTask<(BattleActionDecisionResult decisionResult, BattleActionData actionData)>
DecideEnemy(CancellationToken ctx, EntityProperties entity, Dictionary<BattleActionType, BattleAction> battleActions);
public abstract EnemyDeciderTypes EnemyDeciderType { get; }
public abstract (BattleActionDecisionResult decisionResult, BattleActionData actionData)
DecideEnemy(EntityProperties entity,
IReadOnlyDictionary<BattleActionType, BattleAction> battleActions);
}
}
@@ -14,13 +14,12 @@ namespace Code.OfficeGame.BattleMode.Actions.AI.EnemyDeciders
_player = player;
}
public override async UniTask<(BattleActionDecisionResult decisionResult, BattleActionData actionData)> DecideEnemy(
CancellationToken ctx,
public override (BattleActionDecisionResult decisionResult,
BattleActionData actionData)
DecideEnemy(
EntityProperties entity,
Dictionary<BattleActionType,BattleAction> battleActions)
IReadOnlyDictionary<BattleActionType, BattleAction> battleActions)
{
await UniTask.Yield();
var entityPosition = entity.transform.position;
var playerPosition = _player.transform.position;
@@ -1,4 +1,4 @@
using Code.Infrastructure.Utils;
using System;
using Code.OfficeGame.BattleMode.Actions.Deciders;
using Code.OfficeGame.BattleMode.Timeline;
using UnityEngine;
@@ -14,7 +14,8 @@ namespace Code.OfficeGame.BattleMode.Actions
BattleActionDecisionResult battleActionDecisionResult,
BattleActionData battleActionData)
{
if (battleActionData is not WaitBattleActionData waitActionData)
if (battleActionData is not WaitBattleActionData waitActionData
|| battleActionDecisionResult is not CountBattleActionDeciderResult countResult)
{
battleActionData.Finished = true;
return;
@@ -30,14 +31,12 @@ namespace Code.OfficeGame.BattleMode.Actions
entityAnimator.CrossFadeInFixedTime(EntryStateHash, transitionDurationSeconds);
// entityAnimator.Play(EntryStateHash, 0, 0f); // Создать None State и кинуть эту штуку туда
// entityAnimator.Update(0f);
// TODO С нормальными анимациями не нужен будет рут моушен√
entityAnimator.ResetAnimatorPosition();
// entityAnimator.ResetAnimatorPosition();
}
waitActionData.WaitFrames--;
if (waitActionData.WaitFrames <= 0)
{
battleActionData.Finished = true;
@@ -45,12 +44,14 @@ namespace Code.OfficeGame.BattleMode.Actions
}
public override BattleActionType ActionType => BattleActionType.Wait;
public override DeciderType DeciderType => DeciderType.AsIs;
public override DeciderType DeciderType => DeciderType.Count;
public override BattleActionData MountAndGetFrames(EntityProperties entity, BattleActionDecisionResult result)
{
if (result is not CountBattleActionDeciderResult countResult) throw new Exception("Wrong Decider Result");
WaitBattleActionData actionData = new()
{
WaitFrames = 120
WaitFrames = countResult.Count
};
return actionData;
@@ -58,7 +59,15 @@ namespace Code.OfficeGame.BattleMode.Actions
public override void Finish(EntityProperties entity, BattleActionData actionData, BattleActionDecisionResult result)
{
if (actionData is not WaitBattleActionData waitActionData
|| result is not CountBattleActionDeciderResult countResult)
{
actionData.Finished = true;
return;
}
actionData.Finished = true;
waitActionData.WaitFrames = 0;
}
}
}
@@ -15,10 +15,10 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
};
}
public override void UnmountDecider()
{ }
public override UniTask UnmountDecider()
{ return UniTask.CompletedTask; }
public override void MountDecider(EntityProperties entityProperties)
{ }
public override UniTask MountDecider(EntityProperties entityProperties)
{ return UniTask.CompletedTask; }
}
}
@@ -8,8 +8,8 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
protected bool IsMounted;
public abstract UniTask<BattleActionDecisionResult> GetDecision();
public abstract void UnmountDecider();
public abstract UniTask UnmountDecider();
public abstract void MountDecider(EntityProperties entityProperties);
public abstract UniTask MountDecider(EntityProperties entityProperties);
}
}
@@ -63,15 +63,15 @@ namespace Code.OfficeGame.BattleMode.Actions
ResultCode = deciderResult.ResultCode;
}
}
public class FrameBattleActionDeciderResult : BattleActionDecisionResult
public class CountBattleActionDeciderResult : BattleActionDecisionResult
{
public int FrameCount;
public int Count;
public override BattleActionDecisionResult GetSnapshot()
{
var snapshot = new FrameBattleActionDeciderResult
var snapshot = new CountBattleActionDeciderResult
{
FrameCount = FrameCount,
Count = Count,
ActionType = ActionType,
ResultCode = ResultCode
};
@@ -80,11 +80,11 @@ namespace Code.OfficeGame.BattleMode.Actions
public override void RestoreSnapshot(BattleActionDecisionResult snapshot)
{
if (snapshot is not FrameBattleActionDeciderResult) return;
if (snapshot is not CountBattleActionDeciderResult) return;
var deciderResult = (FrameBattleActionDeciderResult)snapshot;
var deciderResult = (CountBattleActionDeciderResult)snapshot;
FrameCount = deciderResult.FrameCount;
Count = deciderResult.Count;
ActionType = deciderResult.ActionType;
ResultCode = deciderResult.ResultCode;
}
@@ -57,9 +57,9 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
};
}
public override void UnmountDecider()
public override UniTask UnmountDecider()
{
if (!IsMounted) return;
if (!IsMounted) return UniTask.CompletedTask;
_playerDecisionMarker.Toggle(false);
_markerManager.ReleaseMarkerInstance(_playerDecisionMarker);
@@ -79,6 +79,8 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
MarkPosition);
IsMounted = false;
return UniTask.CompletedTask;
}
private bool _rotationChanging = false;
@@ -91,9 +93,9 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
_rotationChanging = false;
}
public override void MountDecider(EntityProperties entityProperties)
public override UniTask MountDecider(EntityProperties entityProperties)
{
if (IsMounted) return;
if (IsMounted) return UniTask.CompletedTask;
_inputService.BindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.RightClick,
ActivateRotationChange);
@@ -115,6 +117,8 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
_targetRotation = Quaternion.identity;
IsMounted = true;
return UniTask.CompletedTask;
}
private MarkerManager _markerManager;
@@ -0,0 +1,108 @@
using System;
using System.Threading;
using Code.Infrastructure.Input;
using Code.OfficeGame.BattleMode.Actions.UI;
using Cysharp.Threading.Tasks;
using R3;
using UnityEngine.InputSystem;
namespace Code.OfficeGame.BattleMode.Actions.Deciders
{
public class CountBattleActionDecider : BattleActionDecider
{
private WaitActionCountSelectorPanel _countSelectorPanel;
public override DeciderType DeciderType => DeciderType.Count;
private int _decidedCount;
private BattleActionDecisionResultCode _resultCode;
private CancellationTokenSource _waitForEnterTokenSource = new();
private IDisposable _sliderDisposable;
private IInputService _inputService;
public CountBattleActionDecider(WaitActionCountSelectorPanel countSelectorPanel, IInputService inputService)
{
_inputService = inputService;
_countSelectorPanel = countSelectorPanel;
}
public override async UniTask<BattleActionDecisionResult> GetDecision()
{
if (!IsMounted) throw new Exception("Decider is not mounted");
_waitForEnterTokenSource = new CancellationTokenSource();
_resultCode = BattleActionDecisionResultCode.Deciding;
_countSelectorPanel.CountSlider.enabled = true;
await UniTask.WaitUntilCanceled(_waitForEnterTokenSource.Token).SuppressCancellationThrow();
_countSelectorPanel.CountSlider.enabled = false;
_waitForEnterTokenSource.Dispose();
_waitForEnterTokenSource = null;
return new CountBattleActionDeciderResult()
{
Count = _decidedCount,
ResultCode = _resultCode
};
}
private void Cancel(InputAction.CallbackContext obj)
{
_resultCode = BattleActionDecisionResultCode.CancelDecision;
_waitForEnterTokenSource.Cancel();
}
private void Confirm(InputAction.CallbackContext obj)
{
_resultCode = BattleActionDecisionResultCode.Decided;
_waitForEnterTokenSource.Cancel();
}
public override async UniTask UnmountDecider()
{
if (!IsMounted) return;
_inputService.UnbindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Confirm,
Confirm);
_inputService.UnbindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Cancel,
Cancel);
_sliderDisposable.Dispose();
await _countSelectorPanel.Close();
IsMounted = false;
}
public override async UniTask MountDecider(EntityProperties entityProperties)
{
if (IsMounted) return;
_inputService.BindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Confirm,
Confirm);
_inputService.BindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Cancel,
Cancel);
_decidedCount = 0;
await _countSelectorPanel.Open();
_countSelectorPanel.SetRange(1, 150);
_sliderDisposable = _countSelectorPanel.CountSlider.OnValueChangedAsObservable()
.Subscribe(val =>
{
// if (_suppressSliderCallback) return;
_decidedCount = (int)val;
_waitForEnterTokenSource.Cancel();
});
IsMounted = true;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3a6bb15289ef4ab1a8e2b62e883b988b
timeCreated: 1795128743
@@ -4,6 +4,7 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
{
AsIs,
Position,
Rotation
Rotation,
Count
}
}
@@ -57,9 +57,9 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
};
}
public override void UnmountDecider()
public override UniTask UnmountDecider()
{
if (!IsMounted) return;
if (!IsMounted) return UniTask.CompletedTask;
_playerDecisionMarker.Toggle(false);
_markerManager.ReleaseMarkerInstance(_playerDecisionMarker);
@@ -76,11 +76,13 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
MarkPosition);
IsMounted = false;
return UniTask.CompletedTask;
}
public override void MountDecider(EntityProperties entityProperties)
public override UniTask MountDecider(EntityProperties entityProperties)
{
if (IsMounted) return;
if (IsMounted) return UniTask.CompletedTask;
_inputService.BindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Select,
SelectRotation);
@@ -101,6 +103,8 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
_entityPosition = entityProperties.KinematicCharacterMotor.TransientPosition;
IsMounted = true;
return UniTask.CompletedTask;
}
private MarkerManager _markerManager;
@@ -98,7 +98,8 @@ namespace Code.OfficeGame.BattleMode.Actions
/// <summary>
/// Полное детерминированное восстановление для старта/перезапекания физической симуляции.
/// </summary>
public static void RestoreForSimulation(EntityProperties entity, Transform[] cachedBones, in EntitySnapshot snapshot)
public static void RestoreForSimulation(EntityProperties entity, Transform[] cachedBones,
in EntitySnapshot snapshot)
{
var motor = entity.KinematicCharacterMotor;
var moveCtrl = entity.MovementController;
@@ -220,6 +221,7 @@ namespace Code.OfficeGame.BattleMode.Actions
case AnimatorControllerParameterType.Bool:
case AnimatorControllerParameterType.Trigger: pSnap.BoolValue = animator.GetBool(hash); break;
}
_parameters[i] = pSnap;
}
}
@@ -228,7 +230,9 @@ namespace Code.OfficeGame.BattleMode.Actions
{
if (targetAnimator == null || _layers == null) return;
targetAnimator.applyRootMotion = false;
// 1. ВАЖНО: включаем исходный режим RootMotion ДО перемотки,
// чтобы Mecanim вычислял позу и внутренний курсор корня в правильном режиме!
targetAnimator.applyRootMotion = _applyRootMotion;
targetAnimator.speed = _speed;
if (_parameters != null)
@@ -240,9 +244,12 @@ namespace Code.OfficeGame.BattleMode.Actions
switch (p.Type)
{
case AnimatorControllerParameterType.Float: targetAnimator.SetFloat(p.NameHash, p.FloatValue); break;
case AnimatorControllerParameterType.Int: targetAnimator.SetInteger(p.NameHash, p.IntValue); break;
case AnimatorControllerParameterType.Bool: targetAnimator.SetBool(p.NameHash, p.BoolValue); break;
case AnimatorControllerParameterType.Float:
targetAnimator.SetFloat(p.NameHash, p.FloatValue); break;
case AnimatorControllerParameterType.Int:
targetAnimator.SetInteger(p.NameHash, p.IntValue); break;
case AnimatorControllerParameterType.Bool:
targetAnimator.SetBool(p.NameHash, p.BoolValue); break;
case AnimatorControllerParameterType.Trigger:
if (p.BoolValue) targetAnimator.SetTrigger(p.NameHash);
else targetAnimator.ResetTrigger(p.NameHash);
@@ -251,7 +258,9 @@ namespace Code.OfficeGame.BattleMode.Actions
}
}
const float warmupEpsilon = 0.0001f;
int layerCount = Mathf.Min(_layers.Length, targetAnimator.layerCount);
for (int i = 0; i < layerCount; i++)
{
var layer = _layers[i];
@@ -259,15 +268,22 @@ namespace Code.OfficeGame.BattleMode.Actions
if (!layer.IsInTransition || layer.NextFullPathHash == 0)
{
float timeInSeconds = Mathf.Max(0f, layer.NormalizedTime * layer.StateLength);
targetAnimator.CrossFadeInFixedTime(layer.FullPathHash, 0f, i, timeInSeconds);
float targetSeconds = Mathf.Max(0f, layer.NormalizedTime * layer.StateLength);
float preSeconds = Mathf.Max(0f, targetSeconds - warmupEpsilon);
float dt = targetSeconds - preSeconds;
targetAnimator.CrossFadeInFixedTime(layer.FullPathHash, 0f, i, preSeconds);
targetAnimator.Update(0f);
// Ненулевой микрошаг прогревает m_PrevRootPosition ровно до targetSeconds!
if (dt > 0f)
targetAnimator.Update(dt);
}
else
{
// Защита от отрицательного времени (фикс бага старого AnimatorSnapshot)
float startSecondsA = Mathf.Max(0f, (layer.NormalizedTime * layer.StateLength) - layer.ElapsedTransitionTime);
float startSecondsB = Mathf.Max(0f, (layer.NextNormalizedTime * layer.NextStateLength) - layer.ElapsedTransitionTime);
float elapsed = Mathf.Max(warmupEpsilon, layer.ElapsedTransitionTime);
float startSecondsA = Mathf.Max(0f, (layer.NormalizedTime * layer.StateLength) - elapsed);
float startSecondsB = Mathf.Max(0f, (layer.NextNormalizedTime * layer.NextStateLength) - elapsed);
targetAnimator.CrossFadeInFixedTime(layer.FullPathHash, 0f, i, startSecondsA);
targetAnimator.Update(0f);
@@ -278,14 +294,15 @@ namespace Code.OfficeGame.BattleMode.Actions
i,
startSecondsB);
targetAnimator.Update(layer.ElapsedTransitionTime);
targetAnimator.Update(elapsed);
}
}
// 2. Отбрасываем любое смещение, которое произошло во время прогрева,
// сохраняя родной локальный оффсет модели
Transform targetTransform = targetAnimator.transform;
targetTransform.localPosition = _localPosition;
targetTransform.localRotation = _localRotation;
targetAnimator.applyRootMotion = _applyRootMotion;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7dd8e44f5657473c8702ed72998267d2
timeCreated: 1795128177
@@ -0,0 +1,77 @@
using System;
using System.Threading;
using Code.Infrastructure.UI;
using Cysharp.Threading.Tasks;
using LitMotion;
using LitMotion.Extensions;
using R3;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace Code.OfficeGame.BattleMode.Actions.UI
{
public class WaitActionCountSelectorPanel : UIPanel
{
[SerializeField] private float duration;
[SerializeField] private Slider countSlider;
[SerializeField] private TMP_Text countText;
public Slider CountSlider => countSlider;
private MotionHandle _motionHandle;
private IDisposable _sliderCounter;
public void SetRange(int min, int max)
{
countSlider.minValue = min;
countSlider.maxValue = max;
}
private void Awake()
{
countSlider.wholeNumbers = true;
_sliderCounter = countSlider.OnValueChangedAsObservable()
.Subscribe(value =>
{
countText.SetText(value.ToString());
});
}
private void OnDestroy()
{
_sliderCounter.Dispose();
}
public override async UniTask Open(CancellationToken cts = default)
{
gameObject.SetActive(true);
float startY = -((RectTransform)transform).rect.height;
_motionHandle = LMotion.Create(startY, 0f, duration)
.WithEase(Ease.OutCubic)
.WithScheduler(MotionScheduler.UpdateIgnoreTimeScale)
.BindToAnchoredPositionY((RectTransform)transform);
await _motionHandle.ToUniTask(cts);
}
public override async UniTask Close(CancellationToken cts = default)
{
float targetY = ((RectTransform)transform).rect.height;
_motionHandle = LMotion.Create(0f, targetY, duration)
.WithEase(Ease.InBack)
.WithScheduler(MotionScheduler.UpdateIgnoreTimeScale)
.BindToAnchoredPositionY((RectTransform)transform);
await _motionHandle.ToUniTask(cts);
gameObject.SetActive(false);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 91ac8575fc0f42faaad845dd9f30f1f4
timeCreated: 1795128198
@@ -17,6 +17,8 @@ using Code.OfficeGame.BattleMode.Actions.AI.EnemyDeciders;
using Code.OfficeGame.BattleMode.Actions.Attacks;
using Code.OfficeGame.BattleMode.Actions.Deciders;
using Code.OfficeGame.BattleMode.Actions.Player;
using Code.OfficeGame.BattleMode.Actions.UI;
using Code.OfficeGame.BattleMode.CursorControl;
using Code.OfficeGame.BattleMode.Health;
using Code.OfficeGame.BattleMode.Marker;
using Code.OfficeGame.BattleMode.Timeline;
@@ -94,6 +96,10 @@ namespace Code.Game.OfficeGame.GameStates
BattleTimelinePanel battleTimelinePanel =
(BattleTimelinePanel)await Context.UIFactory
.LoadPanel(UIPanelType.BattleTimeline, false);
WaitActionCountSelectorPanel waitActionCountSelectorPanel =
(WaitActionCountSelectorPanel)await Context.UIFactory
.LoadPanel(UIPanelType.WaitActionFrameCountSelector, false);
var healthBarHolder = new HealthPanelsHolder();
@@ -108,6 +114,7 @@ namespace Code.Game.OfficeGame.GameStates
builder.RegisterType(typeof(MarkerManager), Lifetime.Singleton, Resolution.Eager);
builder.RegisterValue(waitActionCountSelectorPanel);
builder.RegisterValue(battleActionDecisionPanel);
builder.RegisterValue(battleTimelinePanel);
@@ -121,10 +128,12 @@ namespace Code.Game.OfficeGame.GameStates
builder.RegisterType(typeof(BattleActionPositionDecider), new[]{ typeof(BattleActionDecider) } , Lifetime.Singleton, Resolution.Eager);
builder.RegisterType(typeof(RotationBattleActionDecider), new[]{ typeof(BattleActionDecider) } , Lifetime.Singleton, Resolution.Eager);
builder.RegisterType(typeof(CountBattleActionDecider), new[]{ typeof(BattleActionDecider) } , Lifetime.Singleton, Resolution.Eager);
builder.RegisterType(typeof(AsIsBattleActionDecider), new[]{ typeof(BattleActionDecider) } , Lifetime.Singleton, Resolution.Eager);
builder.RegisterType(typeof(FrankAttackDecider), new[]{ typeof(EnemyDecider) } , Lifetime.Singleton, Resolution.Eager);
builder.RegisterType(typeof(BattleModeCursorController), Lifetime.Singleton, Resolution.Eager);
builder.RegisterType(typeof(BattleTimeline), Lifetime.Singleton, Resolution.Eager);
}
@@ -126,7 +126,7 @@ namespace Code.Game.OfficeGame.BattleMode
var camTransform = Context.cameraLoadedData.Camera.transform;
float dt = Time.unscaledDeltaTime;
if (!(battleDeciding && !_rightClickHold))
if (!_rightClickHold)
{
_rotation.x += _mouseDelta.x * _sensitivityX;
_rotation.y -= _mouseDelta.y * _sensitivityY;
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 315a65c69e4943ad9bbfa7ab0a2ac497
timeCreated: 1795127866
@@ -0,0 +1,36 @@
using System;
using Code.Infrastructure.Input;
using UnityEngine;
using UnityEngine.InputSystem;
namespace Code.OfficeGame.BattleMode.CursorControl
{
public class BattleModeCursorController : IDisposable
{
private IInputService _inputService;
public BattleModeCursorController(IInputService inputService)
{
_inputService = inputService;
_inputService.BindActionPerformed((int) ActionMappings.BattleMode, (int) BattleModeActions.RightClick, EnableCursor);
_inputService.BindActionCancelled((int) ActionMappings.BattleMode, (int) BattleModeActions.RightClick, DisableCursor);
}
private void EnableCursor(InputAction.CallbackContext obj)
{
Cursor.lockState = CursorLockMode.Confined;
}
private void DisableCursor(InputAction.CallbackContext obj)
{
Cursor.lockState = CursorLockMode.Locked;
}
public void Dispose()
{
_inputService.UnbindActionPerformed((int) ActionMappings.BattleMode, (int) BattleModeActions.RightClick, EnableCursor);
_inputService.UnbindActionCancelled((int) ActionMappings.BattleMode, (int) BattleModeActions.RightClick, DisableCursor);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5473936e5f6c422383965fe6dc71c645
timeCreated: 1795127908
@@ -267,16 +267,40 @@ namespace Code.OfficeGame.BattleMode.Timeline
KinematicCharacterSystem.CharacterMotors,
KinematicCharacterSystem.PhysicsMovers);
// ФАЗА 3: Параметры BlendTree ходьбы + шаг аниматоров + RootMotion синхронизация каждый тик
// ФАЗА 3: Параметры ходьбы + шаг аниматоров + чистый дельта-перенос RootMotion
for (int i = 0; i < _entities.Length; i++)
{
var entity = _entities[i];
UpdateAnimatorLocomotionParams(entity);
entity.animator.Update(FixedTickDelta);
if (entity.animator.applyRootMotion)
entity.SyncRootMotionToMotor();
{
Transform animT = entity.animator.transform;
Vector3 savedLocalPos = animT.localPosition;
Quaternion savedLocalRot = animT.localRotation;
Vector3 worldPosBefore = animT.position;
Quaternion worldRotBefore = animT.rotation;
entity.animator.Update(FixedTickDelta);
Vector3 worldDeltaPos = animT.position - worldPosBefore;
Quaternion worldDeltaRot = animT.rotation * Quaternion.Inverse(worldRotBefore);
// Возвращаем модель на её родной локальный оффсет
animT.localPosition = savedLocalPos;
animT.localRotation = savedLocalRot;
var motor = entity.KinematicCharacterMotor;
motor.SetPositionAndRotation(
motor.TransientPosition + worldDeltaPos,
worldDeltaRot * motor.TransientRotation,
bypassInterpolation: true);
motor.BaseVelocity = Vector3.zero;
}
else
{
entity.animator.Update(FixedTickDelta);
}
}
// ФАЗА 4: Единый шаг PhysX и синхронизация костей/хитбоксов ДО проверок
@@ -9,6 +9,7 @@ using Code.Infrastructure.Particles;
using Code.OfficeGame.BattleMode.Actions;
using Code.OfficeGame.BattleMode.Actions.AI;
using Code.OfficeGame.BattleMode.Actions.Deciders;
using Code.OfficeGame.BattleMode.CursorControl;
using Code.OfficeGame.BattleMode.Health;
using Code.OfficeGame.BattleMode.HitBoxes;
using Code.OfficeGame.BattleMode.UI;
@@ -65,8 +66,10 @@ namespace Code.OfficeGame.BattleMode.Timeline
BattleActionDecisionPanel battleActionDecisionPanel,
HealthPanelsHolder healthPanelsHolder,
CameraStateMachine cameraStateMachine,
IParticleService particleService)
IParticleService particleService,
BattleModeCursorController cursorController)
{
_cursorController = cursorController;
_timelinePanel = timelinePanel;
_decisionPanel = battleActionDecisionPanel;
_healthPanelsHolder = healthPanelsHolder;
@@ -135,6 +138,7 @@ namespace Code.OfficeGame.BattleMode.Timeline
// =================== ОСНОВНОЙ ЦИКЛ БОЯ ===================
private CancellationToken _battleLoopCt;
private BattleModeCursorController _cursorController;
public async UniTask RunBattleLoopAsync(List<EntityProperties> entities, CancellationToken ctx)
{
@@ -255,8 +259,8 @@ namespace Code.OfficeGame.BattleMode.Timeline
if (entity.TeamData.Team == EntityTeam.ChaoticEvil)
{
var (enemyRes, enemyData) = await _enemyDeciders[entity.TeamData.DeciderType]
.DecideEnemy(ctx, entity, _battleActions);
var (enemyRes, enemyData) = _enemyDeciders[entity.TeamData.DeciderType]
.DecideEnemy(entity, _battleActions);
return new EntityActionSlotSnapshot
{
@@ -292,7 +296,7 @@ namespace Code.OfficeGame.BattleMode.Timeline
while (!ctx.IsCancellationRequested)
{
Cursor.lockState = CursorLockMode.Confined;
// Cursor.lockState = CursorLockMode.Confined;
if (cameraBattleState != null) cameraBattleState.battleDeciding = true;
await _decisionPanel.Open(ctx);
@@ -306,7 +310,7 @@ namespace Code.OfficeGame.BattleMode.Timeline
_simulator.RestoreSimulationToWorld(Track.GetFrame(_committedFrame.Value));
ApplyFrame(_committedFrame.Value, playOneShotVfx: false);
decider.MountDecider(entity);
await decider.MountDecider(entity);
bool waitingForFirstTarget = true;
try
@@ -316,7 +320,7 @@ namespace Code.OfficeGame.BattleMode.Timeline
// Пока цель ещё не выбрана — курсор залочен под прицеливание камеры.
// Как только цель выбрана (идёт превью) — курсор свободен (Confined),
// чтобы игрок мог двигать ползунок таймлайна (а вращать камеру через ПКМ).
Cursor.lockState = waitingForFirstTarget ? CursorLockMode.Locked : CursorLockMode.Confined;
// Cursor.lockState = waitingForFirstTarget ? CursorLockMode.Locked : CursorLockMode.Confined;
if (cameraBattleState != null) cameraBattleState.battleDeciding = !waitingForFirstTarget;
await _decisionPanel.Close(ctx);
@@ -368,7 +372,7 @@ namespace Code.OfficeGame.BattleMode.Timeline
finally
{
StopPreviewLoop();
decider.UnmountDecider();
await decider.UnmountDecider();
}
}
@@ -0,0 +1,14 @@
using System.Collections.Generic;
using Code.OfficeGame.BattleMode.Actions;
namespace Code.OfficeGame.BattleMode.Timeline
{
public interface IBattleAiResolver
{
bool TryResolveNextAction(
EntityProperties entity,
IReadOnlyDictionary<BattleActionType, BattleAction> actions,
out BattleActionDecisionResult decision,
out BattleActionData actionData);
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8c62bc0c68374905952a26eba8fbba54
timeCreated: 1795174068