Beispiel #1
0
        public Replay <T, S> FlatternToReplay()
        {
            Replay <T, S> replay = new Replay <T, S>(fixedDt, settings, stepDts);

            foreach (var item in commands)
            {
                List <ZeroLagCommand> currStepReceivedCommands = item.Value;
                foreach (var command in currStepReceivedCommands)
                {
                    replay.ReceiveCommand(command);
                }
            }
            foreach (var timeoutsReceivedOnCurrStep in timeouts.Values)
            {
                foreach (var timeout in timeoutsReceivedOnCurrStep)
                {
                    ZeroLagCommand targetCommand = replay.GetTimeoutedCommand(timeout);
                    targetCommand.OnTimedout(timeout);
                    var targetStepCommands = replay.commands[timeout.targetCommandStep];
                    targetStepCommands.RemoveOne(cmd => cmd.hash == timeout.targetCommandHash);

                    if (timeout.whatToDo == ActionOnTimeout.ExecuteLater)
                    {
                        replay.ReceiveCommand(targetCommand); // Receive command later.
                    }
                }
            }
            return(replay);
        }
Beispiel #2
0
        private bool TryConsumeTimeout(TimeoutCommand timeout)
        {
            ZeroLagCommand targetCommand = playedGameReplay.GetTimeoutedCommand(timeout);

            if (targetCommand == null)
            {
                return(false);
            }
            int targetCommandStep = targetCommand.stepInd;

            lastActualStep = Math.Min(lastActualStep, targetCommandStep);
            targetCommand.OnTimedout(timeout);
            playedGameReplay.commands[targetCommandStep].RemoveOne(cmd => cmd.hash == timeout.targetCommandHash);
            if (timeout.whatToDo == ActionOnTimeout.ExecuteLater)
            {
                ReceiveCommand(targetCommand); // Receive command later.
            }
            return(true);
        }