Preview improvements. StillBug

This commit is contained in:
ThomasCharester committed 2026-11-20 15:19:22 +03:00
1 parent f927552adc
commit 3678d039e3
161 files changed
+34002 -61534

No files matched your search

+1 -1
View File
@@ -115,7 +115,6 @@
<Compile Include="Assets/Code/Infrastructure/Audio/AudioService.cs" /> <Compile Include="Assets/Code/Infrastructure/Audio/AudioService.cs" />
<Compile Include="Assets/Code/OfficeGame/BattleMode/Timeline/BattleTimelineModels.cs" /> <Compile Include="Assets/Code/OfficeGame/BattleMode/Timeline/BattleTimelineModels.cs" />
<Compile Include="Assets/Code/OfficeGame/Location/PlayerLocationManager.cs" /> <Compile Include="Assets/Code/OfficeGame/Location/PlayerLocationManager.cs" />
<Compile Include="Assets/Code/OfficeGame/BattleMode/Actions/HoloCopy/HoloCop.cs" />
<Compile Include="Assets/Code/OfficeGame/BattleMode/Actions/Companions/OnMapCompanion.cs" /> <Compile Include="Assets/Code/OfficeGame/BattleMode/Actions/Companions/OnMapCompanion.cs" />
<Compile Include="Assets/KinematicCharacterController/Core/ReadOnlyAttribute.cs" /> <Compile Include="Assets/KinematicCharacterController/Core/ReadOnlyAttribute.cs" />
<Compile Include="Assets/Code/OfficeGame/BattleMode/Actions/Player/PlayerDecisionMarker.cs" /> <Compile Include="Assets/Code/OfficeGame/BattleMode/Actions/Player/PlayerDecisionMarker.cs" />
@@ -131,6 +130,7 @@
<Compile Include="Assets/Code/OfficeGame/Location/LocationSegment.cs" /> <Compile Include="Assets/Code/OfficeGame/Location/LocationSegment.cs" />
<Compile Include="Assets/Code/OfficeGame/Player/Factory/PlayerFactorySettings.cs" /> <Compile Include="Assets/Code/OfficeGame/Player/Factory/PlayerFactorySettings.cs" />
<Compile Include="Assets/Code/OfficeGame/BattleMode/Effects/DefenseEffect.cs" /> <Compile Include="Assets/Code/OfficeGame/BattleMode/Effects/DefenseEffect.cs" />
<Compile Include="Assets/Code/OfficeGame/BattleMode/Timeline/BattleAiResolver.cs" />
<Compile Include="Assets/Code/Infrastructure/Generators/Attributes.cs" /> <Compile Include="Assets/Code/Infrastructure/Generators/Attributes.cs" />
<Compile Include="Assets/Code/OfficeGame/BattleMode/Actions/Deciders/BattleActionPositionDecider.cs" /> <Compile Include="Assets/Code/OfficeGame/BattleMode/Actions/Deciders/BattleActionPositionDecider.cs" />
<Compile Include="Assets/Code/Infrastructure/StateMachine/AbstractStateMachine.cs" /> <Compile Include="Assets/Code/Infrastructure/StateMachine/AbstractStateMachine.cs" />
+1 -2
View File
@@ -115,7 +115,6 @@
<Compile Include="Assets/Code/Infrastructure/Audio/AudioService.cs" /> <Compile Include="Assets/Code/Infrastructure/Audio/AudioService.cs" />
<Compile Include="Assets/Code/OfficeGame/BattleMode/Timeline/BattleTimelineModels.cs" /> <Compile Include="Assets/Code/OfficeGame/BattleMode/Timeline/BattleTimelineModels.cs" />
<Compile Include="Assets/Code/OfficeGame/Location/PlayerLocationManager.cs" /> <Compile Include="Assets/Code/OfficeGame/Location/PlayerLocationManager.cs" />
<Compile Include="Assets/Code/OfficeGame/BattleMode/Actions/HoloCopy/HoloCop.cs" />
<Compile Include="Assets/Code/OfficeGame/BattleMode/Actions/Companions/OnMapCompanion.cs" /> <Compile Include="Assets/Code/OfficeGame/BattleMode/Actions/Companions/OnMapCompanion.cs" />
<Compile Include="Assets/KinematicCharacterController/Core/ReadOnlyAttribute.cs" /> <Compile Include="Assets/KinematicCharacterController/Core/ReadOnlyAttribute.cs" />
<Compile Include="Assets/Code/OfficeGame/BattleMode/Actions/Player/PlayerDecisionMarker.cs" /> <Compile Include="Assets/Code/OfficeGame/BattleMode/Actions/Player/PlayerDecisionMarker.cs" />
@@ -131,6 +130,7 @@
<Compile Include="Assets/Code/OfficeGame/Location/LocationSegment.cs" /> <Compile Include="Assets/Code/OfficeGame/Location/LocationSegment.cs" />
<Compile Include="Assets/Code/OfficeGame/Player/Factory/PlayerFactorySettings.cs" /> <Compile Include="Assets/Code/OfficeGame/Player/Factory/PlayerFactorySettings.cs" />
<Compile Include="Assets/Code/OfficeGame/BattleMode/Effects/DefenseEffect.cs" /> <Compile Include="Assets/Code/OfficeGame/BattleMode/Effects/DefenseEffect.cs" />
<Compile Include="Assets/Code/OfficeGame/BattleMode/Timeline/BattleAiResolver.cs" />
<Compile Include="Assets/Code/Infrastructure/Generators/Attributes.cs" /> <Compile Include="Assets/Code/Infrastructure/Generators/Attributes.cs" />
<Compile Include="Assets/Code/OfficeGame/BattleMode/Actions/Deciders/BattleActionPositionDecider.cs" /> <Compile Include="Assets/Code/OfficeGame/BattleMode/Actions/Deciders/BattleActionPositionDecider.cs" />
<Compile Include="Assets/Code/Infrastructure/StateMachine/AbstractStateMachine.cs" /> <Compile Include="Assets/Code/Infrastructure/StateMachine/AbstractStateMachine.cs" />
@@ -223,7 +223,6 @@
<Compile Include="Assets/Code/OfficeGame/BattleMode/Actions/ActionDatas/StuggerActionData.cs" /> <Compile Include="Assets/Code/OfficeGame/BattleMode/Actions/ActionDatas/StuggerActionData.cs" />
<Compile Include="Assets/Code/OfficeGame/Player/Factory/PlayerFactory.cs" /> <Compile Include="Assets/Code/OfficeGame/Player/Factory/PlayerFactory.cs" />
<Compile Include="Assets/Code/OfficeGame/Location/PlayerLocationChecker.cs" /> <Compile Include="Assets/Code/OfficeGame/Location/PlayerLocationChecker.cs" />
<Compile Include="Assets\Code\OfficeGame\BattleMode\Timeline\IBattleAiResolver.cs" />
<None Include="Assets/uchwch/Toon/Shader/Toon_DoubleShadeWithFeather_Mobile_TransClipping_StencilMask.shader" /> <None Include="Assets/uchwch/Toon/Shader/Toon_DoubleShadeWithFeather_Mobile_TransClipping_StencilMask.shader" />
<None Include="Library/PackageCache/com.unity.bindings.openimageio@94e2abc0bc65/package.json" /> <None Include="Library/PackageCache/com.unity.bindings.openimageio@94e2abc0bc65/package.json" />
<None Include="Library/PackageCache/com.unity.ai.navigation@d0cf77b009bb/ValidationExceptions.json" /> <None Include="Library/PackageCache/com.unity.ai.navigation@d0cf77b009bb/ValidationExceptions.json" />
@@ -5,19 +5,29 @@ namespace Code.OfficeGame.BattleMode.Actions
{ {
public class EntityPreviewVisuals : MonoBehaviour public class EntityPreviewVisuals : MonoBehaviour
{ {
public const int MaxGhostStages = 5; // 0 = Commit + до 4 прерываний public const int MaxGhostStages = 14; // 0 = Commit + до 4 прерываний
[Header("Материалы MKToon")] [Header("Материалы MKToon")]
[SerializeField] private Material snapshotGhostMaterial; [SerializeField] private Material snapshotGhostMaterial;
[SerializeField] private Material activePreviewMaterial; [SerializeField] private Material activePreviewMaterial;
[Header("Цвета проекции по стадиям прерываний")] [Header("Цвета проекции по стадиям прерываний")]
[SerializeField] private Color[] stageProjectionTints = private Color[] stageProjectionTints =
{ {
new(0.55f, 0.85f, 1.0f, 1f), // Stage 0: до первого прерывания (голубой) new(0f, 0.25f, 0.55f, 1f), // Глубокий синий (Ocean Blue)
new(1.0f, 0.85f, 0.35f, 1f), // Stage 1: после 1-го прерывания (жёлтый) new(0.15f, 0.55f, 0.9f, 1f), // Ярко-синий (Azure)
new(1.0f, 0.55f, 0.25f, 1f), // Stage 2: после 2-го прерывания (оранжевый) new(0.55f, 0.85f, 1.0f, 1f), // Небесно-голубой (Sky Blue)
new(0.95f, 0.3f, 0.5f, 1f), // Stage 3+: 3+ прерываний (малиновый) new(0.1f, 0.8f, 0.75f, 1f), // Бирюзовый (Turquoise)
new(0.1f, 0.8f, 0.5f, 1f), // Изумрудный (Emerald)
new(0.45f, 0.85f, 0.25f, 1f), // Салатовый (Lime Green)
new(1.0f, 0.85f, 0.35f, 1f), // Тёплый жёлтый (Warm Yellow)
new(1.0f, 0.7f, 0.2f, 1f), // Янтарный (Amber)
new(1.0f, 0.55f, 0.25f, 1f), // Оранжевый (Orange)
new(0.95f, 0.3f, 0.3f, 1f), // Кораллово-красный (Coral Red)
new(0.95f, 0.3f, 0.5f, 1f), // Малиново-розовый (Crimson Pink)
new(0.8f, 0.35f, 0.85f, 1f), // Орхидея / Маджента (Orchid)
new(0.5f, 0.3f, 0.9f, 1f), // Фиолетовый (Violet)
new(1f, 1f, 1f, 1f), // Чистый белый (White)
}; };
[Header("Цвета статичных слепков")] [Header("Цвета статичных слепков")]
@@ -225,6 +235,7 @@ namespace Code.OfficeGame.BattleMode.Actions
{ {
Color c = stageProjectionTints[Mathf.Clamp(stage, 0, stageProjectionTints.Length - 1)]; Color c = stageProjectionTints[Mathf.Clamp(stage, 0, stageProjectionTints.Length - 1)];
if (alphaOverride.HasValue) c.a = alphaOverride.Value; if (alphaOverride.HasValue) c.a = alphaOverride.Value;
return c; return c;
} }
@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: fb857a2eae284b31b2eb19ac4abfcaa7
timeCreated: 1793141973
@@ -1,105 +0,0 @@
using System;
using System.Threading;
using Code.Game.Gameplay.Player;
using Code.OfficeGame.BattleMode.Timeline;
using Cysharp.Threading.Tasks;
using KinematicCharacterController;
using UnityEngine;
using UnityEngine.Serialization;
namespace Code.OfficeGame.BattleMode.Actions.HoloCopy
{
public class HoloCop : MonoBehaviour
{
private static readonly int VelocityForward = Animator.StringToHash("VelocityForward");
private Func<HoloCop, float, bool> _action;
[SerializeField] private MovementController movementController;
[SerializeField] private KinematicCharacterMotor motor;
[SerializeField] private KinematicCharacterMotor originMotor;
[SerializeField] private Animator animator;
[SerializeField] private Animator originAnimator;
public MovementController Controller => movementController;
public Animator Animator => animator;
private Vector3 _initialMotorPosition;
private Quaternion _initialMotorRotation;
private int _initialAnimationState;
private float _initialNormalizedTime;
private void Snapshot()
{
_initialMotorPosition = originMotor.TransientPosition;
_initialMotorRotation = originMotor.TransientRotation;
AnimatorStateInfo stateInfo = originAnimator.GetCurrentAnimatorStateInfo(0);
_initialAnimationState = stateInfo.shortNameHash;
_initialNormalizedTime = stateInfo.normalizedTime;
animator.SetFloat(VelocityForward, originAnimator.GetFloat(VelocityForward));
animator.Play(_initialAnimationState, 0, _initialNormalizedTime);
animator.Update(0f);
}
private void ReturnToSnapshot()
{
bool prevRootMotion = animator.applyRootMotion;
animator.Play(_initialAnimationState, 0, _initialNormalizedTime);
animator.Update(0f);
animator.transform.localPosition = Vector3.zero;
animator.transform.localRotation = Quaternion.identity;
originMotor.SetPositionAndRotation(_initialMotorPosition, _initialMotorRotation);
Physics.SyncTransforms();
}
public async UniTask Simulate(Func<HoloCop, float, bool> action, CancellationToken ctx)
{
_action = action;
float accumulator = 0f;
Snapshot();
try
{
gameObject.SetActive(true);
while (!ctx.IsCancellationRequested)
{
await UniTask.Yield(PlayerLoopTiming.Update, ctx);
accumulator += Time.unscaledDeltaTime;
while (accumulator >= BattleTimeline.TickDelta)
{
accumulator -= BattleTimeline.TickDelta;
if (_action == null) return;
bool result = _action(this, BattleTimeline.TickDelta);
animator.Update(BattleTimeline.TickDelta);
Physics.Simulate(BattleTimeline.TickDelta);
Physics.SyncTransforms();
if (result) ReturnToSnapshot();
}
}
}
finally
{
ReturnToSnapshot();
gameObject.SetActive(false);
}
}
}
}
@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: b4067e559c4d4556a335b4c507f9702f
timeCreated: 1793142036
@@ -133,6 +133,8 @@ namespace Code.Game.OfficeGame.GameStates
builder.RegisterType(typeof(FrankAttackDecider), new[]{ typeof(EnemyDecider) } , Lifetime.Singleton, Resolution.Eager); builder.RegisterType(typeof(FrankAttackDecider), new[]{ typeof(EnemyDecider) } , Lifetime.Singleton, Resolution.Eager);
builder.RegisterType(typeof(BattleAiResolver), new[] { typeof(IBattleAiResolver) }, Lifetime.Singleton, Resolution.Eager);
builder.RegisterType(typeof(BattleModeCursorController), Lifetime.Singleton, Resolution.Eager); builder.RegisterType(typeof(BattleModeCursorController), Lifetime.Singleton, Resolution.Eager);
builder.RegisterType(typeof(BattleTimeline), Lifetime.Singleton, Resolution.Eager); builder.RegisterType(typeof(BattleTimeline), Lifetime.Singleton, Resolution.Eager);
} }
@@ -0,0 +1,47 @@
using System.Collections.Generic;
using System.Linq;
namespace Code.OfficeGame.BattleMode.Actions.AI
{
public interface IBattleAiResolver
{
bool TryResolveNextAction(
EntityProperties entity,
IReadOnlyDictionary<BattleActionType, BattleAction> battleActions,
out BattleActionDecisionResult decisionResult,
out BattleActionData actionData);
}
public sealed class BattleAiResolver : IBattleAiResolver
{
private readonly Dictionary<EnemyDeciderTypes, EnemyDecider> _deciders;
public BattleAiResolver(IEnumerable<EnemyDecider> enemyDeciders)
{
_deciders = enemyDeciders.ToDictionary(x => x.EnemyDeciderType);
}
public bool TryResolveNextAction(
EntityProperties entity,
IReadOnlyDictionary<BattleActionType, BattleAction> battleActions,
out BattleActionDecisionResult decisionResult,
out BattleActionData actionData)
{
if (_deciders.TryGetValue(entity.TeamData.DeciderType, out var decider))
{
(decisionResult, actionData) = decider.DecideEnemy(entity, battleActions);
if (decisionResult != null
&& actionData != null
&& decisionResult.ActionType != BattleActionType.None)
{
return true;
}
}
decisionResult = null;
actionData = null;
return false;
}
}
}
@@ -1,7 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Code.Game.Entities; using Code.Game.Entities;
using Code.Game.OfficeGame.Entities;
using Code.OfficeGame.BattleMode.Actions; using Code.OfficeGame.BattleMode.Actions;
using Code.OfficeGame.BattleMode.Actions.AI;
using Code.OfficeGame.BattleMode.Effects; using Code.OfficeGame.BattleMode.Effects;
using Code.OfficeGame.BattleMode.HitBoxes; using Code.OfficeGame.BattleMode.HitBoxes;
using KinematicCharacterController; using KinematicCharacterController;
@@ -14,12 +16,14 @@ namespace Code.OfficeGame.BattleMode.Timeline
float TickDelta { get; } float TickDelta { get; }
int CurrentSimFrame { get; } int CurrentSimFrame { get; }
int GetSlotIndex(EntityId entityId); int GetSlotIndex(EntityId entityId);
void SubmitAttack( void SubmitAttack(
EntityId attackerId, EntityId attackerId,
EntityId defenderId, EntityId defenderId,
HitBoxPartType hitPart, HitBoxPartType hitPart,
Vector3 hitWorldPosition, Vector3 hitWorldPosition,
EntityAttackedData attackedData); EntityAttackedData attackedData);
void RecordHitboxVisual(BoxCollider box, Color color); void RecordHitboxVisual(BoxCollider box, Color color);
} }
@@ -46,9 +50,14 @@ namespace Code.OfficeGame.BattleMode.Timeline
private Dictionary<EntityId, int> _idToSlot; private Dictionary<EntityId, int> _idToSlot;
private EntityActionSlotSnapshot[] _workingSlots; private EntityActionSlotSnapshot[] _workingSlots;
public BattleSimulator(Dictionary<BattleActionType, BattleAction> actions) private readonly IBattleAiResolver _aiResolver;
public BattleSimulator(
Dictionary<BattleActionType, BattleAction> actions,
IBattleAiResolver aiResolver)
{ {
_actions = actions; _actions = actions;
_aiResolver = aiResolver;
} }
public void BindEntities(EntityProperties[] entities) public void BindEntities(EntityProperties[] entities)
@@ -75,6 +84,7 @@ namespace Code.OfficeGame.BattleMode.Timeline
{ {
if (unique.Add(t)) list.Add(t); if (unique.Add(t)) list.Add(t);
} }
return list.ToArray(); return list.ToArray();
} }
@@ -162,6 +172,7 @@ namespace Code.OfficeGame.BattleMode.Timeline
{ {
EntitySnapshot.ApplyVisualOnly(_entities[i], _entityBones[i], snapshot.Entities[i].PhysicsAndVisuals); EntitySnapshot.ApplyVisualOnly(_entities[i], _entityBones[i], snapshot.Entities[i].PhysicsAndVisuals);
} }
Physics.SyncTransforms(); Physics.SyncTransforms();
} }
@@ -172,8 +183,10 @@ namespace Code.OfficeGame.BattleMode.Timeline
{ {
for (int i = 0; i < _entities.Length; i++) for (int i = 0; i < _entities.Length; i++)
{ {
EntitySnapshot.RestoreForSimulation(_entities[i], _entityBones[i], snapshot.Entities[i].PhysicsAndVisuals); EntitySnapshot.RestoreForSimulation(_entities[i], _entityBones[i],
snapshot.Entities[i].PhysicsAndVisuals);
} }
Physics.SyncTransforms(); Physics.SyncTransforms();
} }
@@ -240,6 +253,7 @@ namespace Code.OfficeGame.BattleMode.Timeline
if (slot.ActionType != BattleActionType.None && slot.ActionData != null && !slot.ActionData.Finished) if (slot.ActionType != BattleActionType.None && slot.ActionData != null && !slot.ActionData.Finished)
return true; return true;
} }
return false; return false;
} }
@@ -368,6 +382,50 @@ namespace Code.OfficeGame.BattleMode.Timeline
} }
} }
// Авто-цепочка ходов ИИ: если игрок НЕ освободился в этом кадре, но всё ещё занят действием,
// освободившиеся враги сразу выбирают следующее действие прямо внутри запекания.
if (_aiResolver != null && readyMask != 0UL)
{
bool anyPlayerReadyThisFrame = false;
bool anyPlayerStillBusy = false;
for (int i = 0; i < _entities.Length; i++)
{
if (_entities[i].EntityHealth.IsDead) continue;
if (_entities[i].TeamData.Team != EntityTeam.Good) continue;
if ((readyMask & (1UL << i)) != 0UL)
anyPlayerReadyThisFrame = true;
else if (_workingSlots[i].ActionType != BattleActionType.None &&
!_workingSlots[i].ActionData.Finished)
anyPlayerStillBusy = true;
}
if (!anyPlayerReadyThisFrame && anyPlayerStillBusy)
{
for (int i = 0; i < _entities.Length; i++)
{
if ((readyMask & (1UL << i)) == 0UL) continue;
var entity = _entities[i];
if (entity.TeamData.Team != EntityTeam.ChaoticEvil) continue;
if (_aiResolver.TryResolveNextAction(entity, _actions, out var nextDecision, out var nextData))
{
_workingSlots[i] = new EntityActionSlotSnapshot
{
ActionType = nextDecision.ActionType,
DecisionResult = nextDecision,
ActionData = nextData,
LastCompletedActionType = _workingSlots[i].LastCompletedActionType,
ActionStartFrame = frame,
EstimatedEndFrame = frame + nextData.TotalFrames
};
}
}
}
}
return CaptureCurrentFrame( return CaptureCurrentFrame(
frame, frame,
currentStage, currentStage,
@@ -404,10 +462,12 @@ namespace Code.OfficeGame.BattleMode.Timeline
int damage = request.Damage; int damage = request.Damage;
foreach (var effect in attacker.Effects) foreach (var effect in attacker.Effects)
if (effect is AttackEffect atk) atk.Apply(ref damage); if (effect is AttackEffect atk)
atk.Apply(ref damage);
foreach (var effect in defender.Effects) foreach (var effect in defender.Effects)
if (effect is DefenseEffect def) def.Apply(ref damage); if (effect is DefenseEffect def)
def.Apply(ref damage);
defender.EntityHealth.GetDamage(damage, request.HitBoxPartType); defender.EntityHealth.GetDamage(damage, request.HitBoxPartType);
@@ -429,7 +489,8 @@ namespace Code.OfficeGame.BattleMode.Timeline
if (defender.EntityHealth.IsDead) if (defender.EntityHealth.IsDead)
{ {
_workingSlots[defenderSlot] = EntityActionSlotSnapshot.CreateNone(frame, oldSlot.LastCompletedActionType); _workingSlots[defenderSlot] =
EntityActionSlotSnapshot.CreateNone(frame, oldSlot.LastCompletedActionType);
_frameEvents.Add(new TimelineEvent( _frameEvents.Add(new TimelineEvent(
frame, frame,
@@ -67,8 +67,10 @@ namespace Code.OfficeGame.BattleMode.Timeline
HealthPanelsHolder healthPanelsHolder, HealthPanelsHolder healthPanelsHolder,
CameraStateMachine cameraStateMachine, CameraStateMachine cameraStateMachine,
IParticleService particleService, IParticleService particleService,
BattleModeCursorController cursorController) BattleModeCursorController cursorController,
IBattleAiResolver aiResolver)
{ {
_aiResolver = aiResolver;
_cursorController = cursorController; _cursorController = cursorController;
_timelinePanel = timelinePanel; _timelinePanel = timelinePanel;
_decisionPanel = battleActionDecisionPanel; _decisionPanel = battleActionDecisionPanel;
@@ -80,7 +82,7 @@ namespace Code.OfficeGame.BattleMode.Timeline
_battleActionDeciders = battleActionDeciders.ToDictionary(x => x.DeciderType); _battleActionDeciders = battleActionDeciders.ToDictionary(x => x.DeciderType);
_enemyDeciders = enemyDeciders.ToDictionary(x => x.EnemyDeciderType); _enemyDeciders = enemyDeciders.ToDictionary(x => x.EnemyDeciderType);
_simulator = new BattleSimulator(_battleActions); _simulator = new BattleSimulator(_battleActions, aiResolver);
foreach (var action in _battleActions.Values) foreach (var action in _battleActions.Values)
action.SetSimulationContext(_simulator); action.SetSimulationContext(_simulator);
} }
@@ -139,6 +141,7 @@ namespace Code.OfficeGame.BattleMode.Timeline
private CancellationToken _battleLoopCt; private CancellationToken _battleLoopCt;
private BattleModeCursorController _cursorController; private BattleModeCursorController _cursorController;
private IBattleAiResolver _aiResolver;
public async UniTask RunBattleLoopAsync(List<EntityProperties> entities, CancellationToken ctx) public async UniTask RunBattleLoopAsync(List<EntityProperties> entities, CancellationToken ctx)
{ {
@@ -182,7 +185,7 @@ namespace Code.OfficeGame.BattleMode.Timeline
HideAllPreviewVisuals(); HideAllPreviewVisuals();
RebakeFromCommitted(recordGhosts: false); RebakeFromCommitted(recordGhosts: false);
int nextPauseFrame = Track.FindNextPauseFrame(_committedFrame.Value); int nextPauseFrame = Track.FindNextPlayerPauseFrame(_committedFrame.Value, _entities);
if (nextPauseFrame <= _committedFrame.Value) if (nextPauseFrame <= _committedFrame.Value)
{ {
await UniTask.Yield(PlayerLoopTiming.Update, ctx); await UniTask.Yield(PlayerLoopTiming.Update, ctx);
@@ -259,20 +262,25 @@ namespace Code.OfficeGame.BattleMode.Timeline
if (entity.TeamData.Team == EntityTeam.ChaoticEvil) if (entity.TeamData.Team == EntityTeam.ChaoticEvil)
{ {
var (enemyRes, enemyData) = _enemyDeciders[entity.TeamData.DeciderType] var lastCompleted = Track.GetFrame(_committedFrame.Value)
.DecideEnemy(entity, _battleActions); .Entities[slotIndex].ActionSlot.LastCompletedActionType;
if (_aiResolver.TryResolveNextAction(entity, _battleActions, out var enemyRes, out var enemyData))
{
return new EntityActionSlotSnapshot return new EntityActionSlotSnapshot
{ {
ActionType = enemyRes.ActionType, ActionType = enemyRes.ActionType,
DecisionResult = enemyRes, DecisionResult = enemyRes,
ActionData = enemyData, ActionData = enemyData,
LastCompletedActionType = Track.GetFrame(_committedFrame.Value).Entities[slotIndex].ActionSlot.LastCompletedActionType, LastCompletedActionType = lastCompleted,
ActionStartFrame = _committedFrame.Value, ActionStartFrame = _committedFrame.Value,
EstimatedEndFrame = _committedFrame.Value + enemyData.TotalFrames EstimatedEndFrame = _committedFrame.Value + enemyData.TotalFrames
}; };
} }
return EntityActionSlotSnapshot.CreateNone(_committedFrame.Value, lastCompleted);
}
if (entity.TeamData.Team == EntityTeam.Good) if (entity.TeamData.Team == EntityTeam.Good)
return await DecideForPlayerSlot(slotIndex, ctx); return await DecideForPlayerSlot(slotIndex, ctx);
@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Code.Game.OfficeGame.Entities;
using Code.OfficeGame.BattleMode.Actions; using Code.OfficeGame.BattleMode.Actions;
namespace Code.OfficeGame.BattleMode.Timeline namespace Code.OfficeGame.BattleMode.Timeline
@@ -101,5 +102,27 @@ namespace Code.OfficeGame.BattleMode.Timeline
return result; return result;
} }
/// <summary>
/// Первый кадр после fromFrame, на котором завершил действие хотя бы один игрок (EntityTeam.Good).
/// Если игроков в маске нет (например, игрок мёртв), возвращает LastFrame.
/// </summary>
public int FindNextPlayerPauseFrame(int fromFrame, EntityProperties[] entities)
{
ulong playerMask = 0UL;
for (int i = 0; i < entities.Length; i++)
{
if (entities[i].TeamData.Team == EntityTeam.Good)
playerMask |= 1UL << i;
}
for (int f = fromFrame + 1; f < _frames.Count; f++)
{
if ((_frames[f].ReadySlotsMask & playerMask) != 0UL)
return f;
}
return LastFrame;
}
} }
} }
@@ -1,14 +0,0 @@
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);
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+7 -7
View File
@@ -1,10 +1,10 @@
{ "pid": 35942, "tid": -1, "ph": "M", "name": "process_name", "args": { "name": "ScriptCompilationBuildProgram.exe" } }, { "pid": 35942, "tid": -1, "ph": "M", "name": "process_name", "args": { "name": "ScriptCompilationBuildProgram.exe" } },
{ "pid": 35942, "tid": -1, "ph": "M", "name": "process_sort_index", "args": { "sort_index": "-1" } }, { "pid": 35942, "tid": -1, "ph": "M", "name": "process_sort_index", "args": { "sort_index": "-1" } },
{ "pid": 35942, "tid": 1, "ph": "M", "name": "thread_name", "args": { "name": "" } }, { "pid": 35942, "tid": 1, "ph": "M", "name": "thread_name", "args": { "name": "" } },
{ "pid": 35942, "tid": 1, "ts": 1795171886389138, "dur": 1768496, "ph": "X", "name": "BuildProgram", "args": {} }, { "pid": 35942, "tid": 1, "ts": 1795176079603204, "dur": 1666101, "ph": "X", "name": "BuildProgram", "args": {} },
{ "pid": 35942, "tid": 1, "ts": 1795171886389596, "dur": 109554, "ph": "X", "name": "BuildProgramContextConstructor", "args": {} }, { "pid": 35942, "tid": 1, "ts": 1795176079603666, "dur": 122633, "ph": "X", "name": "BuildProgramContextConstructor", "args": {} },
{ "pid": 35942, "tid": 1, "ts": 1795171887692117, "dur": 2251, "ph": "X", "name": "OutputData.Write", "args": {} }, { "pid": 35942, "tid": 1, "ts": 1795176080856977, "dur": 4607, "ph": "X", "name": "OutputData.Write", "args": {} },
{ "pid": 35942, "tid": 1, "ts": 1795171887694374, "dur": 463212, "ph": "X", "name": "Backend.Write", "args": {} }, { "pid": 35942, "tid": 1, "ts": 1795176080861587, "dur": 407663, "ph": "X", "name": "Backend.Write", "args": {} },
{ "pid": 35942, "tid": 1, "ts": 1795171887708201, "dur": 446975, "ph": "X", "name": "JsonToString", "args": {} }, { "pid": 35942, "tid": 1, "ts": 1795176080872637, "dur": 396038, "ph": "X", "name": "JsonToString", "args": {} },
{ "pid": 35942, "tid": 1, "ts": 1795171888159467, "dur": 616, "ph": "X", "name": "", "args": {} }, { "pid": 35942, "tid": 1, "ts": 1795176081270996, "dur": 534, "ph": "X", "name": "", "args": {} },
{ "pid": 35942, "tid": 1, "ts": 1795171888159092, "dur": 1423, "ph": "X", "name": "Write chrome-trace events", "args": {} }, { "pid": 35942, "tid": 1, "ts": 1795176081270699, "dur": 1193, "ph": "X", "name": "Write chrome-trace events", "args": {} },
+2632 -7871
View File
File diff suppressed because it is too large. Load diff
Binary file not shown.
File diff suppressed because it is too large. Load diff
Binary file not shown.
Loaded 100 of 161 files, more files were not shown because too many files have changed in this diff. Show more