public void Push(TimeStamp timeStamp) { if(timeStamps.Count > max) { timeStamps.RemoveLast(); } timeStamps.AddFirst(timeStamp); }
public void ApplyTimeStamp(TimeStamp timeStamp, TimeSpan totalGameTime, int localID) { Queue<Command> localCommands = new Queue<Command>(gameStateManager.RollBack(timeStamp.time, localID)); gameStateManager.TimeStampManager.SwapFirstTimeStamp(timeStamp); GameLoop gameLoop = new GameLoop(0); SimulationGameTime simulationGameTime = new SimulationGameTime(totalGameTime, totalGameTime.TotalMilliseconds - timeStamp.time); gameLoop.InputQueue = localCommands; while (simulationGameTime.SimulationTime > 0) { gameLoop.SimulationLoop(simulationGameTime, this.gameStateManager); simulationGameTime.SimulationTime -= 50; } }
public TimeStamp ReplaceTimeStamp(TimeStamp timeStamp, int time) { LinkedListNode<TimeStamp> toReplace = FindTimeStamp(time); if(toReplace != null) { timeStamps.AddBefore(toReplace, timeStamp); if (timeStamps.Remove(toReplace.Value)) { return toReplace.Value; } } throw new Exception("Could not replace timestamp"); }
public void AddFirstBefore(TimeStamp timeStamp, int time) { this.BatchPop(time); Push(timeStamp); }
public void SwapFirstTimeStamp(TimeStamp timeStamp) { if(timeStamps.Count > 0) { TimeStamp returnStamp = timeStamps.First.Value; timeStamps.RemoveFirst(); } timeStamps.AddFirst(timeStamp); }