int Simulate(int frameNumber) { SWConsole.Crit($"Engine: Simulate frameNumber={frameNumber}"); InputFrame lastInputFrame = inputFrames[frameNumber - 1]; InputFrameDelta lastInputFrameDelta = inputFrameDeltas[frameNumber - 1]; int playerFrameNumber = lastInputFrameDelta.playerFrameNumber; InputFrame inputFrame = inputFrames[frameNumber]; if (inputFrame == null) { inputFrame = new InputFrame(frameNumber); inputFrames[frameNumber] = inputFrame; } inputFrame.FrameNumber = frameNumber; inputFrame.ResetBytes(); if (lastInputFrame == null || _input == null || inputFrame == null || lastInputFrameDelta == null) { SWConsole.Error($"Engine: Simulate input data is nil {lastInputFrame} {_input} {inputFrame} {lastInputFrameDelta}"); } lastInputFrameDelta.Apply(_input, lastInputFrame, inputFrame); FrameSyncUpdateType updateType = FrameSyncUpdateType.Normal; DoSimulate(updateType, inputFrame, frameNumber); return(playerFrameNumber); }
bool Predict(int localFrameDeltaNumber, int frameNumber) { SWConsole.Crit($"Engine: Predict localFrameDeltaNumber={localFrameDeltaNumber} frameNumber={frameNumber}"); InputFrameDelta inputFrameDelta = localInputFrameDeltas[localFrameDeltaNumber]; _inputFrameForPrediction.FrameNumber = frameNumber; _inputFrameForPrediction.ResetBytes(); inputFrameDelta.Apply(_input, _lastInputFrameForPrediction, _inputFrameForPrediction); _input.ApplyPredictionModifier(_inputFrameForPrediction.bytes); FrameSyncUpdateType updateType = FrameSyncUpdateType.Prediction; DoSimulate(updateType, _inputFrameForPrediction, frameNumber); return(true); }