QuantumGame acts as an interface to the simulation from the client code's perspective. More...
Classes | |
class | CallbackBase |
The base class of Quantum callbacks. More... | |
class | ConfigurationsContainer |
Stores runtime config and simulation config for this session. More... | |
class | FramesContainer |
Stores the different frames the simulation uses during one tick. More... | |
Public Member Functions | |
QuantumGame (in QuantumGameStartParameters startParams) | |
Create a Quantum game instance. More... | |
void | AddPlayer (Int32 playerSlot, RuntimePlayer data) |
Send data for one local player to join the online match. More... | |
void | AddPlayer (RuntimePlayer data) |
Send data for the local player to join the online match. If the client has multiple local players, the data will be sent for the first player set. More... | |
void | AssignSession (DeterministicSession session) |
The DeterministicSession creates this reference during its initialization. More... | |
void | CheckTrackedHeapAllocations () |
Trigger the heap allocation tracker during OnDestroy. More... | |
Frame | CreateFrame () |
Create a new frame object using the internal frame context. More... | |
IDisposable | CreateFrameContext () |
Create the frame context. More... | |
QuantumReplayFile | CreateSavegame (bool includeDb=false) |
Create a QuantumReplayFile file that represents a save game. More... | |
void | DeserializeInputInto (int player, byte[] data, byte *buffer, bool verified) |
Asks the game to de-serialize input into the buffers, because it's game specific it cannot be done from here. More... | |
byte[] | GetExtraErrorFrameDumpData (DeterministicFrame frame) |
Creates information send to the server when detecting a checksum error. More... | |
int | GetInputInMemorySize () |
Return the in memory input size. More... | |
Int32 | GetInputSerializedFixedSize () |
Returns the serialized input size. More... | |
Frame | GetInstantReplaySnapshot (int frame) |
Get a recorded frame for a given frame number from the checksum or instant replay snapshot buffers. More... | |
void | GetInstantReplaySnapshots (int startFrame, int endFrame, List< Frame > frames) |
Get recorded frames for a given frame number window from the checksum or instant replay snapshot buffers. More... | |
List< PlayerRef > | GetLocalPlayers () |
Returns an array that is unique on every client and represents the global player indices that the local client controls in the Quantum simulation. More... | |
List< Int32 > | GetLocalPlayerSlots () |
Returns an array that is unique on every client and represents the player slots that the local client controls in the Quantum simulation. More... | |
QuantumReplayFile | GetRecordedReplay (bool includeChecksums=false, bool includeDb=false, QuantumJsonFriendlyDataBlob.Encoder customAssetDbSerializer=null, QuantumJsonFriendlyDataBlob.Encoder customRuntimeConfigSerializer=null, QuantumJsonFriendlyDataBlob.Encoder customInputSerializer=null) |
Creates a replay file that represents a recorded replay of the complete simulation. Requires the RecordingFlags to be set accordingly. More... | |
DeterministicFrame | GetVerifiedFrame (int tick) |
Tries to get the verified frame for a given tick from the snapshot buffer. More... | |
void | InitCallbacks () |
Initializes all callbacks. More... | |
void | OnChecksumComputed (Int32 frame, ulong checksum) |
The callback is called when the local checksum was computed. More... | |
void | OnChecksumError (DeterministicTickChecksumError error, DeterministicFrame[] frames) |
The callback is called when a checksum error was detected. More... | |
void | OnChecksumErrorFrameDump (int actorId, int frameNumber, DeterministicSessionConfig sessionConfig, byte[] runtimeConfig, byte[] frameData, byte[] extraData) |
The callback is called when the clients receives a frame dump of another client from the server. More... | |
void | OnDestroy () |
The game is destroyed. This is called from inside the DeterministicSession. More... | |
void | OnGameEnded () |
Not implemented. More... | |
void | OnGameResync () |
The callback is called when the game is starting from a snapshot after the snapshot has been received. More... | |
void | OnGameStart (DeterministicFrame f) |
The callback is called when the actual simulation starts after the online protocol start sequence was successful. More... | |
void | OnInputConfirmed (DeterministicFrameInputTemp input) |
The callback is called when an input object was confirmed by the server. More... | |
void | OnInputSetConfirmed (int tick, int length, byte[] data) |
The callback is called when an input set (all clients) was confirmed by the server. More... | |
DeterministicFrameInputTemp | OnLocalInput (Int32 frame, Int32 playerSlot) |
The callback is called to poll local input. More... | |
void | OnLocalPlayerAddConfirmed (DeterministicFrame frame, int playerSlot, PlayerRef player) |
The callback is called when the server confirmed the addition of a (local) player. More... | |
void | OnLocalPlayerAddFailed (int playerSlot, string message) |
The callback is called when the server failed to process the add player request. More... | |
void | OnLocalPlayerRemoveConfirmed (DeterministicFrame frame, int playerSlot, PlayerRef player) |
The callback is called when the server confirmed the removal of a (local) player. More... | |
void | OnLocalPlayerRemoveFailed (int playerSlot, string message) |
The callback is called when the server failed to process the remove player request. More... | |
void | OnPluginDisconnect (string reason) |
The callback is called when the server plugin disconnected the client. More... | |
void | OnSerializedInput (byte *encoded, Array result) |
The callback is called to serialize the game-specific input. More... | |
void | OnSimulate (DeterministicFrame state) |
The callback is called when any simulation step was executed. More... | |
void | OnSimulateFinished (DeterministicFrame state) |
The callback is called after any simulation step was executed and after the OnSimulate(DeterministicFrame) callback. More... | |
void | OnSimulationBegin () |
The callback is called before the session computes multiple simulation steps (frames). More... | |
void | OnSimulationEnd () |
The callback is called when multiple simulation steps (frames) were executed. More... | |
void | OnUpdateDone () |
The callback is called when when the session completed its DeterministicSession.Update loop. More... | |
Boolean | PlayerIsLocal (PlayerRef playerRef) |
Helps to decide if a PlayerRef is associated with the local player. More... | |
void | RemoveAllPlayers () |
Removes all players from the game and acts as a spectator. More... | |
void | RemovePlayer () |
Remove the player. Assuming there is only one local player that this client controls. More... | |
void | RemovePlayer (Int32 playerSlot) |
Remove a player slot from the game. More... | |
DeterministicCommandSendResult | SendCommand (DeterministicCommand command) |
Sends a command to the server. More... | |
DeterministicCommandSendResult | SendCommand (Int32 playerSlot, DeterministicCommand command) |
Sends a command to the server. More... | |
void | SetPredictionArea (FPVector2 position, FP radius) |
See SetPredictionArea(FPVector3, FP). More... | |
void | SetPredictionArea (FPVector3 position, FP radius) |
Set the prediction area. More... | |
void | StartRecordingChecksums () |
Manually start the recording of checksums. More... | |
void | StartRecordingInput (Int32? startFrame=null) |
Manually start the input recording. Either accessible by RecordedInputs (if DeterministicSessionConfig.InputDeltaCompression is disabled) or RecordInputStream (if DeterministicSessionConfig.InputDeltaCompression is enabled). More... | |
void | StartRecordingInstantReplaySnapshots () |
Manually start recording instant replay snapshots. Requires InstantReplayConfig to be set accordingly. More... | |
void | StartVerifyingChecksums (ChecksumFile checksums) |
Start verifying new checksums against a recorded checksum file. More... | |
Public Member Functions inherited from Photon.Deterministic.IDeterministicGame | |
void | OnChecksumErrorFrameDump (Int32 actorId, Int32 frameNumber, DeterministicSessionConfig sessionConfig, byte[] runtimeConfig, byte[] frameData, byte[] extraData) |
The callback is called when the clients receives a frame dump of another client from the server. More... | |
void | OnInputSetConfirmed (Int32 tick, Int32 length, byte[] data) |
The callback is called when an input set (all clients) was confirmed by the server. More... | |
Public Attributes | |
int | EventWaitingForConfirmationCount => _eventsConfirmationQueue.Count |
The number of events in the queue waiting for confirmation. More... | |
int | GameFlags => _flags |
Game flags passer by QuantumGameStartParameters.GameFlags. See QuantumGameFlags. More... | |
Properties | |
IAssetSerializer | AssetSerializer [get] |
Asset serializer passed by QuantumGameStartParameters.AssetSerializer. More... | |
ConfigurationsContainer | Configurations [get] |
Access the configurations that the simulation is running with. Only set after the first CreateFrame() call. More... | |
FramesContainer | Frames [get] |
Access the frames of various times available during one tick. More... | |
int | HeapExtraCount [get] |
Extra heaps to allocate for a session in case you need to create 'auxiliary' frames than actually required for the simulation itself. More... | |
InstantReplaySettings | InstantReplayConfig [get] |
Instant replay configuration, initialized by QuantumGameStartParameters.InstantReplaySettings." More... | |
Single | InterpolationFactor [get] |
Used for position interpolation on the client for smoother interpolation results. More... | |
ChecksumFile | RecordedChecksums [get] |
The recorded checksums. The checksum recording automatically start when SessionRunner.Arguments.RecordingFlags contains RecordingFlags.Checksums and DeterministicSessionConfig.ChecksumInterval > 0. The recording can also be started by calling StartRecordingChecksums manually. More... | |
InputProvider | RecordedInputs [get] |
The recorded raw inputs. The raw input recording automatically start when SessionRunner.Arguments.RecordingFlags contains RecordingFlags.Input and DeterministicSessionConfig.InputDeltaCompression is disabled. The recording can also be started by calling StartRecordingInput manually. More... | |
Stream | RecordInputStream [get, set] |
The recorded delta compressed input stream. The raw input recording automatically start when SessionRunner.Arguments.RecordingFlags contains RecordingFlags.Input and DeterministicSessionConfig.InputDeltaCompression is enabled. The recording can also be started by calling StartRecordingInput manually. /// More... | |
IResourceManager | ResourceManager [get] |
Resource manager passed by QuantumGameStartParameters.ResourceManager. More... | |
DeterministicSession | Session [get] |
Access the Deterministic session object to query more internals. More... | |
Properties inherited from Photon.Deterministic.IDeterministicGame | |
DeterministicSession | Session [get] |
Get the deterministic session. More... | |
Events | |
Action< ProfilerContextData > | ProfilerSampleGenerated |
A callback that is invoked after the IDeterministicGame.OnSimulate callback. It uses the FrameContext.ProfilerContext to create a report. More... | |
QuantumGame acts as an interface to the simulation from the client code's perspective.
Access and method to this class is always safe from the clients point of view.
|
inline |
Create a Quantum game instance.
startParams | Start parameters. |
|
inline |
Returns an array that is unique on every client and represents the global player indices that the local client controls in the Quantum simulation.
|
inline |
Returns an array that is unique on every client and represents the player slots that the local client controls in the Quantum simulation.
|
inline |
Helps to decide if a PlayerRef is associated with the local player.
playerRef | Player reference |
|
inline |
Sends a command to the server.
command | Command to send |
Commands are similar to input, they drive the simulation, but do not have to be sent regularly.
|
inline |
Sends a command to the server.
playerSlot | Specify the local player index when you have multiple players controlled from the same machine. |
command | Command to send |
See SendCommand(DeterministicCommand)
Games that only have one local player can ignore the player index field.
|
inline |
Send data for the local player to join the online match. If the client has multiple local players, the data will be sent for the first player set.
data | Player data |
After starting, joining the Quantum Game and after the OnGameStart signal has been fired each player needs to call the AddPlayer method to be added as a player in every ones simulation.
The reason this needs to be called explicitly is that it greatly simplifies late-joining players.
|
inline |
Send data for one local player to join the online match.
playerSlot | Local player index |
data | Player data |
After starting, joining the Quantum Game and after the OnGameStart signal has been fired each player needs to call the AddPlayer method to be added as a player in every ones simulation.
The reason this needs to be called explicitly is that it greatly simplifies late-joining players.
|
inline |
Remove the player. Assuming there is only one local player that this client controls.
|
inline |
Remove a player slot from the game.
playerSlot | Local player |
|
inline |
Removes all players from the game and acts as a spectator.
|
inline |
The game is destroyed. This is called from inside the DeterministicSession.
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
Create a new frame object using the internal frame context.
|
inline |
Tries to get the verified frame for a given tick from the snapshot buffer.
tick | Tick |
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
Create the frame context.
ArgumentException | Is raised when no SimulationConfig is set inside the RuntimeConfig. |
Implements Photon.Deterministic.IDeterministicGame.
Set the prediction area.
position | Center of the prediction area |
radius | Radius of the prediction area |
This can be safely called from the main-thread.
Prediction Culling allows developers to save CPU time in games where the player has only a partial view of the game scene. Quantum prediction and rollbacks, which are time consuming, will only run for important entities that are visible to the local player(s). Leaving anything outside that area to be simulated only once per tick with no rollbacks as soon as the inputs are confirmed from server. It is safe and simple to activate and, depending on the game, the performance difference can be quite large.Imagine a 30Hz game to constantly rollback ten ticks for every confirmed input (with more players, the predictor eventually misses at least for one of them). This requires the game simulation to be lightweight to be able to run at almost 300Hz(because of the rollbacks). With Prediction Culling enabled the full frames will be simulated at the expected 30Hz all the time while the much smaller prediction area is the only one running within the prediction buffer.
See SetPredictionArea(FPVector3, FP).
position | |
radius |
|
inline |
Not implemented.
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The callback is called when the actual simulation starts after the online protocol start sequence was successful.
f | First frame |
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The callback is called when the game is starting from a snapshot after the snapshot has been received.
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The callback is called to poll local input.
frame | Frame |
playerSlot | Player slot |
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The callback is called to serialize the game-specific input.
encoded | The source input |
result | The destination input |
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The callback is called when any simulation step was executed.
state | Frame that was simulated |
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The callback is called after any simulation step was executed and after the OnSimulate(DeterministicFrame) callback.
state | Frame that was simulated |
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The callback is called when when the session completed its DeterministicSession.Update loop.
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The DeterministicSession creates this reference during its initialization.
session | Deterministic session that this game uses |
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The callback is called when a checksum error was detected.
error | Checksum error information |
frames | Contains the verified frame that was failed to validate |
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The callback is called when the local checksum was computed.
frame | The frame the checksum belongs to |
checksum | The checksum that will be send to the server |
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The callback is called before the session computes multiple simulation steps (frames).
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The callback is called when multiple simulation steps (frames) were executed.
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The callback is called when an input object was confirmed by the server.
input | Input object |
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The callback is called when an input set (all clients) was confirmed by the server.
tick | Tick |
length | Length of input object array |
data | Input objects |
|
inline |
The callback is called when the clients receives a frame dump of another client from the server.
actorId | The Photon actor id that the dump belongs to |
frameNumber | The frame number of the dump |
sessionConfig | The session config |
runtimeConfig | The runtime config |
frameData | The frame data |
extraData | Extra dump meta information |
|
inline |
The callback is called when the server plugin disconnected the client.
reason | Debug string |
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The callback is called when the server confirmed the addition of a (local) player.
frame | The frame the player has been added |
playerSlot | The player slot that was used to assign the player |
player | The player |
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The callback is called when the server confirmed the removal of a (local) player.
frame | The frame when the request was confirmed |
playerSlot | The player slot of the removed player |
player | The player that was removed |
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The callback is called when the server failed to process the add player request.
playerSlot | The player slot that was requested |
message | Debug message |
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
The callback is called when the server failed to process the remove player request.
playerSlot | The player slot that was tried to remove |
message | Debug message |
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
Return the in memory input size.
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
Returns the serialized input size.
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
Asks the game to de-serialize input into the buffers, because it's game specific it cannot be done from here.
player | The player the input is for |
data | The input data |
buffer | The destination buffer |
verified | Is the input verified |
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
Creates information send to the server when detecting a checksum error.
frame | Frame |
Implements Photon.Deterministic.IDeterministicGame.
|
inline |
Trigger the heap allocation tracker during OnDestroy.
ArgumentOutOfRangeException | Is raised when HeapTrackingMode is unknown |
|
inline |
Get a recorded frame for a given frame number from the checksum or instant replay snapshot buffers.
frame | Frame number |
|
inline |
Get recorded frames for a given frame number window from the checksum or instant replay snapshot buffers.
startFrame | Start frame |
endFrame | End frame |
frames | Resulting frames |
|
inline |
Create a QuantumReplayFile file that represents a save game.
includeDb | Include the AssetDb |
|
inline |
Creates a replay file that represents a recorded replay of the complete simulation. Requires the RecordingFlags to be set accordingly.
includeChecksums | Include checksums |
includeDb | Include the asset db |
customAssetDbSerializer | A custom asset serializer |
customRuntimeConfigSerializer | A custom runtime config serializer |
customInputSerializer | A custom input serialized |
|
inline |
Manually start the input recording. Either accessible by RecordedInputs (if DeterministicSessionConfig.InputDeltaCompression is disabled) or RecordInputStream (if DeterministicSessionConfig.InputDeltaCompression is enabled).
startFrame |
|
inline |
Manually start the recording of checksums.
|
inline |
Start verifying new checksums against a recorded checksum file.
checksums | Recorded checksum file |
|
inline |
Manually start recording instant replay snapshots. Requires InstantReplayConfig to be set accordingly.
|
inline |
Initializes all callbacks.
int Quantum.QuantumGame.GameFlags => _flags |
Game flags passer by QuantumGameStartParameters.GameFlags. See QuantumGameFlags.
int Quantum.QuantumGame.EventWaitingForConfirmationCount => _eventsConfirmationQueue.Count |
The number of events in the queue waiting for confirmation.
|
get |
Access the frames of various times available during one tick.
|
get |
Access the configurations that the simulation is running with. Only set after the first CreateFrame() call.
|
get |
Access the Deterministic session object to query more internals.
|
get |
Used for position interpolation on the client for smoother interpolation results.
|
get |
Instant replay configuration, initialized by QuantumGameStartParameters.InstantReplaySettings."
|
get |
Asset serializer passed by QuantumGameStartParameters.AssetSerializer.
|
get |
Resource manager passed by QuantumGameStartParameters.ResourceManager.
|
get |
Extra heaps to allocate for a session in case you need to create 'auxiliary' frames than actually required for the simulation itself.
|
get |
The recorded raw inputs. The raw input recording automatically start when SessionRunner.Arguments.RecordingFlags contains RecordingFlags.Input and DeterministicSessionConfig.InputDeltaCompression is disabled. The recording can also be started by calling StartRecordingInput manually.
|
get |
The recorded checksums. The checksum recording automatically start when SessionRunner.Arguments.RecordingFlags contains RecordingFlags.Checksums and DeterministicSessionConfig.ChecksumInterval > 0. The recording can also be started by calling StartRecordingChecksums manually.
|
getset |
The recorded delta compressed input stream. The raw input recording automatically start when SessionRunner.Arguments.RecordingFlags contains RecordingFlags.Input and DeterministicSessionConfig.InputDeltaCompression is enabled. The recording can also be started by calling StartRecordingInput manually. ///
Action<ProfilerContextData> Quantum.QuantumGame.ProfilerSampleGenerated |
A callback that is invoked after the IDeterministicGame.OnSimulate callback. It uses the FrameContext.ProfilerContext to create a report.