Table of Contents

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

List<IClientSimulationCallbacks>

SimulatedLossIn

public float SimulatedLossIn

Field Value

float

SimulatedLossOut

public float SimulatedLossOut

Field Value

float

Properties

AllEntities

public IReadOnlyDictionary<int, Entity> AllEntities { get; }

Property Value

IReadOnlyDictionary<int, Entity>

AuthoritativeTick

public Tick AuthoritativeTick { get; }

Property Value

Tick

Client

public Client Client { get; }

Property Value

Client

ClientSimulation

public ClientSimulation ClientSimulation { get; }

Property Value

ClientSimulation

Config

public NetickConfigData Config { get; }

Property Value

NetickConfigData

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

IReadOnlyList<ServerConnection>

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

IReadOnlyList<NetworkPlayer>

CurrentRpcCaller

public NetworkPlayer CurrentRpcCaller { get; }

Property Value

NetworkPlayer

CurrentRpcSource

public NetworkConnection CurrentRpcSource { get; }

Property Value

NetworkConnection

Entities

public IReadOnlyDictionary<int, Entity> Entities { get; }

Property Value

IReadOnlyDictionary<int, Entity>

FixedDeltaTime

Time period between simulation ticks.

public float FixedDeltaTime { get; }

Property Value

float

GameVersion

public int GameVersion { get; }

Property Value

int

InKBps

Average incoming data in kilobytes per second (KBps).

public float InKBps { get; }

Property Value

float

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

float

InterestManagement

public InterestManagement InterestManagement { get; }

Property Value

InterestManagement

InterpolationDelay

[Client Only] Interpolation delay in seconds.

public float InterpolationDelay { get; }

Property Value

float

IsClient

public bool IsClient { get; }

Property Value

bool

IsConnected

[Client Only] Returns true if this client is currently connected to a server.

public bool IsConnected { get; }

Property Value

bool

IsFirstNetworkFixedUpdateCall

public bool IsFirstNetworkFixedUpdateCall { get; }

Property Value

bool

IsIMEnabled

public bool IsIMEnabled { get; }

Property Value

bool

IsInputEnabled

public bool IsInputEnabled { get; set; }

Property Value

bool

IsInvokingNetworkRender

public bool IsInvokingNetworkRender { get; }

Property Value

bool

IsLastNetworkFixedUpdateCall

public bool IsLastNetworkFixedUpdateCall { get; }

Property Value

bool

IsOffline

public bool IsOffline { get; }

Property Value

bool

IsRecording

public bool IsRecording { get; }

Property Value

bool

IsReplay

public bool IsReplay { get; }

Property Value

bool

IsReplayEnabled

public bool IsReplayEnabled { get; }

Property Value

bool

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

bool

IsRunning

public bool IsRunning { get; }

Property Value

bool

IsServer

public bool IsServer { get; }

Property Value

bool

LagCompensation

public INetickComponent LagCompensation { get; }

Property Value

INetickComponent

LocalInterpolation

public LocalInterpolation LocalInterpolation { get; }

Property Value

LocalInterpolation

LocalPeer

public NetworkPeer LocalPeer { get; }

Property Value

NetworkPeer

LocalPlayer

public NetworkPeer LocalPlayer { get; }

Property Value

NetworkPeer

MaxClients

public int MaxClients { get; }

Property Value

int

MaxPlayers

public int MaxPlayers { get; }

Property Value

int

Monitor

public Monitor Monitor { get; }

Property Value

Monitor

Name

public string Name { get; }

Property Value

string

OnPostNetworkStart

public Action OnPostNetworkStart { get; set; }

Property Value

Action

OnTickEnd

public Action OnTickEnd { get; set; }

Property Value

Action

OnTickStart

public Action OnTickStart { get; set; }

Property Value

Action

OutKBps

Average outgoing data in kilobytes per second (KBps).

public float OutKBps { get; }

Property Value

float

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

float

Players

public IReadOnlyList<NetworkPlayerId> Players { get; }

Property Value

IReadOnlyList<NetworkPlayerId>

Port

public int Port { get; }

Property Value

int

PostNetworkFixedUpdate

public Action PostNetworkFixedUpdate { get; set; }

Property Value

Action

PostNetworkRender

public Action PostNetworkRender { get; set; }

Property Value

Action

PostNetworkUpdate

public Action PostNetworkUpdate { get; set; }

Property Value

Action

PostResimulation

public Action PostResimulation { get; set; }

Property Value

Action

PostRollback

public Action PostRollback { get; set; }

Property Value

Action

PreNetworkFixedUpdate

public Action PreNetworkFixedUpdate { get; set; }

Property Value

Action

PreNetworkRender

public Action PreNetworkRender { get; set; }

Property Value

Action

PreNetworkUpdate

public Action PreNetworkUpdate { get; set; }

Property Value

Action

PreRollback

public Action PreRollback { get; set; }

Property Value

Action

PredictedTick

public Tick PredictedTick { get; }

Property Value

Tick

RTT

[Client Only] The round-trip time (RTT) of the client in seconds.

public double RTT { get; }

Property Value

double

RemoteInterpolation

public RemoteInterpolation RemoteInterpolation { get; }

Property Value

RemoteInterpolation

Replay

public Replay Replay { get; }

Property Value

Replay

Server

public Server Server { get; }

Property Value

Server

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

IEndPoint

ServerSimulation

public ServerSimulation ServerSimulation { get; }

Property Value

ServerSimulation

Simulation

public Simulation Simulation { get; }

Property Value

Simulation

SimulationTick

public Tick SimulationTick { get; }

Property Value

Tick

SnapshotTick

public Tick SnapshotTick { get; }

Property Value

Tick

StartMode

public NetickStartMode StartMode { get; }

Property Value

NetickStartMode

Tick

public Tick Tick { get; }

Property Value

Tick

Timer

public SimulationClock Timer { get; }

Property Value

SimulationClock

Transport

public NetworkTransport Transport { get; }

Property Value

NetworkTransport

UserObject

public object UserObject { get; set; }

Property Value

object

Methods

AttachBehaviour(INetickScript, bool)

Attaches a INetickScript to the simulation.

public void AttachBehaviour(INetickScript behaviour, bool addToResimulationLoop = true)

Parameters

behaviour INetickScript
addToResimulationLoop bool

Connect(int, string, byte[], int)

public void Connect(int port, string ip, byte[] connectionData = null, int connectionDataLength = 0)

Parameters

port int
ip string
connectionData byte[]
connectionDataLength int

ConnectHost()

public void ConnectHost()

ContainsPlayer(NetworkPlayerId)

public bool ContainsPlayer(NetworkPlayerId playerId)

Parameters

playerId NetworkPlayerId

Returns

bool

CopyWorldStateTo(int, byte*)

public void CopyWorldStateTo(int blockIndex, byte* target)

Parameters

blockIndex int
target byte*

CopyWorldStateTo(int, byte[])

public void CopyWorldStateTo(int blockIndex, byte[] target)

Parameters

blockIndex int
target byte[]

DestroyEntity(Entity, bool, bool)

public void DestroyEntity(Entity entity, bool instant, bool freeMemory)

Parameters

entity Entity
instant bool
freeMemory bool

DetachBehaviour(INetickScript)

Detaches a INetickScript from the simulation.

public void DetachBehaviour(INetickScript behaviour)

Parameters

behaviour INetickScript

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

input T
isDuplicated bool
entity Entity
localPlayerIndex int

Returns

bool

Type Parameters

T

FindPlayerByEndPoint(IEndPoint)

public NetworkPlayer FindPlayerByEndPoint(IEndPoint endPoint)

Parameters

endPoint IEndPoint

Returns

NetworkPlayer

GetBehaviourOrder(Type)

public int GetBehaviourOrder(Type type)

Parameters

type Type

Returns

int

GetBehavioursOfType<T>(List<T>)

public void GetBehavioursOfType<T>(List<T> result) where T : INetickScript

Parameters

result List<T>

Type Parameters

T

GetInput<T>(int)

public T GetInput<T>(int index = 0) where T : unmanaged

Parameters

index int

Returns

T

Type Parameters

T

GetPlayerById(NetworkPlayerId)

public NetworkPlayer GetPlayerById(NetworkPlayerId playerId)

Parameters

playerId NetworkPlayerId

Returns

NetworkPlayer

GetPlayerEntity(NetworkPlayerId)

public Entity GetPlayerEntity(NetworkPlayerId playerId)

Parameters

playerId NetworkPlayerId

Returns

Entity

GetWorldStateBlockCount()

public int GetWorldStateBlockCount()

Returns

int

GetWorldStateBlockSize()

public long GetWorldStateBlockSize()

Returns

long

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

long

Kick(ServerConnection, ReadOnlySpan<byte>)

public void Kick(ServerConnection connection, ReadOnlySpan<byte> kickData = default)

Parameters

connection ServerConnection
kickData ReadOnlySpan<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

input T
index int

Type Parameters

T

SetPlayerEntity(NetworkPlayerId, Entity)

public void SetPlayerEntity(NetworkPlayerId playerId, Entity entity)

Parameters

playerId NetworkPlayerId
entity Entity

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

userObject object
name string
serverPort int
startMode NetickStartMode
gameEngine IGameEngine
config NetickConfigData
networkTransport NetworkTransport
replayTransport IReplayTransport
reflectionData ReflectionData
logger INetickLogger
allocator IMemoryAllocator
mismatchChecker MismatchChecker
gameVersion int
numberOfThreads int
aggressivePreAllocation bool
fastSerialization bool
isArm32Bit bool
isProfilingEnabled bool
isLoggingEnabled bool

StartReplayPlayback(string)

public void StartReplayPlayback(string replayAddress)

Parameters

replayAddress string

StartReplayRecording(string)

public void StartReplayRecording(string replayAddress)

Parameters

replayAddress string

StopRecordingReplay()

public Task StopRecordingReplay()

Returns

Task

Update(float, float, bool)

Updates Netick logic.

public void Update(float deltaTime, float timeScale, bool simulate)

Parameters

deltaTime float
timeScale float
simulate bool