Table of Contents

InputBuffer<T>

Type Parameters

T
Constructors
InputBuffer(int, int, bool, EqualityComparer<T>)
Properties
Delay

Delay applied to the stored inputs.

LastAcknowledgedFrame

Last frame received that didn't trigger a misprediction, or -1 if nothing was acknowledged yet. Might be greater than LastConsumedFrame.

LastConsumedFrame

Last frame that was fetched from the buffer and was not predicted.

LastFrame

Last (latest) frame number for which an input was stored, received or predicted. -1 if nothing was added to the buffer yet.

LastInput

Last (latest) known input, or default if none was added to the buffer yet.

LastReceivedFrame

Last frame number that was received from the remote input producer, or -1 if nothing was received yet.

LastSentFrame

Last frame number that was dequeued for sending, or -1 if nothing was sent yet.

MispredictionFrame

Frame at which last prediction failure has been detected.

Size

Size of the buffer. Dictates how many frames worth of inputs can be stored. When buffer reaches its capacity a pause is requested through the ShouldPause(long, long).

Methods
AddInput(in T, long)

Adds an input to the buffer for a given frame. If the Delay is set, the frame is offset by its value. This method should be used by the owner of the input; receiving side should use the ReceiveInput(in T, long) method.

DequeueForSending(long, out long, out T, out bool)

Dequeues next input from the buffer that hasn't been sent yet. Progresses the internal LastSentFrame counter.

ReceiveInput(in T, long)
Reset()

Clears the input buffer and resets its state.

ShouldPause(long, long)

If true, the buffer cannot do any more predictions. Client should pause the game and stop polling inputs to not lose any data required for a rollback.

TryGetInput(long, out T, bool)

Retrieves input from the buffer for a given frame.

Events
OnStaleInput

Called when an input is received that is older than the oldest input in the buffer.