CoherenceInputSimulation<TState>
CoherenceInputSimulation<TState> helps building a deterministic simulation by taking care of most complexities related to keeping a simulation state, handling predictions, rolling back state, resimulating state, etc..
Type Parameters
TState
Type that holds the simulation state for a given frame.
Constructors
CoherenceInputSimulation() |
Fields
PauseAutomatically | If set to true, the simulation will automatically handle the ShouldPause changes, stopping the fixed simulation updates as needed. |
coherenceBridge |
Properties
AllClients | All instances of the connected CoherenceClientConnections, including a local one. |
CoherenceClient | A network client used for communication with the Replication Server. |
CurrentSimulationFrame | |
Debugger | Input debugger that stores various information about the input system for each frame. Upon disconnect the information is dumped to a specified location defined by the XXX (by default to a file). |
FixedTimeStep | A fixed time step as set in the NetworkTime. By default set to fixedDeltaTime. |
LocalClient | Instance of the local CoherenceClientConnection. |
SimulationEnabled | If set to false, the simulation code won't be run, however: * Frame progression is not stopped * The OnBeforeSimulate() is still called Can be used for example to wait for all players before starting the simulation. |
StateStore | Stores the simulation states used for rollbacks in case of a misprediction. |
Methods
CreateState() | Called at the end of the simulation loop to get a snapshot of the simulation that can be later used in the Rollback(long, TState) if needed. |
Destroy() | Called after the simulation cleanup in the Unity's |
OnBeforeSimulate() | Called as a first thing in a given simulation loop, before any of the simulation or rollback code. Can be used for example to control the SimulationEnabled flag based on the players readiness. |
OnClientJoined(CoherenceClientConnection) | Called when a new CoherenceClientConnection joins the session (including a local one). |
OnClientLeft(CoherenceClientConnection) | Called when a CoherenceClientConnection leaves the session. |
OnConnected() | Called when we successfully connect to the Replication Server. |
OnDisconnected() | Called when we disconnect from the Replication Server. |
OnPauseChange(bool) | Called when a pause or unpause happens. See the PauseAutomatically and ShouldPause for more information. |
OnStart() | Called after the simulation initializes in the Unity's |
Rollback(long, TState) | Called when the simulation should be rolled back to a given |
SetInputs(CoherenceClientConnection) | Called when the local client should set inputs using the CoherenceInput. |
Simulate(long) | Called when a simulation must happen for a given |
Start() | Used internally, DON'T hide it by defining another |
TryGetClient(ClientID, out CoherenceClientConnection) | Returns a CoherenceClientConnection by its ClientId. |
Events
BridgeResolve | Given a component on a CoherenceSync, resolve a specific CoherenceBridge. |