This static class provides utility methods for working with NetworkBehaviour objects. More...
Classes | |
struct | ArrayInitializer |
A utility structure for initializing NetworkArray and NetworkLinkedList with inline initialization. More... | |
struct | DictionaryInitializer |
A utility structure for initializing NetworkDictionary with inline initialization. More... | |
struct | MetaData |
This structure holds metadata for a NetworkBehaviour object. More... | |
Static Public Member Functions | |
static T[] | CloneArray< T > (T[] array) |
Creates a new array that is a clone of the specified array. More... | |
static void | CopyFromNetworkArray< T > (NetworkArray< T > networkArray, ref T[] dstArray) |
Copies the values from a NetworkArray to a destination array. More... | |
static void | CopyFromNetworkDictionary< D, K, V > (NetworkDictionary< K, V > networkDictionary, ref D dictionary) |
Copies the values from a NetworkDictionary to a destination dictionary. More... | |
static void | CopyFromNetworkList< T > (NetworkLinkedList< T > networkList, ref T[] dstArray) |
Copies the values from a NetworkLinkedList to a destination array. More... | |
static MetaData | GetMetaData (Type type) |
Retrieves the metadata for a given type. More... | |
static int | GetRpcStaticIndexOrThrow (string key) |
Retrieves the index of a static RPC (Remote Procedure Call) based on its key. More... | |
static int | GetStaticWordCount (Type type) |
Retrieves the static word count for a given type. If the word count for the type has not been computed yet, it is computed and stored. More... | |
static int | GetWordCount (NetworkBehaviour behaviour) |
Retrieves the word count for a given NetworkBehaviour. If the NetworkBehaviour has a dynamic word count, it is returned. Otherwise, the static word count for the type of the NetworkBehaviour is returned. More... | |
static bool | HasStaticWordCount (Type type) |
Checks if a given type has a static word count. A type has a static word count if it is a subclass of NetworkBehaviour and its word count is non-negative. More... | |
static void | InitializeNetworkArray< T > (NetworkArray< T > networkArray, T[] sourceArray, string name) |
Initializes a NetworkArray with the values from a source array. More... | |
static void | InitializeNetworkDictionary< D, K, V > (NetworkDictionary< K, V > networkDictionary, D dictionary, string name) |
Initializes a NetworkDictionary with the values from a source dictionary. More... | |
static void | InitializeNetworkList< T > (NetworkLinkedList< T > networkList, T[] sourceArray, string name) |
Initializes a NetworkLinkedList with the values from a source array. More... | |
static void | InternalOnDestroy (SimulationBehaviour obj) |
This method is not meant to be called directly. Calls are injected by the Weaver. More... | |
static void | InternalOnDisable (SimulationBehaviour obj) |
This method is not meant to be called directly. Calls are injected by the Weaver. More... | |
static void | InternalOnEnable (SimulationBehaviour obj) |
This method is not meant to be called directly. Calls are injected by the Weaver. More... | |
static SerializableDictionary< K, V > | MakeSerializableDictionary< K, V > (Dictionary< K, V > dictionary) |
Wraps a Dictionary in a SerializableDictionary. More... | |
static void | NotifyLocalSimulationNotAllowedToSendRpc (string rpc, NetworkObject obj, int sources) |
Logs an error message indicating that a local simulation is not allowed to send a specific RPC. More... | |
static void | NotifyLocalTargetedRpcCulled (PlayerRef player, string methodName) |
Logs a warning message indicating that a local targeted RPC was culled. More... | |
static void | NotifyNetworkUnwrapFailed< T > (T wrapper, Type valueType) |
Logs a warning message indicating that a network unwrap operation failed. More... | |
static void | NotifyNetworkWrapFailed< T > (T value) |
Logs a warning message indicating that a network wrap operation failed. More... | |
static void | NotifyNetworkWrapFailed< T > (T value, Type wrapperType) |
Logs a warning message indicating that a network wrap operation failed for a specific wrapper type. More... | |
static void | NotifyRpcPayloadSizeExceeded (string rpc, int size) |
Logs an error message indicating that the target of a Remote Procedure Call (RPC) payload is too large. More... | |
static void | NotifyRpcTargetUnreachable (PlayerRef player, string rpc) |
Logs an error message indicating that the target of a Remote Procedure Call (RPC) is not reachable. More... | |
static void | RegisterMetaData (Type type) |
Registers the metadata for a given type. This method checks if the type has an override for the "ReplicateTo" method and stores this information in the metadata. If the metadata for the type already exists, this method does nothing. More... | |
static void | RegisterRpcInvokeDelegates (Type type) |
Registers the RPC (Remote Procedure Call) invoke delegates for a given type. This method is only available when the FUSION_UNITY compilation symbol is defined. More... | |
static bool | ShouldRegisterRpcInvokeDelegates (Type type) |
Determines whether the RPC (Remote Procedure Call) invoke delegates should be registered for a given type. More... | |
static void | ThrowIfBehaviourNotInitialized (NetworkBehaviour behaviour) |
Checks if the NetworkBehaviour object is initialized and throws an exception if it is not. More... | |
static bool | TryGetRpcInvokeDelegateArray (Type type, out RpcInvokeData[] delegates) |
Tries to get the RPC (Remote Procedure Call) invoke delegate array for a given type. More... | |
static bool | TryGetRpcStaticInvokeDelegate (int index, out RpcStaticInvokeDelegate del) |
Tries to get the static RPC (Remote Procedure Call) invoke delegate based on its index. More... | |
Static Public Attributes | |
static bool | InvokeRpc = false |
A static field that determines whether to invoke RPC (Remote Procedure Call). When set to true, RPCs are invoked. When set to false, RPCs are not invoked. Default value is false. More... | |
This static class provides utility methods for working with NetworkBehaviour objects.
|
static |
Creates a new array that is a clone of the specified array.
T | The type of the elements in the array. |
array | The array to clone. |
|
static |
Copies the values from a NetworkArray to a destination array.
T | The type of the elements in the NetworkArray and destination array. |
networkArray | The NetworkArray from which to copy the values. |
dstArray | The destination array to which to copy the values. |
If the length of the destination array is not equal to the length of the NetworkArray, a new array of the correct length is created and assigned to the destination array.
T | : | unmanaged |
|
static |
Copies the values from a NetworkDictionary to a destination dictionary.
D | The type of the destination dictionary. Must implement IDictionary{K, V} and have a parameterless constructor. |
K | The type of the keys in the NetworkDictionary and destination dictionary. Must be unmanaged. |
V | The type of the values in the NetworkDictionary and destination dictionary. Must be unmanaged. |
networkDictionary | The NetworkDictionary from which to copy the values. |
dictionary | The destination dictionary to which to copy the values. If the destination dictionary is null, a new dictionary of type D is created. |
D | : | IDictionary | |
D | : | K | |
D | : | V | |
D | : | new() | |
K | : | unmanaged | |
V | : | unmanaged |
|
static |
Copies the values from a NetworkLinkedList to a destination array.
T | The type of the elements in the NetworkLinkedList and destination array. |
networkList | The NetworkLinkedList from which to copy the values. |
dstArray | The destination array to which to copy the values. If the length of the destination array is not equal to the count of the NetworkLinkedList, a new array of the correct length is created and assigned to the destination array. |
T | : | unmanaged |
|
static |
Retrieves the metadata for a given type.
type | The type for which to retrieve the metadata. |
|
static |
Retrieves the index of a static RPC (Remote Procedure Call) based on its key.
key | The key of the static RPC. |
System.ArgumentOutOfRangeException | Thrown when the static RPC does not exist. |
|
static |
Retrieves the static word count for a given type. If the word count for the type has not been computed yet, it is computed and stored.
type | The type for which to retrieve the static word count. |
System.ArgumentException | Thrown when the provided type is not a subclass of NetworkBehaviour. |
System.InvalidOperationException | Thrown when the provided type does not have a weaved attribute or its word count is negative. |
|
static |
Retrieves the word count for a given NetworkBehaviour. If the NetworkBehaviour has a dynamic word count, it is returned. Otherwise, the static word count for the type of the NetworkBehaviour is returned.
behaviour | The NetworkBehaviour for which to retrieve the word count. |
System.InvalidOperationException | Thrown when the dynamic word count or the static word count is negative. |
|
static |
Checks if a given type has a static word count. A type has a static word count if it is a subclass of NetworkBehaviour and its word count is non-negative.
type | The type to check. |
System.ArgumentException | Thrown when the provided type is not a subclass of NetworkBehaviour. |
System.InvalidOperationException | Thrown when the provided type does not have a weaved attribute. |
|
static |
Initializes a NetworkArray with the values from a source array.
T | The type of the elements in the NetworkArray and source array. |
networkArray | The NetworkArray to initialize. |
sourceArray | The source array from which to copy the values. |
name | The name of the NetworkArray for logging purposes. |
If the length of the source array is greater than the length of the NetworkArray, a warning is logged and only the first elements up to the length of the NetworkArray are copied.
T | : | unmanaged |
|
static |
Initializes a NetworkDictionary with the values from a source dictionary.
D | The type of the source dictionary. Must implement IDictionary{K, V}. |
K | The type of the keys in the NetworkDictionary and source dictionary. Must be unmanaged. |
V | The type of the values in the NetworkDictionary and source dictionary. Must be unmanaged. |
networkDictionary | The NetworkDictionary to initialize. |
dictionary | The source dictionary from which to copy the values. |
name | The name of the NetworkDictionary for logging purposes. |
If the count of the source dictionary is greater than the capacity of the NetworkDictionary, a warning is logged and only the first elements up to the capacity of the NetworkDictionary are copied.
D | : | IDictionary | |
D | : | K | |
D | : | V | |
K | : | unmanaged | |
V | : | unmanaged |
|
static |
Initializes a NetworkLinkedList with the values from a source array.
T | The type of the elements in the NetworkLinkedList and source array. Must be unmanaged. |
networkList | The NetworkLinkedList to initialize. |
sourceArray | The source array from which to copy the values. |
name | The name of the NetworkLinkedList for logging purposes. |
If the length of the source array is greater than the capacity of the NetworkLinkedList, a warning is logged and only the first elements up to the capacity of the NetworkLinkedList are copied.
T | : | unmanaged |
|
static |
This method is not meant to be called directly. Calls are injected by the Weaver.
obj | SimulationBehaviour object. |
|
static |
This method is not meant to be called directly. Calls are injected by the Weaver.
obj | SimulationBehaviour object. |
|
static |
This method is not meant to be called directly. Calls are injected by the Weaver.
obj | SimulationBehaviour object. |
|
static |
Wraps a Dictionary in a SerializableDictionary.
K | The type of the keys in the dictionary. Must be unmanaged. |
V | The type of the values in the dictionary. Must be unmanaged. |
dictionary | The dictionary to wrap. |
K | : | unmanaged | |
V | : | unmanaged |
|
static |
Logs an error message indicating that a local simulation is not allowed to send a specific RPC.
rpc | The name of the RPC that was attempted. |
obj | The network object on which the RPC was attempted. |
sources | The sources from which the RPC was attempted. |
|
static |
Logs a warning message indicating that a local targeted RPC was culled.
player | The player reference for which the RPC was culled. |
methodName | The name of the method that was culled. |
|
static |
Logs a warning message indicating that a network unwrap operation failed.
T | The type of the wrapper that failed to be unwrapped. |
wrapper | The wrapper that failed to be unwrapped. |
valueType | The type that was attempted to be obtained from the unwrap operation. |
|
static |
Logs a warning message indicating that a network wrap operation failed.
T | The type of the value that failed to be wrapped. |
value | The value that failed to be wrapped. |
|
static |
Logs a warning message indicating that a network wrap operation failed for a specific wrapper type.
T | The type of the value that failed to be wrapped. |
value | The value that failed to be wrapped. |
wrapperType | The type that was attempted to be used as a wrapper. |
|
static |
Logs an error message indicating that the target of a Remote Procedure Call (RPC) payload is too large.
size | Size of the payload. |
rpc | The name of the RPC that was attempted. |
|
static |
Logs an error message indicating that the target of a Remote Procedure Call (RPC) is not reachable.
player | The player reference that is not reachable. |
rpc | The name of the RPC that was attempted. |
|
static |
Registers the metadata for a given type. This method checks if the type has an override for the "ReplicateTo" method and stores this information in the metadata. If the metadata for the type already exists, this method does nothing.
type | The type for which to register the metadata. |
|
static |
Registers the RPC (Remote Procedure Call) invoke delegates for a given type. This method is only available when the FUSION_UNITY compilation symbol is defined.
type | The type for which to register the RPC invoke delegates. |
System.ArgumentException | Thrown when the provided type is not a subclass of NetworkBehaviour. |
System.InvalidOperationException | Thrown when the provided type does not have a weaved attribute or its word count is negative. |
|
static |
Determines whether the RPC (Remote Procedure Call) invoke delegates should be registered for a given type.
type | The type for which to check the registration of RPC invoke delegates. |
|
static |
Checks if the NetworkBehaviour object is initialized and throws an exception if it is not.
behaviour | The NetworkBehaviour object to check. |
System.InvalidOperationException | Thrown when the NetworkBehaviour object is not initialized. |
|
static |
Tries to get the RPC (Remote Procedure Call) invoke delegate array for a given type.
type | The type for which to get the RPC invoke delegate array. |
delegates | When this method returns, contains the RPC invoke delegate array if the type has one; otherwise, null. |
|
static |
Tries to get the static RPC (Remote Procedure Call) invoke delegate based on its index.
index | The index of the static RPC. |
del | When this method returns, contains the static RPC invoke delegate if it exists; otherwise, default. |
|
static |
A static field that determines whether to invoke RPC (Remote Procedure Call). When set to true, RPCs are invoked. When set to false, RPCs are not invoked. Default value is false.