Represents a Quantum runtime match, holding the references to Game, its Frames (game state) and Simulator, and implements (together with Simulator) the predict/rollback logic, time control and input management. Single use, so whenever a Session is shutdown (or disconnected), it can't be reused anymore and a new one must be instantiated. More...
Public Member Functions | |
DeterministicSession (DeterministicSessionArgs args) | |
Validates a few conditions to assert the session object has coherent settings. After construction, session is ready to Join/Start a game. More... | |
void | AddPlayer (int playerSlot, Byte[] data) |
Attempts to add a local player slot to have input controlled by the session. Fails is local slot is already used, or if the server/plugin does not have an available PlayerRef. More... | |
void | ApplyTimeOffset (Double time) |
Legacy method to manually add time to the internal Simulator. Not used anymore by the standard SDK, but available to legacy projects. More... | |
void | Destroy () |
Terminates the game/session, Disposing all buffers and objects. More... | |
void | GetLocalConfigs (out DeterministicSessionConfig sessionConfig, out Byte[] runtimeConfig) |
Retrieves the local copies of the main configs. More... | |
Boolean | IsFrameVerified (int frame) |
true if the latest confirmed/verified frame is equals or larger then this. More... | |
Boolean | IsLocalPlayer (PlayerRef player) |
true if this global PlayerRef is controlled by the local session. More... | |
bool | IsPlayerLocal (PlayerRef player) |
Tests whereas this PlayerRef is controlled by this local client/session. More... | |
bool | IsPlayerSlotLocal (int playerSlot) |
Checks if this local player slot is currently in use (local slots can be added/removed dynamically). More... | |
void | Join (String id) |
Sends the Join protocol message to server/plugin. If successful, a start protocol message (and optionally a snapshot) will be received and the session will start to be updated. Sessions are always joined as spectators (starting on Quantum 3.0), and adding local players that can have input polled for is a dynamic operation done after session start. More... | |
void | RemovePlayer (Int32 playerSlot) |
Attempts to remove a local player slot from the session. Fails is local slot is not currently in use. More... | |
void | ResetReplay (DeterministicFrame frame) |
Resets the session to the specified frame for replay purposes. More... | |
void | Resync (Byte[] frameData, Int32 frameNumber) |
Resynchronizes the session based on the provided frame data and frame number. More... | |
void | Resync (DeterministicFrame frame) |
Resynchronizes the session to the specified frame. More... | |
DeterministicCommandSendResult | SendCommand (Int32 playerSlot, DeterministicCommand command) |
Includes command for local prediction, and sends to server (in online games) for confirmation. Fails if this slot is not in use by the local session/client. Server protects against all forms of spoofing in online games. More... | |
void | SendGameResult (Byte[] data) |
Supports sending one game result during one session per client. Send this based on timing and simulation data of a verified frame to make results be comparable. Data can be any format but the size must be below Protocol.GameResult.MaxSize. Zip compress Json for example to reduce the size. More... | |
void | SetPlayerData (int playerSlot, Byte[] data) |
Previously could be called multiple times to send custom data relative to a player. AddPlayer replaces it, and can only be called once for a specific slot. More... | |
bool | TryGetLocalPlayer (int playerSlot, out PlayerRef player) |
Returns true and fills in the corresponding global PlayerRef if playerSlot is a valid local slot, for which the session can send input. More... | |
void | Update (Double? deltaTime=null) |
Called to move the simulation forward (poll local input, decode confirmed, simulate verified and predicted frames). When passing a delta time, the internal Stopwatch is ignored. More... | |
Public Attributes | |
bool | HasStarted => State > DeterministicSessionState.Idle |
The initial state is idle, then it will be started after confirmation from the server. More... | |
bool | IsDestroyed => State == DeterministicSessionState.Destroyed |
Returns true when Destroy() has been called. More... | |
bool | IsRunning => State == DeterministicSessionState.Running |
true if local session is started and active. More... | |
List< PlayerRef > | LocalPlayers => _localPlayerMap.Players |
The collection of PlayerRefs the local client has control of (sends input for). More... | |
List< Int32 > | LocalPlayerSlots => _localPlayerMap.PlayerSlots |
The collection of local-indexed (0-n) players the local client has control of (sends input for). More... | |
Properties | |
Double | AccumulatedTime [get] |
Remaining accumulated time after all frames forward (both verified and predicted) have been simulated. Usually less than a full delta-time (defined by update rate), and used to compute the interpolation alpha. Can be above delta-time if the current session is temporarily lagging behind and can not simulate forward the full prediction (depending on settings). More... | |
DeterministicCommandSerializer | CommandSerializer [get] |
Local instance of specialized serializer that can pack/unpack DeterministicCommands to/from byte[]s. More... | |
FP | DeltaTime [get] |
Fixed-point delta-time as defined by DeterministicConfig's UpdateFPS (1/UpdateFPS). More... | |
Double | DeltaTimeDouble [get] |
Double version of delta-time as defined by DeterministicConfig's UpdateFPS (1/UpdateFPS). More... | |
DeterministicFrame? | FramePredicted [get] |
Quick accessor to the latest locally predicted copy of the game state. More... | |
DeterministicFrame? | FramePredictedPrevious [get] |
Quick accessor to the second latest locally predicted copy of the game state. Used for accurate visual interpolation of transforms (or any other data) between this and the Predicted frame. More... | |
DeterministicFrame? | FrameVerified [get] |
Quick accessor to the forward-only verified data (simulated with confirmed inputs from server in online games). Can be used as source of truth, as this does not include predicted data. More... | |
IDeterministicGame | Game [get] |
The matching game instance, which holds the Frames (game state) and other accessory logic entry points for a predict/rollback match. More... | |
DeterministicGameMode | GameMode [get] |
Possible modes are online/multiplayer, local or replay. More... | |
Int32 | InitialTick [get] |
Normally zero (0) for most game clients. Can be set to a specific value if a local copy for initial frame snapshot data is provided (normally used occasionally in case of quick rejoinining a room). More... | |
DeterministicTickInput.Pool | InputPool [get] |
Accessor to the pool of input objects. More... | |
byte[] | IntitialFrameData [get] |
Serialized local copy for initial frame snapshot data, if provided when starting a new session (normally used occasionally in case of quick rejoinining a room). More... | |
Boolean | IsInterpolatable [get] |
If the session provides previous states for interpolation. More... | |
Boolean | IsLocal [get] |
true for replays and local games (single player or split screen/couch-local). false for online games. More... | |
Boolean | IsLockstep [get] |
Legacy mode in which frames are only simulated forward with input delay, and no prediction is ever performed. In the past this was the default approach for classic RTS games. More... | |
Boolean | IsOnline [get] |
true for online games. false for replays and local games (single player or split screen/couch-local). More... | |
Boolean | IsPaused [get] |
Temporarily true only for a session that has just been started (Start message arrived from server) while waiting for a snapshot to arrive. More... | |
Boolean | IsPredicted [get] |
true when not using legacy lockstep mode. Means frames will be predicted and rolled back. More... | |
Boolean | IsReplay [get] |
true when GameMode is Replay (input comes from replay provider). More... | |
Boolean | IsReplayFinished [get] |
true when the final input in the replay stream has been consumed to simulate forward a verified frame. More... | |
Boolean | IsSpectating [get] |
Always true once session is started. false if at least one player is controlled by the local session. More... | |
Boolean | IsStalling [get] |
true if simulation is being clamped at max prediction (rollback window). Happens normally when input confirmations from server are disrupted (network loss or very high ping times). More... | |
Int32 | LocalInputOffset [get] |
Current value for the dynamically-adjusted input delay (independent for each client). Starts at the initial offset on DeterministicConfig (defaults to 0), and grows with RTT. More... | |
Int32 | MaxVerifiedTicksPerUpdate [get, set] |
Limit the maximum number of verified ticks computed per update. Default is int.MaxValue. More... | |
DeterministicPlatformInfo | PlatformInfo [get] |
Cached info about the local device platform (some OS and hardware available specs). More... | |
Int32 | PlayerCount [get] |
Total/max number of PlayerRefs this particular session instance comprises of. This is not the number of connected players, but rather the total number. More... | |
Int32 | PredictedFrames [get] |
Stats: Number of predicted frames simulated during the last call to Update(). More... | |
DeterministicFrame? | PreviousUpdateFramePredicted [get] |
Quick accessor to the latest simulated copy of the Frame that was last-Predicted during the previous main session update. Used to calculate transform view error for smoothed correction. More... | |
IDeterministicReplayProvider | ReplayProvider [get] |
When running replays, input comes from the provider/container. Replay input streams can com from file, memory, or a network stream (custom). More... | |
Int32 | RollbackWindow [get] |
Max number of frames/ticks the session is allowed to predict. Can be set at DeterministicConfig. More... | |
IDisposable | Runner [get, set] |
Runner is the wrapper for session/game that can be attached to Unity, a .Net console app, or a Quantum Custom Server Plugin. More... | |
Byte[] | RuntimeConfig [get] |
Serialized local copy of the game/session custom RuntimeConfig instance (received from the photon server). Since this has been received from server, it's the same in all instances. More... | |
DeterministicSessionConfig | SessionConfig [get] |
Local copy of the server-provided main set of settings, controlling update rate, input adjustment and other important control values. Since this has been received from server, it's the same set of values in all instances. More... | |
Int32 | SimulationRate [get] |
Fixed rate at which the game is simulated (verified frames). Can be set at DeterministicConfig. More... | |
Double | SimulationTimeElasped [get] |
Stats: Precise time in seconds used by the last call to Update(). Includes all session internal input handling, rollbacks, verified and predicted frames simulation. More... | |
double | SpectatingOffsetSec [get, set] |
Specify the offset in sec that the simulation will run behind in Spectator mode. Value must be negative or 0. Default is -1 sec. More... | |
DeterministicStats | Stats [get] |
Copy of local runtime stats (stores the last Update values for simulation time, number of frames simulated, etc). Used by the QuantumStatsUI to show these in runtime on Unity. More... | |
Double | TimeScale [get] |
Current time-dilation delta-time scale. Tf time-dilation settings allow it, server will reduce this to slow down games when some clients have very high ping (reducing the number of predictions). More... | |
Represents a Quantum runtime match, holding the references to Game, its Frames (game state) and Simulator, and implements (together with Simulator) the predict/rollback logic, time control and input management. Single use, so whenever a Session is shutdown (or disconnected), it can't be reused anymore and a new one must be instantiated.
|
inline |
Validates a few conditions to assert the session object has coherent settings. After construction, session is ready to Join/Start a game.
|
inline |
Tests whereas this PlayerRef is controlled by this local client/session.
Caveat: This method will behave differently in replays, read the replay online documentation for more information.
|
inline |
Returns true
and fills in the corresponding global PlayerRef if playerSlot is a valid local slot, for which the session can send input.
Caveat: This method will behave differently in replays, read the replay online documentation for more information.
|
inline |
Checks if this local player slot is currently in use (local slots can be added/removed dynamically).
Caveat: This method will behave differently in replays, read the replay online documentation for more information.
|
inline |
Retrieves the local copies of the main configs.
|
inline |
true
if the latest confirmed/verified frame is equals or larger then this.
|
inline |
true
if this global PlayerRef is controlled by the local session.
|
inline |
Includes command for local prediction, and sends to server (in online games) for confirmation. Fails if this slot is not in use by the local session/client. Server protects against all forms of spoofing in online games.
|
inline |
Previously could be called multiple times to send custom data relative to a player. AddPlayer replaces it, and can only be called once for a specific slot.
|
inline |
Attempts to add a local player slot to have input controlled by the session. Fails is local slot is already used, or if the server/plugin does not have an available PlayerRef.
|
inline |
Attempts to remove a local player slot from the session. Fails is local slot is not currently in use.
|
inline |
Supports sending one game result during one session per client. Send this based on timing and simulation data of a verified frame to make results be comparable. Data can be any format but the size must be below Protocol.GameResult.MaxSize. Zip compress Json for example to reduce the size.
data | Serialized game result |
|
inline |
Sends the Join protocol message to server/plugin. If successful, a start protocol message (and optionally a snapshot) will be received and the session will start to be updated. Sessions are always joined as spectators (starting on Quantum 3.0), and adding local players that can have input polled for is a dynamic operation done after session start.
|
inline |
Legacy method to manually add time to the internal Simulator. Not used anymore by the standard SDK, but available to legacy projects.
|
inline |
Terminates the game/session, Disposing all buffers and objects.
|
inline |
Called to move the simulation forward (poll local input, decode confirmed, simulate verified and predicted frames). When passing a delta time, the internal Stopwatch is ignored.
|
inline |
Resets the session to the specified frame for replay purposes.
frame | The frame to reset the session to. |
|
inline |
Resynchronizes the session to the specified frame.
frame | The frame to reset to. |
|
inline |
Resynchronizes the session based on the provided frame data and frame number.
frameData | The frame data to use for resynchronization. |
frameNumber | The frame number to resynchronize with. |
List<PlayerRef> Photon.Deterministic.DeterministicSession.LocalPlayers => _localPlayerMap.Players |
The collection of PlayerRefs the local client has control of (sends input for).
List<Int32> Photon.Deterministic.DeterministicSession.LocalPlayerSlots => _localPlayerMap.PlayerSlots |
The collection of local-indexed (0-n) players the local client has control of (sends input for).
bool Photon.Deterministic.DeterministicSession.HasStarted => State > DeterministicSessionState.Idle |
The initial state is idle, then it will be started after confirmation from the server.
bool Photon.Deterministic.DeterministicSession.IsRunning => State == DeterministicSessionState.Running |
true
if local session is started and active.
bool Photon.Deterministic.DeterministicSession.IsDestroyed => State == DeterministicSessionState.Destroyed |
Returns true
when Destroy() has been called.
|
getset |
Limit the maximum number of verified ticks computed per update. Default is int.MaxValue.
|
getset |
Specify the offset in sec that the simulation will run behind in Spectator mode. Value must be negative or 0. Default is -1 sec.
|
get |
Serialized local copy of the game/session custom RuntimeConfig instance (received from the photon server). Since this has been received from server, it's the same in all instances.
|
get |
Copy of local runtime stats (stores the last Update values for simulation time, number of frames simulated, etc). Used by the QuantumStatsUI to show these in runtime on Unity.
|
get |
The matching game instance, which holds the Frames (game state) and other accessory logic entry points for a predict/rollback match.
|
get |
Quick accessor to the latest locally predicted copy of the game state.
|
get |
Quick accessor to the second latest locally predicted copy of the game state. Used for accurate visual interpolation of transforms (or any other data) between this and the Predicted frame.
|
get |
Quick accessor to the forward-only verified data (simulated with confirmed inputs from server in online games). Can be used as source of truth, as this does not include predicted data.
|
get |
Quick accessor to the latest simulated copy of the Frame that was last-Predicted during the previous main session update. Used to calculate transform view error for smoothed correction.
|
get |
Local copy of the server-provided main set of settings, controlling update rate, input adjustment and other important control values. Since this has been received from server, it's the same set of values in all instances.
|
get |
Remaining accumulated time after all frames forward (both verified and predicted) have been simulated. Usually less than a full delta-time (defined by update rate), and used to compute the interpolation alpha. Can be above delta-time if the current session is temporarily lagging behind and can not simulate forward the full prediction (depending on settings).
|
get |
Normally zero (0) for most game clients. Can be set to a specific value if a local copy for initial frame snapshot data is provided (normally used occasionally in case of quick rejoinining a room).
|
get |
Serialized local copy for initial frame snapshot data, if provided when starting a new session (normally used occasionally in case of quick rejoinining a room).
|
get |
Current time-dilation delta-time scale. Tf time-dilation settings allow it, server will reduce this to slow down games when some clients have very high ping (reducing the number of predictions).
|
get |
Total/max number of PlayerRefs this particular session instance comprises of. This is not the number of connected players, but rather the total number.
|
get |
Fixed rate at which the game is simulated (verified frames). Can be set at DeterministicConfig.
|
get |
Max number of frames/ticks the session is allowed to predict. Can be set at DeterministicConfig.
|
get |
Current value for the dynamically-adjusted input delay (independent for each client). Starts at the initial offset on DeterministicConfig (defaults to 0), and grows with RTT.
|
get |
Stats: Number of predicted frames simulated during the last call to Update().
|
get |
Stats: Precise time in seconds used by the last call to Update(). Includes all session internal input handling, rollbacks, verified and predicted frames simulation.
|
get |
Fixed-point delta-time as defined by DeterministicConfig's UpdateFPS (1/UpdateFPS).
|
get |
Double version of delta-time as defined by DeterministicConfig's UpdateFPS (1/UpdateFPS).
|
get |
Possible modes are online/multiplayer, local or replay.
|
get |
true
for replays and local games (single player or split screen/couch-local). false
for online games.
|
get |
true
for online games. false
for replays and local games (single player or split screen/couch-local).
|
get |
Always true
once session is started. false
if at least one player is controlled by the local session.
|
get |
true
if simulation is being clamped at max prediction (rollback window). Happens normally when input confirmations from server are disrupted (network loss or very high ping times).
|
get |
Temporarily true
only for a session that has just been started (Start message arrived from server) while waiting for a snapshot to arrive.
|
get |
Legacy mode in which frames are only simulated forward with input delay, and no prediction is ever performed. In the past this was the default approach for classic RTS games.
|
get |
true
when not using legacy lockstep mode. Means frames will be predicted and rolled back.
|
get |
true
when GameMode is Replay (input comes from replay provider).
|
get |
If the session provides previous states for interpolation.
|
get |
true
when the final input in the replay stream has been consumed to simulate forward a verified frame.
|
get |
When running replays, input comes from the provider/container. Replay input streams can com from file, memory, or a network stream (custom).
|
get |
Cached info about the local device platform (some OS and hardware available specs).
|
get |
Local instance of specialized serializer that can pack/unpack DeterministicCommands to/from byte[]s.
|
getset |
Runner is the wrapper for session/game that can be attached to Unity, a .Net console app, or a Quantum Custom Server Plugin.
|
get |
Accessor to the pool of input objects.