Skip to main content

Class ServerObjectManagerExtensions

Extra helper methods for that dont add any extra logic

Inheritance
System.Object
Inherited Members
Show
Syntax
public static class ServerObjectManagerExtensions

Methods

AddCharacter(ServerObjectManager, INetworkPlayer, GameObject, Int32)

When is received from a player, the server calls this to associate the character GameObject with the NetworkPlayer. When a character is added for a player the object is automatically spawned, so you do not need to call ServerObjectManager.Spawn for that object. This function is used for adding a character, not replacing. If there is already a character then use instead.

Declaration
public static void AddCharacter(this ServerObjectManager som, INetworkPlayer player, GameObject character, int prefabHash)
Parameters
TypeNameDescription
Mirage.ServerObjectManagersom
Mirage.INetworkPlayerplayerthe Player to add the character to
GameObjectcharacterThe Network Object to add to the Player. Can be spawned or unspawned. Calling this method will respawn it.
System.Int32prefabHashNew prefab hash to give to the player, used for dynamically creating objects at runtime.

AddCharacter(ServerObjectManager, INetworkPlayer, GameObject)

When is received from a player, the server calls this to associate the character GameObject with the NetworkPlayer. When a character is added for a player the object is automatically spawned, so you do not need to call ServerObjectManager.Spawn for that object. This function is used for adding a character, not replacing. If there is already a character then use instead.

Declaration
public static void AddCharacter(this ServerObjectManager som, INetworkPlayer player, GameObject character)
Parameters
TypeNameDescription
Mirage.ServerObjectManagersom
Mirage.INetworkPlayerplayerthe Player to add the character to
GameObjectcharacterThe Network Object to add to the Player. Can be spawned or unspawned. Calling this method will respawn it.

ReplaceCharacter(ServerObjectManager, INetworkPlayer, GameObject, Boolean)

This replaces the player object for a connection with a different player object. The old player object is not destroyed. If a connection already has a player object, this can be used to replace that object with a different player object. This does NOT change the ready state of the connection, so it can safely be used while changing scenes.

Declaration
public static void ReplaceCharacter(this ServerObjectManager som, INetworkPlayer player, GameObject character, bool keepAuthority = false)
Parameters
TypeNameDescription
Mirage.ServerObjectManagersom
Mirage.INetworkPlayerplayerConnection which is adding the player.
GameObjectcharacterPlayer object spawned for the player.
System.BooleankeepAuthorityDoes the previous player remain attached to this connection?

ReplaceCharacter(ServerObjectManager, INetworkPlayer, GameObject, Int32, Boolean)

This replaces the player object for a connection with a different player object. The old player object is not destroyed. If a connection already has a player object, this can be used to replace that object with a different player object. This does NOT change the ready state of the connection, so it can safely be used while changing scenes.

Declaration
public static void ReplaceCharacter(this ServerObjectManager som, INetworkPlayer player, GameObject character, int prefabHash, bool keepAuthority = false)
Parameters
TypeNameDescription
Mirage.ServerObjectManagersom
Mirage.INetworkPlayerplayerConnection which is adding the player.
GameObjectcharacterPlayer object spawned for the player.
System.Int32prefabHash
System.BooleankeepAuthorityDoes the previous player remain attached to this connection?

Spawn(ServerObjectManager, GameObject, GameObject)

Spawns the identity and settings its owner to the player that owns ownerObject

Declaration
public static void Spawn(this ServerObjectManager som, GameObject obj, GameObject ownerObject)
Parameters
TypeNameDescription
Mirage.ServerObjectManagersom
GameObjectobj
GameObjectownerObjectAn object owned by a player

Spawn(ServerObjectManager, GameObject, Int32, INetworkPlayer)

Assigns prefabHash to the obj and then spawns it with owner

can only be set on an identity if the current value is Empty

This method is useful if you are creating network objects at runtime and both server and client know what  to set on an object
Declaration
public static void Spawn(this ServerObjectManager som, GameObject obj, int prefabHash, INetworkPlayer owner = null)
Parameters
TypeNameDescription
Mirage.ServerObjectManagersom
GameObjectobjThe object to spawn.
System.Int32prefabHashThe prefabHash of the object to spawn. Used for custom spawn handlers.
Mirage.INetworkPlayerownerThe connection that has authority over the object

Spawn(ServerObjectManager, GameObject, INetworkPlayer)

Spawns the identity and settings its owner to owner

Declaration
public static void Spawn(this ServerObjectManager som, GameObject obj, INetworkPlayer owner = null)
Parameters
TypeNameDescription
Mirage.ServerObjectManagersom
GameObjectobj
Mirage.INetworkPlayerowner

SpawnInstantiate(ServerObjectManager, GameObject, Nullable<Int32>, INetworkPlayer)

Instantiate a prefab an then Spawns it with ServerObjectManager

Declaration
public static GameObject SpawnInstantiate(this ServerObjectManager som, GameObject prefab, int? prefabHash = default(int? ), INetworkPlayer owner = null)
Parameters
TypeNameDescription
Mirage.ServerObjectManagersom
GameObjectprefab
System.Nullable<System.Int32>prefabHash
Mirage.INetworkPlayerowner
Returns
TypeDescription
GameObject

SpawnInstantiate(ServerObjectManager, NetworkIdentity, Nullable<Int32>, INetworkPlayer)

Instantiate a prefab an then Spawns it with ServerObjectManager

Declaration
public static NetworkIdentity SpawnInstantiate(this ServerObjectManager som, NetworkIdentity prefab, int? prefabHash = default(int? ), INetworkPlayer owner = null)
Parameters
TypeNameDescription
Mirage.ServerObjectManagersom
Mirage.NetworkIdentityprefab
System.Nullable<System.Int32>prefabHash
Mirage.INetworkPlayerowner
Returns
TypeDescription
Mirage.NetworkIdentity