Base class for Fusion network components, which are associated with a NetworkObject. More...
Inherits SimulationBehaviour, ISpawned, IDespawned, IElementReaderWriter< NetworkObject >, and IElementReaderWriter< NetworkBehaviour >.
Inherited by HitboxRoot, NetworkMecanimAnimator, and NetworkTRSP.
Classes | |
struct | ArrayReader |
Provides a reader for network arrays of type T. More... | |
struct | BehaviourReader |
Provides a reader for network behaviours of type T. More... | |
class | ChangeDetector |
Change detector for a NetworkBehaviour More... | |
struct | DictionaryReader |
Provides a reader for network dictionaries with keys of type K and values of type V. More... | |
struct | LinkListReader |
Provides a reader for network linked lists of type T. More... | |
struct | PropertyReader |
Provides a reader for properties of type T in a network behaviour. More... | |
Public Member Functions | |
virtual void | CopyBackingFieldsToState (bool firstTime) |
Copies the backing fields to the state. This method is meant to be overridden in derived classes. More... | |
void | CopyStateFrom (NetworkBehaviour source) |
Copies entire state of passed in source NetworkBehaviour More... | |
virtual void | CopyStateToBackingFields () |
Copies the state to the backing fields. This method is meant to be overridden in derived classes. More... | |
virtual void | Despawned (NetworkRunner runner, bool hasState) |
Called before the network object is despawned More... | |
override void | FixedUpdateNetwork () |
Fixed update callback for networked behaviours. More... | |
ArrayReader< T > | GetArrayReader< T > (string property) |
Gets an ArrayReader for a network array of type T. More... | |
BehaviourReader< T > | GetBehaviourReader< T > (string property) |
Gets a BehaviourReader for a network behaviour of type T. More... | |
ChangeDetector | GetChangeDetector (ChangeDetector.Source source, bool copyInitial=true) |
Creates a ChangeDetector for this network behaviour. More... | |
DictionaryReader< K, V > | GetDictionaryReader< K, V > (string property) |
Gets a DictionaryReader for a network dictionary with keys of type K and values of type V. More... | |
T? | GetInput< T > () |
bool | GetInput< T > (out T input) |
Returns true if it a valid INetworkInput can be found for the current simulation tick (Typically this is used in FixedUpdateNetwork). More... | |
LinkListReader< T > | GetLinkListReader< T > (string property) |
Gets a LinkListReader for a network linked list of type T. More... | |
int | GetLocalAuthorityMask () |
Gets a bitmask of AuthorityMasks flags, representing the current local authority over this NetworkObject. More... | |
PropertyReader< T > | GetPropertyReader< T > (string property) |
Gets a PropertyReader for a property of type T in this network behaviour. More... | |
ref T | ReinterpretState< T > (int offset=0) |
Allows read and write access to the internal state buffer More... | |
void | ReplicateTo (PlayerRef player, bool replicate) |
Controls if this network behaviours state is replicated to a player or not More... | |
void | ReplicateToAll (bool replicate) |
Sets the default replicated state for this behaviour, this by default is true so calling ReplicateToAll(true) does nothing if ReplicateToAll(false) hasn't been called before More... | |
void | ResetState () |
Resets the state of the object to the original state More... | |
virtual void | Spawned () |
Post spawn callback. More... | |
bool | TryGetSnapshotsBuffers (out NetworkBehaviourBuffer from, out NetworkBehaviourBuffer to, out float alpha) |
Tries to get the snapshot buffers for this network behaviour. More... | |
Public Member Functions inherited from SimulationBehaviour | |
virtual void | Render () |
Post simulation frame rendering callback. Runs after all simulations have finished. Use in place of Unity's Update when Fusion is handling Physics. More... | |
Public Member Functions inherited from Behaviour | |
T | AddBehaviour< T > () |
Wrapper for Unity's GameObject.AddComponent() More... | |
T | GetBehaviour< T > () |
Wrapper for Unity's GameObject.GetComponentInChildren() More... | |
bool | TryGetBehaviour< T > (out T behaviour) |
Wrapper for Unity's GameObject.TryGetComponent() More... | |
Public Member Functions inherited from IElementReaderWriter< NetworkObject > | |
int | GetElementHashCode (T element) |
Calculate the hash code of an element. More... | |
int | GetElementWordCount () |
Gets the word count of an element. More... | |
T | Read (byte *data, int index) |
Reads an element from the specified index in the byte array. More... | |
ref T | ReadRef (byte *data, int index) |
Reads a reference to an element from the specified index in the byte array. More... | |
void | Write (byte *data, int index, T element) |
Writes an element to the specified index in the byte array. More... | |
Public Member Functions inherited from IElementReaderWriter< NetworkBehaviour > | |
int | GetElementHashCode (T element) |
Calculate the hash code of an element. More... | |
int | GetElementWordCount () |
Gets the word count of an element. More... | |
T | Read (byte *data, int index) |
Reads an element from the specified index in the byte array. More... | |
ref T | ReadRef (byte *data, int index) |
Reads a reference to an element from the specified index in the byte array. More... | |
void | Write (byte *data, int index, T element) |
Writes an element to the specified index in the byte array. More... | |
Static Public Member Functions | |
static ArrayReader< T > | GetArrayReader< T > (Type behaviourType, string property, IElementReaderWriter< T > readerWriter=null) |
Gets an ArrayReader for a network array of type T in a network behaviour of a specific type. More... | |
static BehaviourReader< T > | GetBehaviourReader< T > (NetworkRunner runner, Type behaviourType, string property) |
Gets a BehaviourReader for a network behaviour of type T. More... | |
static BehaviourReader< TProperty > | GetBehaviourReader< TBehaviour, TProperty > (NetworkRunner runner, string property) |
Gets a BehaviourReader for a network behaviour with a specific property of type TProperty. More... | |
static DictionaryReader< K, V > | GetDictionaryReader< K, V > (Type behaviourType, string property, IElementReaderWriter< K > keyReaderWriter=null, IElementReaderWriter< V > valueReaderWriter=null) |
Gets a DictionaryReader for a network dictionary with keys of type K and values of type V in a network behaviour of a specific type. More... | |
static LinkListReader< T > | GetLinkListReader< T > (Type behaviourType, string property, IElementReaderWriter< T > readerWriter=null) |
Gets a LinkListReader for a network linked list of type T in a network behaviour of a specific type. More... | |
static PropertyReader< T > | GetPropertyReader< T > (Type behaviourType, string property) |
Gets a PropertyReader for a property of type T in a network behaviour of a specific type. More... | |
static PropertyReader< TProperty > | GetPropertyReader< TBehaviour, TProperty > (string property) |
Gets a PropertyReader for a property of type TProperty in a network behaviour of type TBehaviour. More... | |
static NetworkBehaviourUtils.DictionaryInitializer< K, V > | MakeInitializer< K, V > (Dictionary< K, V > dictionary) |
This is a special method that is meant to be used only for [Networked] properties inline initialization. More... | |
static NetworkBehaviourUtils.ArrayInitializer< T > | MakeInitializer< T > (T[] array) |
This is a special method that is meant to be used only for [Networked] properties inline initialization. More... | |
static T * | MakePtr< T > () |
Creates a pointer to a value of type T. This method is meant to be used only for [Networked] properties inline initialization. More... | |
static T * | MakePtr< T > (T defaultValue) |
Creates a pointer to a value of type T, initializing it with the provided default value. This method is meant to be used only for [Networked] properties inline initialization. More... | |
static ref T | MakeRef< T > () |
Creates a reference to a value of type T. This method is meant to be used only for [Networked] properties inline initialization. More... | |
static ref T | MakeRef< T > (T defaultValue) |
Creates a reference to a value of type T, initializing it with the provided default value. This method is meant to be used only for [Networked] properties inline initialization. More... | |
static int | NetworkDeserialize (NetworkRunner runner, byte *data, ref NetworkBehaviour result) |
Deserializes a NetworkBehaviour from a byte array. More... | |
static int | NetworkSerialize (NetworkRunner runner, NetworkBehaviour obj, byte *data) |
Serializes a NetworkBehaviour into a byte array. More... | |
static NetworkBehaviour | NetworkUnwrap (NetworkRunner runner, NetworkBehaviourId wrapper) |
Converts a NetworkBehaviourId to a NetworkBehaviour. More... | |
static NetworkBehaviourId | NetworkWrap (NetworkBehaviour obj) |
Converts a NetworkBehaviour to a NetworkBehaviourId. More... | |
static NetworkBehaviourId | NetworkWrap (NetworkRunner runner, NetworkBehaviour obj) |
Converts a NetworkBehaviour to a NetworkBehaviourId. More... | |
static implicit | operator NetworkBehaviourId (NetworkBehaviour behaviour) |
Converts NetworkBehaviour to NetworkBehaviourId More... | |
Static Public Member Functions inherited from Behaviour | |
static void | DestroyBehaviour (Behaviour behaviour) |
Wrapper for Unity's GameObject.Destroy() More... | |
Public Attributes | |
int | offset |
Gives access to the offset (in 32 bit words) and count (in 32 bit words) of this behaviour backing data More... | |
Protected Member Functions | |
virtual bool | ReplicateTo (PlayerRef player) |
Determines whether to replicate the network behaviour to the specified player. This method can be overridden in derived classes to implement custom replication logic. More... | |
Properties | |
Tick | ChangedTick [get] |
The tick the data on this networked behaviour changed More... | |
virtual ? int | DynamicWordCount [get] |
Override this value for custom memory allocations. This is for advanced use cases only, and cannot be used if NetworkedAttribute is used in the derived class. More... | |
bool? | HasInputAuthority [get] |
Returns true if the Simulation.LocalPlayer of the associated NetworkRunner is the designated as Input Source for this network entity. More... | |
bool? | HasStateAuthority [get] |
Returns true if the associated NetworkRunner is the State Source for this network entity. More... | |
NetworkBehaviourId? | Id [get] |
The unique identifier for this network behaviour. More... | |
bool? | IsProxy [get] |
Returns true if the associated NetworkRunner is neither the Input nor State Authority for this network entity. It is recommended to use !HasStateAuthority or !HasInputAuthority when possible instead, as this check requires evaluating both authorities - and is therefore less performant than the individual checks. More... | |
NetworkBehaviourBuffer | StateBuffer [get] |
Gets the state buffer associated with the network behaviour. More... | |
bool | StateBufferIsValid [get] |
Gets a value indicating whether the state buffer is valid. More... | |
Properties inherited from SimulationBehaviour | |
bool | CanReceiveRenderCallback [get] |
Gets a value indicating whether this instance can receive render callbacks. More... | |
bool | CanReceiveSimulationCallback [get] |
Gets a value indicating whether this instance can receive simulation callbacks. More... | |
NetworkObject | Object [get] |
The NetworkObject this component is associated with. More... | |
NetworkRunner | Runner [get] |
The NetworkRunner this component is associated with. More... | |
Base class for Fusion network components, which are associated with a NetworkObject.
Derived from SimulationBehaviour, components derived from this class are associated with a NetworkRunner and Simulation. Components derived from this class are associated with a parent NetworkObject. and can use the NetworkedAttribute on properties to automate state synchronization, and can use the RpcAttribute on methods, to automate messaging.
|
virtual |
Copies the backing fields to the state. This method is meant to be overridden in derived classes.
firstTime | Indicates whether this is the first time the method is called. |
void CopyStateFrom | ( | NetworkBehaviour | source | ) |
Copies entire state of passed in source NetworkBehaviour
source | Source NetworkBehaviour to copy data from |
|
virtual |
Copies the state to the backing fields. This method is meant to be overridden in derived classes.
|
virtual |
Called before the network object is despawned
runner | The runner that owns the object |
hasState | If the state of the behaviour is still accessible |
Implements IDespawned.
Reimplemented in HitboxRoot.
|
virtual |
Fixed update callback for networked behaviours.
Reimplemented from SimulationBehaviour.
ArrayReader<T> GetArrayReader< T > | ( | string | property | ) |
Gets an ArrayReader for a network array of type T.
T | The type of elements in the network array. |
property | The name of the property to be read. |
|
static |
Gets an ArrayReader for a network array of type T in a network behaviour of a specific type.
T | The type of elements in the network array. |
behaviourType | The type of the network behaviour. |
property | The name of the property to be read. |
readerWriter |
|
static |
Gets a BehaviourReader for a network behaviour of type T.
T | The type of the network behaviour. |
runner | The NetworkRunner associated with the network behaviour. |
behaviourType | The type of the behaviour to be read. |
property | The name of the property to be read. |
T | : | NetworkBehaviour |
BehaviourReader<T> GetBehaviourReader< T > | ( | string | property | ) |
Gets a BehaviourReader for a network behaviour of type T.
T | The type of the network behaviour. |
property | The name of the property to be read. |
T | : | NetworkBehaviour |
|
static |
Gets a BehaviourReader for a network behaviour with a specific property of type TProperty.
TBehaviour | The type of the network behaviour. |
TProperty | The type of the property in the network behaviour. |
runner | The NetworkRunner associated with the network behaviour. |
property | The name of the property to be read. |
TBehaviour | : | NetworkBehaviour | |
TProperty | : | NetworkBehaviour |
ChangeDetector GetChangeDetector | ( | ChangeDetector.Source | source, |
bool | copyInitial = true |
||
) |
Creates a ChangeDetector for this network behaviour.
source | The source of the change detector. |
copyInitial | Indicates whether to copy the initial state of the network behaviour. |
DictionaryReader<K, V> GetDictionaryReader< K, V > | ( | string | property | ) |
Gets a DictionaryReader for a network dictionary with keys of type K and values of type V.
K | The type of keys in the network dictionary. |
V | The type of values in the network dictionary. |
property | The name of the property to be read. |
|
static |
Gets a DictionaryReader for a network dictionary with keys of type K and values of type V in a network behaviour of a specific type.
K | The type of keys in the network dictionary. |
V | The type of values in the network dictionary. |
behaviourType | The type of the network behaviour. |
property | The name of the property to be read. |
keyReaderWriter | |
valueReaderWriter |
T? GetInput< T > | ( | ) |
T |
T | : | unmanaged | |
T | : | INetworkInput |
bool GetInput< T > | ( | out T | input | ) |
Returns true if it a valid INetworkInput can be found for the current simulation tick (Typically this is used in FixedUpdateNetwork).
The returned input struct originates from the NetworkObject.InputAuthority, and if valid contains the inputs supplied by that PlayerRef for the current simulation tick.
T | : | unmanaged | |
T | : | INetworkInput |
LinkListReader<T> GetLinkListReader< T > | ( | string | property | ) |
Gets a LinkListReader for a network linked list of type T.
T | The type of elements in the network linked list. |
property | The name of the property to be read. |
|
static |
Gets a LinkListReader for a network linked list of type T in a network behaviour of a specific type.
T | The type of elements in the network linked list. |
behaviourType | The type of the network behaviour. |
property | The name of the property to be read. |
readerWriter |
int GetLocalAuthorityMask | ( | ) |
Gets a bitmask of AuthorityMasks flags, representing the current local authority over this NetworkObject.
PropertyReader<T> GetPropertyReader< T > | ( | string | property | ) |
Gets a PropertyReader for a property of type T in this network behaviour.
T | The type of the property in the network behaviour. Must be unmanaged. |
property | The name of the property to be read. |
T | : | unmanaged |
|
static |
Gets a PropertyReader for a property of type T in a network behaviour of a specific type.
T | The type of the property in the network behaviour. Must be unmanaged. |
behaviourType | The type of the network behaviour. |
property | The name of the property to be read. |
T | : | unmanaged |
|
static |
Gets a PropertyReader for a property of type TProperty in a network behaviour of type TBehaviour.
TBehaviour | The type of the network behaviour. |
TProperty | The type of the property in the network behaviour. Must be unmanaged. |
property | The name of the property to be read. |
TBehaviour | : | NetworkBehaviour | |
TProperty | : | unmanaged |
|
static |
This is a special method that is meant to be used only for [Networked] properties inline initialization.
|
static |
This is a special method that is meant to be used only for [Networked] properties inline initialization.
|
static |
Creates a pointer to a value of type T. This method is meant to be used only for [Networked] properties inline initialization.
T | The type of the value. Must be unmanaged. |
NotImplementedException | Thrown because this method is meant to be used only for [Networked] properties inline initialization. |
T | : | unmanaged |
|
static |
Creates a pointer to a value of type T, initializing it with the provided default value. This method is meant to be used only for [Networked] properties inline initialization.
T | The type of the value. Must be unmanaged. |
defaultValue | The default value to initialize the value with. |
NotImplementedException | Thrown because this method is meant to be used only for [Networked] properties inline initialization. |
T | : | unmanaged |
|
static |
Creates a reference to a value of type T. This method is meant to be used only for [Networked] properties inline initialization.
T | The type of the value. Must be unmanaged. |
NotImplementedException | Thrown because this method is meant to be used only for [Networked] properties inline initialization. |
T | : | unmanaged |
|
static |
Creates a reference to a value of type T, initializing it with the provided default value. This method is meant to be used only for [Networked] properties inline initialization.
T | The type of the value. Must be unmanaged. |
defaultValue | The default value to initialize the value with. |
NotImplementedException | Thrown because this method is meant to be used only for [Networked] properties inline initialization. |
T | : | unmanaged |
|
static |
Deserializes a NetworkBehaviour from a byte array.
runner | The NetworkRunner associated with the NetworkBehaviour. |
data | The byte pointer to read the serialized data from. |
result | The NetworkBehaviour to store the deserialized data in. |
|
static |
Serializes a NetworkBehaviour into a byte array.
runner | |
obj | The NetworkBehaviour to be serialized. |
data | The byte pointer to write the serialized data to. |
|
static |
Converts a NetworkBehaviourId to a NetworkBehaviour.
runner | The NetworkRunner associated with the NetworkBehaviour. |
wrapper | The NetworkBehaviourId to be converted. |
|
static |
Converts a NetworkBehaviour to a NetworkBehaviourId.
obj | The NetworkBehaviour to be converted. |
|
static |
Converts a NetworkBehaviour to a NetworkBehaviourId.
runner | The NetworkRunner associated with the NetworkBehaviour. |
obj | The NetworkBehaviour to be converted. |
|
static |
Converts NetworkBehaviour to NetworkBehaviourId
behaviour | NetworkBehaviour to convert |
ref T ReinterpretState< T > | ( | int | offset = 0 | ) |
Allows read and write access to the internal state buffer
offset | The offset to generate a ref for, in integer words |
T | The type of the ref to generate |
T | : | unmanaged |
|
protectedvirtual |
Determines whether to replicate the network behaviour to the specified player. This method can be overridden in derived classes to implement custom replication logic.
player | The player to potentially replicate the network behaviour to. |
void ReplicateTo | ( | PlayerRef | player, |
bool | replicate | ||
) |
Controls if this network behaviours state is replicated to a player or not
player | The player to change replication status for |
replicate | true = replicate, false = don't replicate |
void ReplicateToAll | ( | bool | replicate | ) |
Sets the default replicated state for this behaviour, this by default is true so calling ReplicateToAll(true) does nothing if ReplicateToAll(false) hasn't been called before
replicate | The default state of this behaviour |
void ResetState | ( | ) |
Resets the state of the object to the original state
|
virtual |
Post spawn callback.
Implements ISpawned.
Reimplemented in NetworkTransform, and NetworkMecanimAnimator.
bool TryGetSnapshotsBuffers | ( | out NetworkBehaviourBuffer | from, |
out NetworkBehaviourBuffer | to, | ||
out float | alpha | ||
) |
Tries to get the snapshot buffers for this network behaviour.
from | The buffer representing the state of the network behaviour at the start of the render frame. |
to | The buffer representing the state of the network behaviour at the end of the render frame. |
alpha | The interpolation factor between the start and end of the render frame. |
int offset |
Gives access to the offset (in 32 bit words) and count (in 32 bit words) of this behaviour backing data
|
get |
The tick the data on this networked behaviour changed
|
get |
Override this value for custom memory allocations. This is for advanced use cases only, and cannot be used if NetworkedAttribute is used in the derived class.
|
get |
Returns true if the Simulation.LocalPlayer of the associated NetworkRunner is the designated as Input Source for this network entity.
|
get |
Returns true if the associated NetworkRunner is the State Source for this network entity.
|
get |
The unique identifier for this network behaviour.
|
get |
Returns true if the associated NetworkRunner is neither the Input nor State Authority for this network entity. It is recommended to use !HasStateAuthority or !HasInputAuthority when possible instead, as this check requires evaluating both authorities - and is therefore less performant than the individual checks.
|
get |
Gets the state buffer associated with the network behaviour.
|
get |
Gets a value indicating whether the state buffer is valid.