Table of Contents

Class NetworkBehaviour

Namespace
Netick.Unity
Assembly
Netick.Unity.dll

Base class for all networked behaviors in Netick. Inherit from this class to create network-synchronized logic. Provides access to network state, input, and misc utility methods.

public abstract class NetworkBehaviour : NetickBehaviour, INetickNetworkScript, INetickScript
Inheritance
NetworkBehaviour
Implements
Derived
Inherited Members

Constructors

NetworkBehaviour()

protected NetworkBehaviour()

Fields

StatePtr

public int* StatePtr

Field Value

int*

Properties

BehaviourId

The network id of this NetworkBehaviour.

public int BehaviourId { get; }

Property Value

int

Id

The network id of this object.

public int Id { get; }

Property Value

int

InputSource

Returns the source NetworkPlayer (NetworkPeer/ServerConnection) of inputs for this NetworkObject. If the source of inputs is remote (from a client) it returns that ServerConnection, while on the input source itself it returns the local NetworkPlayer.

Use InputSourcePlayerId for the synced-to-everyone player id of the Input Source - because InputSource is only valid in the client for objects the client itself is the input source of, and it's null for everything else.

public NetworkPlayer InputSource { get; set; }

Property Value

NetworkPlayer

InputSourcePlayerId

Returns the NetworkPlayerId of the input source of this object. This is synced to every client.

public NetworkPlayerId InputSourcePlayerId { get; }

Property Value

NetworkPlayerId

IsClient

Returns true if this NetworkSandbox is a client.

public bool IsClient { get; }

Property Value

bool

IsHost

Returns true if this NetworkSandbox is the host.

public bool IsHost { get; }

Property Value

bool

IsInputSource

Returns true if this LocalPlayer is providing inputs to this Object.

public bool IsInputSource { get; }

Property Value

bool

IsInterested

On the client, returns true if this client is interested in this object. On the server, always returns true.

public bool IsInterested { get; }

Property Value

bool

IsOwner

Returns true if this NetworkSandbox is the owner of this Object. In this version of Netick: Server=Owner.

public bool IsOwner { get; }

Property Value

bool

IsPlayer

Returns true if this NetworkSandbox is a client or the host.

public bool IsPlayer { get; }

Property Value

bool

IsPredicted

On the client returns true only if the client is predicting this object. On the server, always returns true.

public bool IsPredicted { get; }

Property Value

bool

IsProxy

Returns true if we neither provide inputs nor own this object.

public bool IsProxy { get; }

Property Value

bool

IsReplay

Returns true if this NetworkSandbox is running in ReplayClient mode.

public bool IsReplay { get; }

Property Value

bool

IsResimulating

Returns true if we are currently resimulating a previous input of the past. On the server, it always returns false since only the clients resimulate.

public bool IsResimulating { get; }

Property Value

bool

IsServer

Returns true if this NetworkSandbox is the server.

public bool IsServer { get; }

Property Value

bool

StateSize

Returns the networked state size of this behavior in bytes.

public virtual int StateSize { get; }

Property Value

int

Methods

ClearState(bool)

Zeros out the networked state memory of this behavior. Ignores InputSource Relevancy.

public virtual void ClearState(bool invokeOnChanged = true)

Parameters

invokeOnChanged bool

CopyStateTo(byte*)

Copies the state of this behavior into target.

public virtual void CopyStateTo(byte* target)

Parameters

target byte*

CopyStateTo(byte[])

Copies the state of this behavior into target.

public virtual void CopyStateTo(byte[] target)

Parameters

target byte[]

FetchInput<T>(out T, out bool, int)

Fetches a network input for this tick. Returns false if no input source is currently providing inputs to this Object, or when input loss occurs (in case of a remote input source).

public bool FetchInput<T>(out T input, out bool isDuplicated, int index = 0) where T : unmanaged

Parameters

input T
isDuplicated bool
index int

Returns

bool

Type Parameters

T

FetchInput<T>(out T, int)

Fetches a network input for this tick. Returns false if no input source is currently providing inputs to this Object, or when input loss occurs (in case of a remote input source).

public bool FetchInput<T>(out T input, int index = 0) where T : unmanaged

Parameters

input T
index int

Returns

bool

Type Parameters

T

FindInterpolator(string)

public Interpolator FindInterpolator(string propertyName)

Parameters

propertyName string

Returns

Interpolator

GetRef<T>()

public NetworkBehaviourRef<T> GetRef<T>() where T : NetworkBehaviour

Returns

NetworkBehaviourRef<T>

Type Parameters

T

GetStateRef()

public BehaviourStateRef GetStateRef()

Returns

BehaviourStateRef

InternalGetStateSizeWords()

public virtual int InternalGetStateSizeWords()

Returns

int

InternalInit()

public virtual void InternalInit()

InternalReset()

public virtual void InternalReset()

NetworkAwake()

public virtual void NetworkAwake()

NetworkReset()

[Obsolete("Use NetworkStart/NetworkAwake instead.")]
public virtual void NetworkReset()

OnBecameInterested()

Called in the client when the client becomes interested in this object.

public virtual void OnBecameInterested()

OnBecameUninterested()

Called in the client when the client becomes uninterested in this object.

public virtual void OnBecameUninterested()

OnInputSourceChanged(NetworkPlayer)

Called in the server (or the client if it is the input source) when the input source of this Object has changed.

public virtual void OnInputSourceChanged(NetworkPlayer previous)

Parameters

previous NetworkPlayer

OnInputSourceLeft()

Called on the server when the input source of this Object has disconnected.

public virtual void OnInputSourceLeft()

SetStateFrom(BehaviourStateRef, byte*, bool)

public virtual void SetStateFrom(BehaviourStateRef stateRef, byte* worldSnapshot, bool invokeOnChanged = true)

Parameters

stateRef BehaviourStateRef
worldSnapshot byte*
invokeOnChanged bool

SetStateFrom(BehaviourStateRef, byte[], bool)

public virtual void SetStateFrom(BehaviourStateRef stateRef, byte[] worldSnapshot, bool invokeOnChanged = true)

Parameters

stateRef BehaviourStateRef
worldSnapshot byte[]
invokeOnChanged bool

SetStateFrom(byte*, bool)

Sets the state of this behavior. Ignores InputSource Relevancy.

public virtual void SetStateFrom(byte* source, bool invokeOnChanged = true)

Parameters

source byte*
invokeOnChanged bool

SetStateFrom(byte[], bool)

Sets the state of this behavior. Ignores InputSource Relevancy.

public virtual void SetStateFrom(byte[] source, bool invokeOnChanged = true)

Parameters

source byte[]
invokeOnChanged bool