Class NetickEngine
- Namespace
- Netick
- Assembly
- Netick.dll
The NetickEngine class is the core of Netick, managing networking, simulation, interpolation, replication, etc.
public sealed class NetickEngine
- Inheritance
-
NetickEngine
- Inherited Members
Constructors
NetickEngine()
public NetickEngine()
Fields
ClientSimulationCallbacks
public readonly List<IClientSimulationCallbacks> ClientSimulationCallbacks
Field Value
SimulatedLossIn
public float SimulatedLossIn
Field Value
SimulatedLossOut
public float SimulatedLossOut
Field Value
Properties
AllEntities
public IReadOnlyDictionary<int, Entity> AllEntities { get; }
Property Value
AuthoritativeTick
public Tick AuthoritativeTick { get; }
Property Value
Client
public Client Client { get; }
Property Value
ClientSimulation
public ClientSimulation ClientSimulation { get; }
Property Value
Config
public NetickConfigData Config { get; }
Property Value
ConnectedClients
A list containing all connected clients currently.
Note: if you want the clients + the server, use ConnectedPlayers.
[Obsolete("This will be removed in the future, please use Players instead.")]
public IReadOnlyList<ServerConnection> ConnectedClients { get; }
Property Value
ConnectedPlayers
A list containing all connected clients currently, in addition to the server.
Note: if you only want the clients, use ConnectedClients.
[Obsolete("This will be removed in the future, please use Players instead.")]
public IReadOnlyList<NetworkPlayer> ConnectedPlayers { get; }
Property Value
CurrentRpcCaller
public NetworkPlayer CurrentRpcCaller { get; }
Property Value
CurrentRpcSource
public NetworkConnection CurrentRpcSource { get; }
Property Value
Entities
public IReadOnlyDictionary<int, Entity> Entities { get; }
Property Value
FixedDeltaTime
Time period between simulation ticks.
public float FixedDeltaTime { get; }
Property Value
GameVersion
public int GameVersion { get; }
Property Value
InKBps
Average incoming data in kilobytes per second (KBps).
public float InKBps { get; }
Property Value
InPacketLoss
[Client Only] Estimation of incoming packets that are being lost. Value ranges between 0.0 and 1.0, with 1.0 meaning all packets are being lost.
public float InPacketLoss { get; }
Property Value
InterestManagement
public InterestManagement InterestManagement { get; }
Property Value
InterpolationDelay
[Client Only] Interpolation delay in seconds.
public float InterpolationDelay { get; }
Property Value
IsClient
public bool IsClient { get; }
Property Value
IsConnected
[Client Only] Returns true if this client is currently connected to a server.
public bool IsConnected { get; }
Property Value
IsFirstNetworkFixedUpdateCall
public bool IsFirstNetworkFixedUpdateCall { get; }
Property Value
IsIMEnabled
public bool IsIMEnabled { get; }
Property Value
IsInputEnabled
public bool IsInputEnabled { get; set; }
Property Value
IsInvokingNetworkRender
public bool IsInvokingNetworkRender { get; }
Property Value
IsLastNetworkFixedUpdateCall
public bool IsLastNetworkFixedUpdateCall { get; }
Property Value
IsOffline
public bool IsOffline { get; }
Property Value
IsRecording
public bool IsRecording { get; }
Property Value
IsReplay
public bool IsReplay { get; }
Property Value
IsReplayEnabled
public bool IsReplayEnabled { get; }
Property Value
IsResimulating
Returns true if we are currently resimulating a previous input/tick of the past. On the server, it always returns false since only the clients resimulate.
public bool IsResimulating { get; }
Property Value
IsRunning
public bool IsRunning { get; }
Property Value
IsServer
public bool IsServer { get; }
Property Value
LagCompensation
public INetickComponent LagCompensation { get; }
Property Value
LocalInterpolation
public LocalInterpolation LocalInterpolation { get; }
Property Value
LocalPeer
public NetworkPeer LocalPeer { get; }
Property Value
LocalPlayer
public NetworkPeer LocalPlayer { get; }
Property Value
MaxClients
public int MaxClients { get; }
Property Value
MaxPlayers
public int MaxPlayers { get; }
Property Value
Monitor
public Monitor Monitor { get; }
Property Value
Name
public string Name { get; }
Property Value
OnPostNetworkStart
public Action OnPostNetworkStart { get; set; }
Property Value
OnTickEnd
public Action OnTickEnd { get; set; }
Property Value
OnTickStart
public Action OnTickStart { get; set; }
Property Value
OutKBps
Average outgoing data in kilobytes per second (KBps).
public float OutKBps { get; }
Property Value
OutPacketLoss
[Client Only] Estimation of outgoing packets that are being lost. Value ranges between 0.0 and 1.0, with 1.0 meaning all packets are being lost.
public float OutPacketLoss { get; }
Property Value
Players
public IReadOnlyList<NetworkPlayerId> Players { get; }
Property Value
Port
public int Port { get; }
Property Value
PostNetworkFixedUpdate
public Action PostNetworkFixedUpdate { get; set; }
Property Value
PostNetworkRender
public Action PostNetworkRender { get; set; }
Property Value
PostNetworkUpdate
public Action PostNetworkUpdate { get; set; }
Property Value
PostResimulation
public Action PostResimulation { get; set; }
Property Value
PostRollback
public Action PostRollback { get; set; }
Property Value
PreNetworkFixedUpdate
public Action PreNetworkFixedUpdate { get; set; }
Property Value
PreNetworkRender
public Action PreNetworkRender { get; set; }
Property Value
PreNetworkUpdate
public Action PreNetworkUpdate { get; set; }
Property Value
PreRollback
public Action PreRollback { get; set; }
Property Value
PredictedTick
public Tick PredictedTick { get; }
Property Value
RTT
[Client Only] The round-trip time (RTT) of the client in seconds.
public double RTT { get; }
Property Value
RemoteInterpolation
public RemoteInterpolation RemoteInterpolation { get; }
Property Value
Replay
public Replay Replay { get; }
Property Value
Server
public Server Server { get; }
Property Value
ServerEndPoint
[Client Only] The IEndPoint of the server you are connected to. Returns null if you are not connected to any server, or if you are the server.
public IEndPoint ServerEndPoint { get; }
Property Value
ServerSimulation
public ServerSimulation ServerSimulation { get; }
Property Value
Simulation
public Simulation Simulation { get; }
Property Value
SimulationTick
public Tick SimulationTick { get; }
Property Value
SnapshotTick
public Tick SnapshotTick { get; }
Property Value
StartMode
public NetickStartMode StartMode { get; }
Property Value
Tick
public Tick Tick { get; }
Property Value
Timer
public SimulationClock Timer { get; }
Property Value
Transport
public NetworkTransport Transport { get; }
Property Value
UserObject
public object UserObject { get; set; }
Property Value
Methods
AttachBehaviour(INetickScript, bool)
Attaches a INetickScript to the simulation.
public void AttachBehaviour(INetickScript behaviour, bool addToResimulationLoop = true)
Parameters
behaviourINetickScriptaddToResimulationLoopbool
Connect(int, string, byte[], int)
public void Connect(int port, string ip, byte[] connectionData = null, int connectionDataLength = 0)
Parameters
ConnectHost()
public void ConnectHost()
ContainsPlayer(NetworkPlayerId)
public bool ContainsPlayer(NetworkPlayerId playerId)
Parameters
playerIdNetworkPlayerId
Returns
CopyWorldStateTo(int, byte*)
public void CopyWorldStateTo(int blockIndex, byte* target)
Parameters
CopyWorldStateTo(int, byte[])
public void CopyWorldStateTo(int blockIndex, byte[] target)
Parameters
DestroyEntity(Entity, bool, bool)
public void DestroyEntity(Entity entity, bool instant, bool freeMemory)
Parameters
DetachBehaviour(INetickScript)
Detaches a INetickScript from the simulation.
public void DetachBehaviour(INetickScript behaviour)
Parameters
behaviourINetickScript
DisconnectFromServer()
[Client Only] Disconnects this client from the server.
public void DisconnectFromServer()
DisconnectHost()
public void DisconnectHost()
FetchInput<T>(out T, out bool, Entity, int)
public bool FetchInput<T>(out T input, out bool isDuplicated, Entity entity, int localPlayerIndex) where T : unmanaged
Parameters
Returns
Type Parameters
T
FindPlayerByEndPoint(IEndPoint)
public NetworkPlayer FindPlayerByEndPoint(IEndPoint endPoint)
Parameters
endPointIEndPoint
Returns
GetBehaviourOrder(Type)
public int GetBehaviourOrder(Type type)
Parameters
typeType
Returns
GetBehavioursOfType<T>(List<T>)
public void GetBehavioursOfType<T>(List<T> result) where T : INetickScript
Parameters
resultList<T>
Type Parameters
T
GetInput<T>(int)
public T GetInput<T>(int index = 0) where T : unmanaged
Parameters
indexint
Returns
- T
Type Parameters
T
GetPlayerById(NetworkPlayerId)
public NetworkPlayer GetPlayerById(NetworkPlayerId playerId)
Parameters
playerIdNetworkPlayerId
Returns
GetPlayerEntity(NetworkPlayerId)
public Entity GetPlayerEntity(NetworkPlayerId playerId)
Parameters
playerIdNetworkPlayerId
Returns
GetWorldStateBlockCount()
public int GetWorldStateBlockCount()
Returns
GetWorldStateBlockSize()
public long GetWorldStateBlockSize()
Returns
GetWorldStateTotalSize()
Returns the size of the entirety of the game's networked state snapshot size, in bytes. This includes the sizes of all allocated blocks.
public long GetWorldStateTotalSize()
Returns
Kick(ServerConnection, ReadOnlySpan<byte>)
public void Kick(ServerConnection connection, ReadOnlySpan<byte> kickData = default)
Parameters
connectionServerConnectionkickDataReadOnlySpan<byte>
Render()
Call this to invoke NetworkRender on simulated entities. This might not be needed if you are running a headless build.
public void Render()
ResetForSceneSwitch()
public void ResetForSceneSwitch()
SetInput<T>(T, int)
public void SetInput<T>(T input, int index = 0) where T : unmanaged
Parameters
inputTindexint
Type Parameters
T
SetPlayerEntity(NetworkPlayerId, Entity)
public void SetPlayerEntity(NetworkPlayerId playerId, Entity entity)
Parameters
playerIdNetworkPlayerIdentityEntity
Shutdown()
public void Shutdown()
Start(object, string, int, NetickStartMode, IGameEngine, NetickConfigData, NetworkTransport, IReplayTransport, ReflectionData, INetickLogger, IMemoryAllocator, MismatchChecker, int, int, bool, bool, bool, bool, bool)
public void Start(object userObject, string name, int serverPort, NetickStartMode startMode, IGameEngine gameEngine, NetickConfigData config, NetworkTransport networkTransport, IReplayTransport replayTransport, ReflectionData reflectionData, INetickLogger logger, IMemoryAllocator allocator, MismatchChecker mismatchChecker, int gameVersion, int numberOfThreads, bool aggressivePreAllocation, bool fastSerialization, bool isArm32Bit, bool isProfilingEnabled, bool isLoggingEnabled)
Parameters
userObjectobjectnamestringserverPortintstartModeNetickStartModegameEngineIGameEngineconfigNetickConfigDatanetworkTransportNetworkTransportreplayTransportIReplayTransportreflectionDataReflectionDataloggerINetickLoggerallocatorIMemoryAllocatormismatchCheckerMismatchCheckergameVersionintnumberOfThreadsintaggressivePreAllocationboolfastSerializationboolisArm32BitboolisProfilingEnabledboolisLoggingEnabledbool
StartReplayPlayback(string)
public void StartReplayPlayback(string replayAddress)
Parameters
replayAddressstring
StartReplayRecording(string)
public void StartReplayRecording(string replayAddress)
Parameters
replayAddressstring
StopRecordingReplay()
public Task StopRecordingReplay()
Returns
Update(float, float, bool)
Updates Netick logic.
public void Update(float deltaTime, float timeScale, bool simulate)