Photon Quantum 2.1.9

Classes | Public Member Functions | Public Attributes | Properties | List of all members
Quantum.QuantumGame Class Reference

QuantumGame acts as an interface to the simulation from the client code's perspective. More...

Inherits Photon.Deterministic.IDeterministicGame.

Classes

class  FramesContainer
 Stores the different frames the simulation uses during one tick. More...
 

Public Member Functions

Int32[] GetLocalPlayers ()
 Returns an array that is unique on every client and represents the indexes for players that your local machine controls in the Quantum simulation. More...
 
Boolean PlayerIsLocal (PlayerRef playerRef)
 Helps to decide if a PlayerRef is associated with the local player. More...
 
void SendCommand (DeterministicCommand command)
 Sends a command to the server. More...
 
void SendCommand (Int32 player, DeterministicCommand command)
 Sends a command to the server. More...
 
void SendPlayerData (Int32 player, RuntimePlayer data)
 Send data for one local player to join the online match. More...
 
void SendPlayerData (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 of them (smallest player index). More...
 
void SetPredictionArea (FPVector2 position, FP radius)
 See SetPredictionArea(FPVector3, FP). More...
 
void SetPredictionArea (FPVector3 position, FP radius)
 Set the prediction area. More...
 

Public Attributes

int GameFlags => _flags
 QuantumGameFlags More...
 
bool IsSessionDestroyed => Session != null && Session.IsDestroyed
 Returns true when the session has been assigned and has been destroyed. The session assignment happens during the DeterministicSession contructor which is usually during QuantumRunner.StartGame(). More...
 

Properties

IAssetSerializer AssetSerializer [get]
 
ConfigurationsContainer Configurations [get]
 Access the configurations that the simulation is running with. 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]
 
Single InterpolationFactor [get]
 Used for position interpolation on the client for smoother interpolation results. More...
 
DeterministicSession Session [get]
 Access the Deterministic session object to query more internals. More...
 

Detailed Description

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.

Member Function Documentation

◆ GetLocalPlayers()

Int32 [] Quantum.QuantumGame.GetLocalPlayers ( )
inline

Returns an array that is unique on every client and represents the indexes for players that your local machine controls in the Quantum simulation.

Returns
Array of player indices

◆ PlayerIsLocal()

Boolean Quantum.QuantumGame.PlayerIsLocal ( PlayerRef  playerRef)
inline

Helps to decide if a PlayerRef is associated with the local player.

Parameters
playerRefPlayer reference
Returns
True if the player is the local player

◆ SendCommand() [1/2]

void Quantum.QuantumGame.SendCommand ( DeterministicCommand  command)
inline

Sends a command to the server.

Parameters
commandCommand to send

Commands are similar to input, they drive the simulation, but do not have to be sent regularly.

RemoveUnitCommand command = new RemoveUnitCommand();
command.CellIndex = 42;
QuantumRunner.Default.Game.SendCommand(command);

◆ SendCommand() [2/2]

void Quantum.QuantumGame.SendCommand ( Int32  player,
DeterministicCommand  command 
)
inline

Sends a command to the server.

Parameters
playerSpecify the player index (PlayerRef) when you have multiple players controlled from the same machine.
commandCommand to send

See SendCommand(DeterministicCommand)

Games that only have one local player can ignore the player index field.

◆ SendPlayerData() [1/2]

void Quantum.QuantumGame.SendPlayerData ( RuntimePlayer  data)
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 of them (smallest player index).

Parameters
dataPlayer data

After starting, joining the Quantum Game and after the OnGameStart signal has been fired each player needs to call the SendPlayerData 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.

◆ SendPlayerData() [2/2]

void Quantum.QuantumGame.SendPlayerData ( Int32  player,
RuntimePlayer  data 
)
inline

Send data for one local player to join the online match.

Parameters
playerLocal player index
dataPlayer data

After starting, joining the Quantum Game and after the OnGameStart signal has been fired each player needs to call the SendPlayerData 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.

◆ SetPredictionArea() [1/2]

void Quantum.QuantumGame.SetPredictionArea ( FPVector3  position,
FP  radius 
)
inline

Set the prediction area.

Parameters
positionCenter of the prediction area
radiusRadius of the prediction area

The Prediction Culling feature must be explicitly enabled in SimulationConfig.UsePredictionArea.

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.

◆ SetPredictionArea() [2/2]

void Quantum.QuantumGame.SetPredictionArea ( FPVector2  position,
FP  radius 
)
inline

See SetPredictionArea(FPVector3, FP).

Parameters
position
radius

Member Data Documentation

◆ IsSessionDestroyed

bool Quantum.QuantumGame.IsSessionDestroyed => Session != null && Session.IsDestroyed

Returns true when the session has been assigned and has been destroyed. The session assignment happens during the DeterministicSession contructor which is usually during QuantumRunner.StartGame().

◆ GameFlags

int Quantum.QuantumGame.GameFlags => _flags

Property Documentation

◆ Frames

FramesContainer Quantum.QuantumGame.Frames
get

Access the frames of various times available during one tick.

◆ Configurations

ConfigurationsContainer Quantum.QuantumGame.Configurations
get

Access the configurations that the simulation is running with.

◆ Session

DeterministicSession Quantum.QuantumGame.Session
get

Access the Deterministic session object to query more internals.

◆ InterpolationFactor

Single Quantum.QuantumGame.InterpolationFactor
get

Used for position interpolation on the client for smoother interpolation results.

◆ InstantReplayConfig

InstantReplaySettings Quantum.QuantumGame.InstantReplayConfig
get

◆ AssetSerializer

IAssetSerializer Quantum.QuantumGame.AssetSerializer
get

◆ HeapExtraCount

int Quantum.QuantumGame.HeapExtraCount
get

Extra heaps to allocate for a session in case you need to create 'auxiliary' frames than actually required for the simulation itself.