Table of Contents

Class MirrorExtensions

Namespace
Exiled.API.Extensions
Assembly
Exiled.API.dll

A set of extensions for Mirror Networking.

public static class MirrorExtensions
Inheritance
MirrorExtensions
Inherited Members

Properties

RpcFullNames

Gets Rpc's FullName string corresponding to StringExtensions(format:classname.methodname).

public static ReadOnlyDictionary<string, string> RpcFullNames { get; }

Property Value

ReadOnlyDictionary<string, string>

SendSpawnMessageMethodInfo

Gets a NetworkServer.SendSpawnMessage's MethodInfo.

public static MethodInfo SendSpawnMessageMethodInfo { get; }

Property Value

MethodInfo

SetDirtyBitsMethodInfo

public static MethodInfo SetDirtyBitsMethodInfo { get; }

Property Value

MethodInfo

SyncVarDirtyBits

Gets a all DirtyBit ulong from StringExtensions(format:classname.methodname).

public static ReadOnlyDictionary<string, ulong> SyncVarDirtyBits { get; }

Property Value

ReadOnlyDictionary<string, ulong>

WriterExtensions

Gets MethodInfo corresponding to Type.

public static ReadOnlyDictionary<Type, MethodInfo> WriterExtensions { get; }

Property Value

ReadOnlyDictionary<Type, MethodInfo>

Methods

ChangeAppearance(Player, RoleTypeId, bool, byte)

Change Player character model for appearance. It will continue until Player's PlayerRoles.RoleTypeId changes.

public static void ChangeAppearance(this Player player, RoleTypeId type, bool skipJump = false, byte unitId = 0)

Parameters

player Player

Player to change.

type RoleTypeId

Model type.

skipJump bool

Whether to skip the little jump that works around an invisibility issue.

unitId byte

The UnitNameId to use for the player's new role, if the player's new role uses unit names. (is NTF).

ChangeAppearance(Player, RoleTypeId, IEnumerable<Player>, bool, byte)

Change Player character model for appearance. It will continue until Player's PlayerRoles.RoleTypeId changes.

public static void ChangeAppearance(this Player player, RoleTypeId type, IEnumerable<Player> playersToAffect, bool skipJump = false, byte unitId = 0)

Parameters

player Player

Player to change.

type RoleTypeId

Model type.

playersToAffect IEnumerable<Player>

The players who should see the changed appearance.

skipJump bool

Whether to skip the little jump that works around an invisibility issue.

unitId byte

The UnitNameId to use for the player's new role, if the player's new role uses unit names. (is NTF).

ChangeSceneToAllClients(ScenesType)

Emulation of the method SCP:SL uses to change scene.

public static void ChangeSceneToAllClients(ScenesType scene)

Parameters

scene ScenesType

The new Scene the client will load.

EditNetworkObject(NetworkIdentity, Action<NetworkIdentity>)

Edit Mirror.NetworkIdentity's parameter and sync.

public static void EditNetworkObject(NetworkIdentity identity, Action<NetworkIdentity> customAction)

Parameters

identity NetworkIdentity

Target object.

customAction Action<NetworkIdentity>

Edit function.

MessageTranslated(Player, string, string, bool, bool, bool)

Send CASSIE announcement with custom subtitles for translation that only Player can hear and see it.

public static void MessageTranslated(this Player player, string words, string translation, bool makeHold = false, bool makeNoise = true, bool isSubtitles = true)

Parameters

player Player

Target to send.

words string

The message to be reproduced.

translation string

The translation should be show in the subtitles.

makeHold bool

Same on MessageTranslated(string, string, bool, bool, bool)'s isHeld.

makeNoise bool

Same on MessageTranslated(string, string, bool, bool, bool)'s isNoisy.

isSubtitles bool

Same on MessageTranslated(string, string, bool, bool, bool)'s isSubtitles.

MoveNetworkIdentityObject(Player, NetworkIdentity, Vector3)

Moves object for the player.

public static void MoveNetworkIdentityObject(this Player player, NetworkIdentity identity, Vector3 pos)

Parameters

player Player

Target to send.

identity NetworkIdentity

The Mirror.NetworkIdentity to move.

pos Vector3

The position to change.

MoveNetworkIdentityObject(NetworkIdentity, Vector3)

Moves object for all the players.

public static void MoveNetworkIdentityObject(this NetworkIdentity identity, Vector3 pos)

Parameters

identity NetworkIdentity

The Mirror.NetworkIdentity to move.

pos Vector3

The position to change.

PlayBeepSound(Player)

Plays a beep sound that only the target player can hear.

public static void PlayBeepSound(this Player player)

Parameters

player Player

Target to play sound to.

PlayCassieAnnouncement(Player, string, bool, bool, bool)

Send CASSIE announcement that only Player can hear.

public static void PlayCassieAnnouncement(this Player player, string words, bool makeHold = false, bool makeNoise = true, bool isSubtitles = false)

Parameters

player Player

Target to send.

words string

Announcement words.

makeHold bool

Same on Message(string, bool, bool, bool)'s isHeld.

makeNoise bool

Same on Message(string, bool, bool, bool)'s isNoisy.

isSubtitles bool

Same on Message(string, bool, bool, bool)'s isSubtitles.

PlayGunSound(Player, Vector3, ItemType, byte, byte)

Plays a gun sound that only the player can hear.

public static void PlayGunSound(this Player player, Vector3 position, ItemType itemType, byte volume, byte audioClipId = 0)

Parameters

player Player

Target to play.

position Vector3

Position to play on.

itemType ItemType

Weapon' sound to play.

volume byte

Sound's volume to set.

audioClipId byte

GunAudioMessage's audioClipId to set (default = 0).

ResetIntercomDisplayText()

Resync DisplayText.

public static void ResetIntercomDisplayText()

ResyncSyncVar(NetworkIdentity, Type, string)

Force resync to client's Mirror.SyncVarAttribute.

public static void ResyncSyncVar(NetworkIdentity behaviorOwner, Type targetType, string propertyName)

Parameters

behaviorOwner NetworkIdentity

Mirror.NetworkIdentity of object that owns Mirror.NetworkBehaviour.

targetType Type

Mirror.NetworkBehaviour's type.

propertyName string

Property name starting with Network.

ScaleNetworkIdentityObject(Player, NetworkIdentity, Vector3)

Scales an object for the specified player.

public static void ScaleNetworkIdentityObject(this Player player, NetworkIdentity identity, Vector3 scale)

Parameters

player Player

Target to send.

identity NetworkIdentity

The Mirror.NetworkIdentity to scale.

scale Vector3

The scale the object needs to be set to.

ScaleNetworkIdentityObject(NetworkIdentity, Vector3)

Scales an object for all players.

public static void ScaleNetworkIdentityObject(this NetworkIdentity identity, Vector3 scale)

Parameters

identity NetworkIdentity

The Mirror.NetworkIdentity to scale.

scale Vector3

The scale the object needs to be set to.

SendFakeSceneLoading(Player, ScenesType)

Sends to the player a Fake Change Scene.

public static void SendFakeSceneLoading(this Player player, ScenesType newSceneName)

Parameters

player Player

The player to send the Scene.

newSceneName ScenesType

The new Scene the client will load.

SendFakeSyncObject(Player, NetworkIdentity, Type, Action<NetworkWriter>)

Send fake values to client's Mirror.SyncObject.

public static void SendFakeSyncObject(Player target, NetworkIdentity behaviorOwner, Type targetType, Action<NetworkWriter> customAction)

Parameters

target Player

Target to send.

behaviorOwner NetworkIdentity

Mirror.NetworkIdentity of object that owns Mirror.NetworkBehaviour.

targetType Type

Mirror.NetworkBehaviour's type.

customAction Action<NetworkWriter>

Custom writing action.

Examples

EffectOnlySCP207.

MirrorExtensions.SendFakeSyncObject(player, player.NetworkIdentity, typeof(PlayerEffectsController), (writer) => {
 writer.WriteULong(1ul);                                            // DirtyObjectsBit
 writer.WriteUInt(1);                                               // DirtyIndexCount
 writer.WriteByte((byte)SyncList<byte>.Operation.OP_SET);     // Operations
 writer.WriteUInt(17);                                              // EditIndex
});

SendFakeSyncVar<T>(Player, NetworkIdentity, Type, string, T)

Send fake values to client's Mirror.SyncVarAttribute.

public static void SendFakeSyncVar<T>(this Player target, NetworkIdentity behaviorOwner, Type targetType, string propertyName, T value)

Parameters

target Player

Target to send.

behaviorOwner NetworkIdentity

Mirror.NetworkIdentity of object that owns Mirror.NetworkBehaviour.

targetType Type

Mirror.NetworkBehaviour's type.

propertyName string

Property name starting with Network.

value T

Value of send to target.

Type Parameters

T

Target SyncVar property type.

SendFakeTargetRpc(Player, NetworkIdentity, Type, string, params object[])

Send fake values to client's Mirror.ClientRpcAttribute.

public static void SendFakeTargetRpc(Player target, NetworkIdentity behaviorOwner, Type targetType, string rpcName, params object[] values)

Parameters

target Player

Target to send.

behaviorOwner NetworkIdentity

Mirror.NetworkIdentity of object that owns Mirror.NetworkBehaviour.

targetType Type

Mirror.NetworkBehaviour's type.

rpcName string

Property name starting with Rpc.

values object[]

Values of send to target.

SetIntercomDisplayTextForTargetOnly(Player, string)

Sets DisplayText that only the target player can see.

public static void SetIntercomDisplayTextForTargetOnly(this Player target, string text)

Parameters

target Player

Only this player can see Display Text.

text string

Text displayed to the player.

SetName(Player, Player, string)

Sets DisplayNickname of a player that only the target player can see.

public static void SetName(this Player target, Player player, string name)

Parameters

target Player

Only this player can see the name changed.

player Player

Player that will desync the CustomName.

name string

Nickname to set.

SetPlayerInfoForTargetOnly(Player, Player, string)

Set CustomInfo on the target player that only the player can see.

public static void SetPlayerInfoForTargetOnly(this Player player, Player target, string info)

Parameters

player Player

Only this player can see info.

target Player

Target to set info.

info string

Setting info.

SetRoomColorForTargetOnly(Room, Player, Color)

Sets Color of a room that only the target player can see.

public static void SetRoomColorForTargetOnly(this Room room, Player target, Color color)

Parameters

room Room

Room to modify.

target Player

Only this player can see room color.

color Color

Color to set.

SetRoomLightsForTargetOnly(Room, Player, bool)

Sets the lights of a room to be either on or off, visible only to the target player.

public static void SetRoomLightsForTargetOnly(this Room room, Player target, bool value)

Parameters

room Room

The room to modify the lights of.

target Player

The player who will see the lights state change.

value bool

The state to set the lights to. True for on, false for off.