Something fixed
This commit is contained in:
1 parent
f40a10912c
commit
7d236d14cd
72 files changed
+270482
-11409
No files matched your search
@@ -0,0 +1,71 @@
|
||||
using System.Collections.Generic;
|
||||
using Code.Game.Entities;
|
||||
using Code.OfficeGame.BattleMode.Actions;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.OfficeGame.BattleMode.Snapshots
|
||||
{
|
||||
public class SnapshotUtilityNonStatic
|
||||
{
|
||||
Dictionary<EntityId, BattleActionData> actionDataSnapshots = new();
|
||||
Dictionary<EntityId, BattleActionDecisionResult> resultsSnapshots = new();
|
||||
Dictionary<EntityId, EntitySnapshot> entitySnapshots = new();
|
||||
|
||||
public void GetSnapshots(
|
||||
Dictionary<EntityId, EntityProperties> entities,
|
||||
Dictionary<EntityId, BattleActionDecisionResult> actionDecisionResults,
|
||||
Dictionary<EntityId, BattleActionData> battleActionDatas)
|
||||
{
|
||||
foreach (var (entityId, entity) in entities)
|
||||
{
|
||||
if (!actionDecisionResults.TryGetValue(entityId, out var actionDecisionResult)
|
||||
|| !battleActionDatas.TryGetValue(entityId, out var battleActionData))
|
||||
{
|
||||
entity.EntityPreviewVisuals.ShowPreviewState(spawnStaticSnapshotGhost: false);
|
||||
continue;
|
||||
}
|
||||
entity.EntityPreviewVisuals.ShowPreviewState(spawnStaticSnapshotGhost: true);
|
||||
|
||||
resultsSnapshots[entityId] = actionDecisionResult.GetSnapshot();
|
||||
actionDataSnapshots[entityId] = battleActionData.GetSnapshot();
|
||||
entitySnapshots[entityId] = entity.GetSnapshot();
|
||||
}
|
||||
}
|
||||
|
||||
public void RestoreFromSnapshots(
|
||||
Dictionary<EntityId, EntityProperties> entities,
|
||||
Dictionary<EntityId, BattleActionDecisionResult> actionDecisionResults,
|
||||
Dictionary<EntityId, BattleActionData> battleActionDatas)
|
||||
{
|
||||
foreach (var (entityId, entity) in entities)
|
||||
{
|
||||
if (!resultsSnapshots.TryGetValue(entityId, out var actionDecisionResult)
|
||||
|| !actionDataSnapshots.TryGetValue(entityId, out var battleActionData))
|
||||
continue;
|
||||
|
||||
bool actionChanged = false;
|
||||
|
||||
if (!actionDecisionResults.TryAdd(entityId, actionDecisionResult))
|
||||
{
|
||||
actionChanged = actionDecisionResult.ActionType
|
||||
!= actionDecisionResults[entityId].ActionType;
|
||||
|
||||
if (actionChanged)
|
||||
actionDecisionResults[entityId] = actionDecisionResult.GetSnapshot();
|
||||
else
|
||||
actionDecisionResults[entityId]?.RestoreSnapshot(actionDecisionResult);
|
||||
}
|
||||
|
||||
if (!battleActionDatas.TryAdd(entityId, battleActionData))
|
||||
{
|
||||
if (actionChanged)
|
||||
battleActionDatas[entityId] = battleActionData.GetSnapshot();
|
||||
else
|
||||
battleActionDatas[entityId]?.RestoreSnapshot(battleActionData);
|
||||
}
|
||||
|
||||
entity.RestoreSnapshot(entitySnapshots[entityId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2bf8fe2677b947a781568c78e8dc7e99
|
||||
timeCreated: 1794237839
|
||||
Reference in new issue
Block a user