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

@@ -121,11 +121,11 @@ namespace Code.OfficeGame.BattleMode.Timeline
Dictionary<EntityId, BattleActionData> actionDataSnapshots = new();
Dictionary<EntityId, BattleActionDecisionResult> resultsSnapshots = new();
Dictionary<EntityId, EntitySnapshot> entitySnapshots = new();
foreach (var entity in entities)
{
var entityId = entity.GetEntityId();
if (!_actionDecisionResults.TryGetValue(entityId, out var actionDecisionResult)
|| !_battleActionDatas.TryGetValue(entityId, out var battleActionData))
continue;
@@ -137,8 +137,6 @@ namespace Code.OfficeGame.BattleMode.Timeline
try
{
Debug.Log(frameCount);
await PlayTimelineForCertainFrames(frameCount, ctx).AttachExternalCancellation(ctx);
}
finally
@@ -146,17 +144,17 @@ namespace Code.OfficeGame.BattleMode.Timeline
foreach (var entity in entities)
{
var entityId = entity.GetEntityId();
if (!resultsSnapshots.TryGetValue(entityId, out var actionDecisionResult)
|| !actionDataSnapshots.TryGetValue(entityId, out var battleActionData))
continue;
if(!_actionDecisionResults.TryAdd(entityId, actionDecisionResult))
if (!_actionDecisionResults.TryAdd(entityId, actionDecisionResult))
_actionDecisionResults[entityId]?.RestoreSnapshot(actionDecisionResult);
if(!_battleActionDatas.TryAdd(entityId, battleActionData))
if (!_battleActionDatas.TryAdd(entityId, battleActionData))
_battleActionDatas[entityId]?.RestoreSnapshot(battleActionData);
entity.RestoreSnapshot(entitySnapshots[entityId]);
}
}
@@ -252,13 +250,11 @@ namespace Code.OfficeGame.BattleMode.Timeline
BattleActionDecisionResult decisionResult = null;
BattleActionData actionData = null;
CancellationTokenSource previewCancellationToken = new();
var entityId = entity.GetEntityId();
BattleActionData entityActionDataSnapshot = null;
BattleActionDecisionResult entityResultSnapshot = null;
if (_battleActionDatas.TryGetValue(entityId, out var battleActionData))
entityActionDataSnapshot = battleActionData.GetSnapshot();
@@ -281,6 +277,8 @@ namespace Code.OfficeGame.BattleMode.Timeline
_battleActionDeciders[deciderType].MountDecider();
CancellationTokenSource previewCancellationToken = new();
while (!ctx.IsCancellationRequested)
{
Cursor.lockState = CursorLockMode.Locked;
@@ -293,13 +291,13 @@ namespace Code.OfficeGame.BattleMode.Timeline
decisionResult.ActionType = decidedActionType;
Debug.Log(decisionResult.ResultCode);
actionData = _battleActions[decidedActionType].MountAndGetFrames(entity, decisionResult);
previewCancellationToken.Cancel();
previewCancellationToken.Dispose();
if(decisionResult.ResultCode == BattleActionDecisionResultCode.Deciding)
if (decisionResult.ResultCode == BattleActionDecisionResultCode.Deciding)
{
_actionDecisionResults[entityId] = decisionResult;
_battleActionDatas[entityId] = actionData;
@@ -309,23 +307,24 @@ namespace Code.OfficeGame.BattleMode.Timeline
PreviewBattleLoopAsync(actionData.TotalFrames, _entities, previewCancellationToken.Token)
.Forget();
}
if (decisionResult.ResultCode == BattleActionDecisionResultCode.CancelDecision)
else if (decisionResult.ResultCode == BattleActionDecisionResultCode.CancelDecision)
{
decidedActionType = BattleActionType.None;
if (decisionResult.ResultCode != BattleActionDecisionResultCode.Deciding)
break;
}
else break;
}
_battleActionDeciders[deciderType].UnmountDecider();
}
if(entityResultSnapshot != null
&& !_actionDecisionResults.TryAdd(entityId, entityResultSnapshot))
if (entityResultSnapshot != null
&& !_actionDecisionResults.TryAdd(entityId, entityResultSnapshot))
_actionDecisionResults[entityId]?.RestoreSnapshot(entityResultSnapshot);
if(entityActionDataSnapshot != null
&& !_battleActionDatas.TryAdd(entityId, entityActionDataSnapshot))
if (entityActionDataSnapshot != null
&& !_battleActionDatas.TryAdd(entityId, entityActionDataSnapshot))
_battleActionDatas[entityId]?.RestoreSnapshot(entityActionDataSnapshot);
if (decisionResult == null || actionData == null) throw new ArgumentNullException(nameof(decisionResult));