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
AdminToyBaseSyncVars
Gets all AdminToys.AdminToyBase sync var names.
public static string[] AdminToyBaseSyncVars { get; }
Property Value
- string[]
RpcFullNames
Gets Rpc's FullName string corresponding to StringExtensions(format:classname.methodname).
public static ReadOnlyDictionary<string, string> RpcFullNames { get; }
Property Value
SendSpawnMessageMethodInfo
Gets a NetworkServer.SendSpawnMessage's MethodInfo.
public static MethodInfo SendSpawnMessageMethodInfo { get; }
Property Value
SetDirtyBitsMethodInfo
Gets a SetSyncVarDirtyBit(ulong)'s MethodInfo.
public static MethodInfo SetDirtyBitsMethodInfo { get; }
Property Value
SyncVarDirtyBits
Gets a all DirtyBit ulong from StringExtensions(format:classname.methodname).
public static ReadOnlyDictionary<string, ulong> SyncVarDirtyBits { get; }
Property Value
WriterExtensions
Gets MethodInfo corresponding to Type.
public static ReadOnlyDictionary<Type, MethodInfo> WriterExtensions { get; }
Property Value
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
playerPlayerPlayer to change.
typeRoleTypeIdModel type.
skipJumpboolWhether to skip the little jump that works around an invisibility issue.
unitIdbyteThe 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
playerPlayerPlayer to change.
typeRoleTypeIdModel type.
playersToAffectIEnumerable<Player>The players who should see the changed appearance.
skipJumpboolWhether to skip the little jump that works around an invisibility issue.
unitIdbyteThe 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
sceneScenesTypeThe 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
identityNetworkIdentityTarget object.
customActionAction<NetworkIdentity>Edit function.
MessageTranslated(Player, string, 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, string customSubtitles, bool makeHold = false, bool makeNoise = true, bool isSubtitles = true)
Parameters
playerPlayerTarget to send.
wordsstringThe message to be reproduced.
translationstringThe translation should be show in the subtitles.
customSubtitlesstringThe custom subtitles to show.
makeHoldboolSame on MessageTranslated(string, string, bool, bool, bool)'s isHeld.
makeNoiseboolSame on MessageTranslated(string, string, bool, bool, bool)'s isNoisy.
isSubtitlesboolSame 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
playerPlayerTarget to send.
identityNetworkIdentityThe Mirror.NetworkIdentity to move.
posVector3The position to change.
MoveNetworkIdentityObject(NetworkIdentity, Vector3)
Moves object for all the players.
public static void MoveNetworkIdentityObject(this NetworkIdentity identity, Vector3 pos)
Parameters
identityNetworkIdentityThe Mirror.NetworkIdentity to move.
posVector3The position to change.
PlaceBlood(Player, Vector3, Vector3, RoleTypeId, int)
Place blood that only the player can see.
[Obsolete("Use Player::SpawnBlood(Vector3, Vector3) instead.")]
public static void PlaceBlood(this Player player, Vector3 position, Vector3 origin, RoleTypeId roleTypeId, int gettingShotSoundIndex)
Parameters
playerPlayerTarget to play.
positionVector3The position of the blood decal.
originVector3The direction of the blood decal.
roleTypeIdRoleTypeIdThe RoleTypeId from who blood come from.
gettingShotSoundIndexintThe sound than player get when getting shot.
PlayBeepSound(Player)
Plays a beep sound that only the target player can hear.
public static void PlayBeepSound(this Player player)
Parameters
playerPlayerTarget 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
playerPlayerTarget to send.
wordsstringAnnouncement words.
makeHoldboolSame on Message(string, bool, bool, bool)'s isHeld.
makeNoiseboolSame on Message(string, bool, bool, bool)'s isNoisy.
isSubtitlesboolSame on Message(string, bool, bool, bool)'s isSubtitles.
PlayGunSound(Player, FirearmType, int, Vector3, MixerChannel, float?, float?)
Plays a gun sound that only the player can hear.
public static void PlayGunSound(this Player player, FirearmType firearmType, int clipIndex, Vector3 position, MixerChannel mixerChannel = MixerChannel.Weapons, float? range = null, float? pitch = null)
Parameters
playerPlayerTarget to play.
firearmTypeFirearmTypeWeapon's sound to play.
clipIndexintIndex of clip.
positionVector3Position to play on.
mixerChannelMixerChannelAudio's mixer channel.
rangefloat?Max range of sound.
pitchfloat?Speed of sound.
PlayGunSound(Player, Vector3, FirearmType, float, int)
Plays a gun sound that only the player can hear.
[Obsolete("This method is deprecated, use PlayGunSound(this Player, FirearmType, int, Vector3, MixerChannel, float, float) instead.")]
public static void PlayGunSound(this Player player, Vector3 position, FirearmType firearmType, float pitch = 1, int clipIndex = 0)
Parameters
playerPlayerTarget to play.
positionVector3Position to play on.
firearmTypeFirearmTypeWeapon's sound to play.
pitchfloatSpeed of sound.
clipIndexintIndex of clip.
PlayGunSound(Player, Vector3, ItemType, byte, byte)
Plays a gun sound that only the player can hear.
[Obsolete("This method is not working. Use PlayGunSound(Player, Vector3, FirearmType, float, int, bool) overload instead.")]
public static void PlayGunSound(this Player player, Vector3 position, ItemType itemType, byte volume, byte audioClipId = 0)
Parameters
playerPlayerTarget to play.
positionVector3Position to play on.
itemTypeItemTypeWeapon' sound to play.
volumebyteSound's volume to set.
audioClipIdbyteGunAudioMessage's audioClipId to set (default = 0).
PlaySound(Firearm, Player, int, MixerChannel, Vector3, bool, float?, float?)
Plays a gun sound to the specified player.
public static bool PlaySound(this Firearm firearm, Player target, int index, MixerChannel channel, Vector3 position, bool shooterVisible, float? range = null, float? pitch = null)
Parameters
firearmFirearmThe firearm whose InventorySystem.Items.Firearms.Modules.AudioModule to use.
targetPlayerThe player to send the sound to.
indexintThe index of the audio clip to play.
channelMixerChannelThe AudioPooling.MixerChannel to play the sound on.
positionVector3The world position the sound originates from.
shooterVisibleboolWhether the shooter is visible to the target. If false, the sound will be played at
positioninstead of on the firearm's transform.rangefloat?The range of the sound.
pitchfloat?The pitch of the sound.
Returns
- bool
true if the sound was played successfully; false if InventorySystem.Items.Firearms.Modules.AudioModule is null.
PlaySound(Firearm, IEnumerable<Player>, int, MixerChannel, Vector3, bool, float?, float?)
Plays a gun sound to the specified players.
public static bool PlaySound(this Firearm firearm, IEnumerable<Player> targets, int index, MixerChannel channel, Vector3 position, bool shooterVisible, float? range = null, float? pitch = null)
Parameters
firearmFirearmThe firearm whose InventorySystem.Items.Firearms.Modules.AudioModule to use.
targetsIEnumerable<Player>The players to send the sound to.
indexintThe index of the audio clip to play.
channelMixerChannelThe AudioPooling.MixerChannel to play the sound on.
positionVector3The world position the sound originates from.
shooterVisibleboolWhether the shooter is visible to the target. If false, the sound will be played at
positioninstead of on the firearm's transform.rangefloat?The range of the sound.
pitchfloat?The pitch of the sound.
Returns
- bool
true if the sound was played successfully; false if InventorySystem.Items.Firearms.Modules.AudioModule is null.
ResetIntercomDisplayText()
Resync DisplayText.
public static void ResetIntercomDisplayText()
ResyncEffectTo(Player, Player, EffectType)
Resynchronizes a specific effect from the effect owner to the target player.
public static void ResyncEffectTo(this Player effectOwner, Player target, EffectType effect)
Parameters
effectOwnerPlayerThe player who owns the effect to be resynchronized.
targetPlayerThe target player to whom the effect will be resynchronized.
effectEffectTypeThe type of effect to be resynchronized.
ResyncEffectTo(Player, IEnumerable<Player>, EffectType)
Resynchronizes a specific effect from the effect owner to the target players.
public static void ResyncEffectTo(this Player effectOwner, IEnumerable<Player> targets, EffectType effect)
Parameters
effectOwnerPlayerThe player who owns the effect to be resynchronized.
targetsIEnumerable<Player>The list of target players to whom the effect will be resynchronized.
effectEffectTypeThe type of effect to be resynchronized.
ResyncKeycardItem(CustomKeycardItem)
Makes the server resend a message to all clients updating a keycards details to current values.
public static void ResyncKeycardItem(CustomKeycardItem customKeycardItem)
Parameters
customKeycardItemCustomKeycardItemThe keycard to resync.
ResyncKeycardPickup(CustomKeycardPickup)
Makes the server resend a message to all clients updating a keycards details to current values.
public static void ResyncKeycardPickup(CustomKeycardPickup customKeycard)
Parameters
customKeycardCustomKeycardPickupThe keycard to resync.
ResyncSyncVar(NetworkIdentity, Type, string)
Force resync to client's Mirror.SyncVarAttribute.
public static void ResyncSyncVar(NetworkIdentity behaviorOwner, Type targetType, string propertyName)
Parameters
behaviorOwnerNetworkIdentityMirror.NetworkIdentity of object that owns Mirror.NetworkBehaviour.
targetTypeTypeMirror.NetworkBehaviour's type.
propertyNamestringProperty 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
playerPlayerTarget to send.
identityNetworkIdentityThe Mirror.NetworkIdentity to scale.
scaleVector3The 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
identityNetworkIdentityThe Mirror.NetworkIdentity to scale.
scaleVector3The scale the object needs to be set to.
SendFakeEffectTo(Player, Player, EffectType, byte)
Sends a fake effect to a target player, simulating the effect as if it originated from the effect owner.
public static void SendFakeEffectTo(this Player effectOwner, Player target, EffectType effect, byte intensity)
Parameters
effectOwnerPlayerThe player who owns the effect.
targetPlayerThe target player to whom the effect will be sent.
effectEffectTypeThe type of effect to be sent.
intensitybyteThe intensity of the effect.
SendFakeEffectTo(Player, IEnumerable<Player>, EffectType, byte)
Sends a fake effect to a list of target players, simulating the effect as if it originated from the effect owner.
public static void SendFakeEffectTo(this Player effectOwner, IEnumerable<Player> targets, EffectType effect, byte intensity)
Parameters
effectOwnerPlayerThe player who owns the effect.
targetsIEnumerable<Player>The list of target players to whom the effect will be sent.
effectEffectTypeThe type of effect to be sent.
intensitybyteThe intensity of the effect.
SendFakeSceneLoading(Player, ScenesType)
Sends to the player a Fake Change Scene.
public static void SendFakeSceneLoading(this Player player, ScenesType newSceneName)
Parameters
playerPlayerThe player to send the Scene.
newSceneNameScenesTypeThe 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
targetPlayerTarget to send.
behaviorOwnerNetworkIdentityMirror.NetworkIdentity of object that owns Mirror.NetworkBehaviour.
targetTypeTypeMirror.NetworkBehaviour's type.
customActionAction<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
targetPlayerTarget to send.
behaviorOwnerNetworkIdentityMirror.NetworkIdentity of object that owns Mirror.NetworkBehaviour.
targetTypeTypeMirror.NetworkBehaviour's type.
propertyNamestringProperty name starting with Network.
valueTValue of send to target.
Type Parameters
TTarget 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
targetPlayerTarget to send.
behaviorOwnerNetworkIdentityMirror.NetworkIdentity of object that owns Mirror.NetworkBehaviour.
targetTypeTypeMirror.NetworkBehaviour's type.
rpcNamestringProperty name starting with Rpc.
valuesobject[]Values of send to target.
SetFakeSpectatable(Player, Player, bool)
Makes a player not spectatable to another player.
public static void SetFakeSpectatable(Player target, Player viewer, bool isforceHidden)
Parameters
targetPlayerThe player who will become not spectatable.
viewerPlayerThe viewer who will see this change.
isforceHiddenboolDetermine if the player will be force hidden.
SetIntercomDisplayTextForTargetOnly(Player, string)
Sets DisplayText that only the target player can see.
public static void SetIntercomDisplayTextForTargetOnly(this Player target, string text)
Parameters
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
targetPlayerOnly this player can see the name changed.
playerPlayerPlayer that will desync the CustomName.
namestringNickname 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
playerPlayerOnly this player can see info.
targetPlayerTarget to set info.
infostringSetting 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
roomRoomRoom to modify.
targetPlayerOnly this player can see room color.
colorColorColor 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
roomRoomThe room to modify the lights of.
targetPlayerThe player who will see the lights state change.
valueboolThe state to set the lights to. True for on, false for off.
SpawnBlood(Player, Vector3, Vector3)
Spawns a blood decal for this player.
public static bool SpawnBlood(this Player player, Vector3 position, Vector3 sourcePosition)
Parameters
playerPlayerTarget to spawn blood decal for.
positionVector3The position of the blood decal.
sourcePositionVector3The raycast origin used to determine the decal's orientation.
Returns
SpawnBlood(IEnumerable<Player>, Vector3, Vector3)
Spawns a blood decal for the specified players.
public static bool SpawnBlood(this IEnumerable<Player> players, Vector3 position, Vector3 sourcePosition)
Parameters
playersIEnumerable<Player>The players for which to spawn the blood decal.
positionVector3The position of the blood decal.
sourcePositionVector3The raycast origin used to determine the decal's orientation.
Returns
SpawnDecal(Player, Vector3, Vector3, DecalPoolType, FirearmType)
Spawns a decal for this player.
public static bool SpawnDecal(this Player player, Vector3 position, Vector3 sourcePosition, DecalPoolType decalType, FirearmType firearmType = FirearmType.Com15)
Parameters
playerPlayerTarget to spawn decal for.
positionVector3The position of the decal.
sourcePositionVector3The raycast origin used to determine the decal's orientation.
decalTypeDecalPoolTypeThe Decals.DecalPoolType.
firearmTypeFirearmTypeThe FirearmType to use.
Returns
SpawnDecal(IEnumerable<Player>, Vector3, Vector3, DecalPoolType, FirearmType)
Spawns a decal for the specified targets.
public static bool SpawnDecal(this IEnumerable<Player> targets, Vector3 position, Vector3 sourcePosition, DecalPoolType decalType, FirearmType firearmType = FirearmType.Com15)
Parameters
targetsIEnumerable<Player>The targets for which to spawn the decal.
positionVector3The position of the decal.
sourcePositionVector3The raycast origin used to determine the decal's orientation.
decalTypeDecalPoolTypeThe Decals.DecalPoolType.
firearmTypeFirearmTypeThe FirearmType to use.