From 4cb22439275e2f692fe9875c51d0e9dd9d6e79d6 Mon Sep 17 00:00:00 2001 From: Yamato Date: Tue, 21 Jan 2025 20:01:48 +0100 Subject: [PATCH] ChangeOnAppearance --- .../Exiled.API/Extensions/MirrorExtensions.cs | 31 +++++++++++++++++-- EXILED/Exiled.API/Features/Roles/Role.cs | 8 +++-- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/EXILED/Exiled.API/Extensions/MirrorExtensions.cs b/EXILED/Exiled.API/Extensions/MirrorExtensions.cs index 09969e637..8bebe38cb 100644 --- a/EXILED/Exiled.API/Extensions/MirrorExtensions.cs +++ b/EXILED/Exiled.API/Extensions/MirrorExtensions.cs @@ -231,7 +231,10 @@ public static void SetName(this Player target, Player player, string name) /// /// Player to change. /// Model type. - public static void ChangeAppearance(this Player player, RoleTypeId type) => ChangeAppearance(player, type, Player.List.Where(x => x != player)); + /// Whether to skip the little jump that works around an invisibility issue. + /// The UnitNameId to use for the player's new role, if the player's new role uses unit names. (is NTF). + [Obsolete("Use this Method instead ChangeAppearance(this Player, RoleTypeId)")] + public static void ChangeAppearance(this Player player, RoleTypeId type, bool skipJump, byte unitId) => ChangeAppearance(player, type, Player.List.Where(x => x != player)); /// /// Change character model for appearance. @@ -240,7 +243,29 @@ public static void SetName(this Player target, Player player, string name) /// Player to change. /// Model type. /// The players who should see the changed appearance. - public static void ChangeAppearance(this Player player, RoleTypeId type, IEnumerable playersToAffect) + /// Whether to skip the little jump that works around an invisibility issue. + /// The UnitNameId to use for the player's new role, if the player's new role uses unit names. (is NTF). + [Obsolete("Use this Method instead ChangeAppearance(this Player, RoleTypeId, IEnumerable)")] + public static void ChangeAppearance(this Player player, RoleTypeId type, IEnumerable playersToAffect, bool skipJump, byte unitId) => ChangeAppearance(player, type, playersToAffect); + + /// + /// Change character model for appearance. + /// It will continue until 's changes. + /// + /// Player to change. + /// Model type. + /// Custom value that will be used to modify slightly the Appearance depending of Role selected. + public static void ChangeAppearance(this Player player, RoleTypeId type, object[] objects = null) => ChangeAppearance(player, type, Player.List.Where(x => x != player), objects); + + /// + /// Change character model for appearance. + /// It will continue until 's changes. + /// + /// Player to change. + /// Model type. + /// The players who should see the changed appearance. + /// Custom value that will be used to modify slightly the Appearance depending of Role selected. + public static void ChangeAppearance(this Player player, RoleTypeId type, IEnumerable playersToAffect, object[] objects = null) { if (!player.IsConnected) return; @@ -253,7 +278,7 @@ public static void ChangeAppearance(this Player player, RoleTypeId type, IEnumer foreach (Player target in playersToAffect) { - player.Role.TrySetIndividualAppearance(target, type, false); + player.Role.TrySetIndividualAppearance(target, type, objects, false); } player.Role.UpdateAppearance(); diff --git a/EXILED/Exiled.API/Features/Roles/Role.cs b/EXILED/Exiled.API/Features/Roles/Role.cs index b1c7f34ef..0e60e9223 100644 --- a/EXILED/Exiled.API/Features/Roles/Role.cs +++ b/EXILED/Exiled.API/Features/Roles/Role.cs @@ -303,9 +303,10 @@ public bool TrySetTeamAppearance(Team team, RoleTypeId newAppearance, bool updat /// /// Target . /// New individual appearance. + /// Custom value that will be used to modify slightly the Appearance depending of Role selected. /// Whether or not the change-role requect should sent imidiately. /// A boolean indicating whether or not a target will be used as new appearance. - public bool TrySetIndividualAppearance(Player player, RoleTypeId newAppearance, bool update = true) + public bool TrySetIndividualAppearance(Player player, RoleTypeId newAppearance, object[] objects = null, bool update = true) { if (!CheckAppearanceCompatibility(newAppearance)) { @@ -317,7 +318,7 @@ public bool TrySetIndividualAppearance(Player player, RoleTypeId newAppearance, if (update) { - UpdateAppearanceFor(player); + UpdateAppearanceFor(player, objects); } return true; @@ -395,7 +396,8 @@ public void UpdateAppearance() /// Updates current player visibility, for target . /// /// Target . - public void UpdateAppearanceFor(Player player) + /// Custom value that will be used to modify slightly the Appearance depending of Role selected. + public void UpdateAppearanceFor(Player player, object[] objects = null) { RoleTypeId roleTypeId = Type; if (Base is IObfuscatedRole obfuscatedRole)