//frame update public void SavePredictionCompoments(int seqHistoryId) { EntityMap localEntites = provider.LocalEntityMap; #pragma warning disable RefCounter001,RefCounter002 EntityMap remoteEntities = PredictionEntityMap.Allocate(); #pragma warning restore RefCounter001,RefCounter002 EntityMapDeepCloner.Clone(remoteEntities, localEntites, CloneFilter.Instance); HistoryEntityMap historyEntityMap = GetTargetHistory(seqHistoryId); if (historyEntityMap == null) { logger.DebugFormat("SavePredictionCompoments1 {0}", seqHistoryId); historyEntityMap = new HistoryEntityMap(seqHistoryId, remoteEntities); histories.Enqueue(historyEntityMap); } else { logger.DebugFormat("Recplce SavePredictionCompoments {0}", seqHistoryId); RefCounterRecycler.Instance.ReleaseReference(historyEntityMap.EntityMap); historyEntityMap.EntityMap = remoteEntities; } if (histories.Count > MaxHistory) { var tdhistory = histories.Dequeue(); RefCounterRecycler.Instance.ReleaseReference(tdhistory.EntityMap); } }
public void SavePredictionCompoments(int historyId) { EntityMap localEntites = _handler.LocalEntityMap; #pragma warning disable RefCounter001,RefCounter002 EntityMap remoteEntities = PredictionEntityMap.Allocate(); #pragma warning restore RefCounter001,RefCounter002 EntityMapDeepCloner.Clone(remoteEntities, localEntites, _filter); SavedHistory history = GetTargetHistory(historyId); if (history == null) { _logger.DebugFormat("SavePredictionCompoments_1 {0}", historyId); history = new SavedHistory(historyId, remoteEntities); _histories.Add(history); } else { _logger.DebugFormat("Recplce SavePredictionCompoments {0}", historyId); RefCounterRecycler.Instance.ReleaseReference(history.EntityMap); history.EntityMap = remoteEntities; } if (_histories.Count > MaxHistory) { var tdhistory = _histories[0]; RefCounterRecycler.Instance.ReleaseReference(tdhistory.EntityMap); _histories.RemoveAt(0); } }
private void RewindTo(EntityMap remoteEntityMap) { var localEntityMapClone = PredictionEntityMap.Allocate(false); localEntityMapClone.AddAll(provider.LocalEntityMap); EntityMapCompareExecutor.Diff(localEntityMapClone, remoteEntityMap, rewindDiffHandler, "predicateRewind", gameEntityRewindComparator); RefCounterRecycler.Instance.ReleaseReference(localEntityMapClone); }
private void RewindTo(EntityMap remoteEntityMap) { PredictionRewindHandler <TPredictionComponent> rewindHandler = new PredictionRewindHandler <TPredictionComponent>(_handler); var localEntityMapClone = PredictionEntityMap.Allocate(false); localEntityMapClone.AddAll(_handler.LocalEntityMap); EntityMapComparator.Diff(localEntityMapClone, remoteEntityMap, rewindHandler, "predicateRewind"); RefCounterRecycler.Instance.ReleaseReference(localEntityMapClone); }
public void RewindFirstSnapshot(EntityKey self) { var localEntityMapClone = PredictionEntityMap.Allocate(false); provider.SetSelf(self); provider.Update(); localEntityMapClone.AddAll(provider.LocalEntityMap); logger.InfoFormat("{0} {1}", provider.LocalEntityMap.Count, localEntityMapClone.Count); checkDiffHandler.SetRemoteCmdSeq(provider.LastSelfUserCmdSeqId); EntityMapCompareExecutor.Diff(localEntityMapClone, provider.RemoteEntityMap, checkDiffHandler, "RewindFirstSnapshotompare", gameEntityComparator); foreach (var gameEntity in provider.RemoteEntityMap.ToArray()) { foreach (var gameComponent in gameEntity.ComponentList) { logger.InfoFormat("{0}", gameComponent); } } EntityMapCompareExecutor.Diff(localEntityMapClone, provider.RemoteEntityMap, rewindDiffHandler, "rewindFirstSnapshot", gameEntityRewindComparator); RefCounterRecycler.Instance.ReleaseReference(localEntityMapClone); }
public void RewindFirstSnapshot(EntityKey self) { var localEntityMapClone = PredictionEntityMap.Allocate(false); _handler.SetSelf(self); _handler.Update(); localEntityMapClone.AddAll(_handler.LocalEntityMap); _logger.InfoFormat("{0} {1}", _handler.LocalEntityMap.Count, localEntityMapClone.Count); PredictionCompareHandler <TPredictionComponent> compareHandler = new PredictionCompareHandler <TPredictionComponent>(_handler.RemoteHistoryId); EntityMapComparator.Diff(localEntityMapClone, _handler.RemoteEntityMap, compareHandler, "RewindFirstSnapshotompare"); foreach (var gameEntity in _handler.RemoteEntityMap.ToArray()) { foreach (var gameComponent in gameEntity.ComponentList) { _logger.InfoFormat("{0}", gameComponent); } } PredictionRewindHandler <TPredictionComponent> rewindHandler = new PredictionRewindHandler <TPredictionComponent>(_handler); EntityMapComparator.Diff(localEntityMapClone, _handler.RemoteEntityMap, rewindHandler, "rewindFirstSnapshot"); RefCounterRecycler.Instance.ReleaseReference(localEntityMapClone); }