Module |
|
Header |
/Engine/Plugins/Runtime/NetworkPrediction/Source/NetworkPrediction/Public/NetworkedSimulationModel.h |
Include |
#include "NetworkedSimulationModel.h" |
class FNetSimModelDefBase
This is the object that ties all user-defined NetworkPrediction things together:
The Simulation: "pure" gameplay simulation: takes input -> produces output. Knows nothing about networking or the general UE4 side of things.
The Model Definition: defines user types, tick settings, the simulation class and functions such as ShouldReconcile and Interpolate. E.g, "How do you want the networking model to work".
The Driver: required interface for this NetSimModel to function: FinalizeFrame, ProduceInput, Debugging/VisualLogging, etc. Implemented by the Actor/Component/UE4 side.
Has 4 buffers: -Input: Generated by a client / not the authority. -Sync: What we are trying to keep in sync. The state that evolves frame to frame with an Update function. -Aux: State that is also an input into the simulation but does not intrinsically evolve from to frame. Changes to this state can be trapped/tracked/predicted. -Debug: Replicated buffer from server->client with server-frame centered debug information. Compiled out of shipping builds.
How other code interacts with this: -Network updates will come in through UE4 networking -> FReplicationProxy (on actor/component) -> TNetworkedSimulationModel::RepProxy_* -> Buffers.* -UNetworkSimulationGlobalManager: responsible for ticking simulation (after recv net traffic, prior to UE4 actor ticking) -External game code can interact with the system: -The TNetworkedSimulationModel is mostly public and exposed. It is not recommend to publicly expose to your "user" code (high level scripting, designers, etc). -TNetkSimStateAccessor is a helper for safely reading/writing to state within the system. -NetSimCues are how the simulation can invoke events out of the system that are "network aware"
Notes on ownership and lifetime: -User code will instantiate the underlying simulation class (TSimulation) -Ownership of the simulation is taken over by TNetworkedSimulationModel on instantiation -(user code may still want to cache a pointer to the TSimulation instance for its own, but does not need to destroy the simulation) -Swapping TSimulation instance or releasing it early would be possible but use case is not clear so not implemented. -TNetworkedSimulationModel lifetime is the responsibility of the code that created it (UNetworkPredictionComponent in most cases).
Name |
Description |
---|---|
Base |
Model base class. E.g, common interface all NetworkedSimulationModels can be communicated with |
BufferTypes |
Buffer types: defines your Input/Sync/Aux state (and optional debug state) |
Simulation |
The simulation class. This encompasses all state and functions for running the simulation but none of the networking/bookkeeping etc. |
TickSettings |
Tick settings: defines variable vs fix step tick, etc. |