Skip to content

Commit

Permalink
ChangeOnAppearance
Browse files Browse the repository at this point in the history
  • Loading branch information
louis1706 committed Jan 21, 2025
1 parent cd1074e commit 4cb2243
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
31 changes: 28 additions & 3 deletions EXILED/Exiled.API/Extensions/MirrorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ public static void SetName(this Player target, Player player, string name)
/// </summary>
/// <param name="player">Player to change.</param>
/// <param name="type">Model type.</param>
public static void ChangeAppearance(this Player player, RoleTypeId type) => ChangeAppearance(player, type, Player.List.Where(x => x != player));
/// <param name="skipJump">Whether to skip the little jump that works around an invisibility issue.</param>
/// <param name="unitId">The UnitNameId to use for the player's new role, if the player's new role uses unit names. (is NTF).</param>
[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));

/// <summary>
/// Change <see cref="Player"/> character model for appearance.
Expand All @@ -240,7 +243,29 @@ public static void SetName(this Player target, Player player, string name)
/// <param name="player">Player to change.</param>
/// <param name="type">Model type.</param>
/// <param name="playersToAffect">The players who should see the changed appearance.</param>
public static void ChangeAppearance(this Player player, RoleTypeId type, IEnumerable<Player> playersToAffect)
/// <param name="skipJump">Whether to skip the little jump that works around an invisibility issue.</param>
/// <param name="unitId">The UnitNameId to use for the player's new role, if the player's new role uses unit names. (is NTF).</param>
[Obsolete("Use this Method instead ChangeAppearance(this Player, RoleTypeId, IEnumerable<Player>)")]
public static void ChangeAppearance(this Player player, RoleTypeId type, IEnumerable<Player> playersToAffect, bool skipJump, byte unitId) => ChangeAppearance(player, type, playersToAffect);

/// <summary>
/// Change <see cref="Player"/> character model for appearance.
/// It will continue until <see cref="Player"/>'s <see cref="RoleTypeId"/> changes.
/// </summary>
/// <param name="player">Player to change.</param>
/// <param name="type">Model type.</param>
/// <param name="objects">Custom value that will be used to modify slightly the Appearance depending of Role selected.</param>
public static void ChangeAppearance(this Player player, RoleTypeId type, object[] objects = null) => ChangeAppearance(player, type, Player.List.Where(x => x != player), objects);

/// <summary>
/// Change <see cref="Player"/> character model for appearance.
/// It will continue until <see cref="Player"/>'s <see cref="RoleTypeId"/> changes.
/// </summary>
/// <param name="player">Player to change.</param>
/// <param name="type">Model type.</param>
/// <param name="playersToAffect">The players who should see the changed appearance.</param>
/// <param name="objects">Custom value that will be used to modify slightly the Appearance depending of Role selected.</param>
public static void ChangeAppearance(this Player player, RoleTypeId type, IEnumerable<Player> playersToAffect, object[] objects = null)
{
if (!player.IsConnected)
return;
Expand All @@ -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();
Expand Down
8 changes: 5 additions & 3 deletions EXILED/Exiled.API/Features/Roles/Role.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,10 @@ public bool TrySetTeamAppearance(Team team, RoleTypeId newAppearance, bool updat
/// </summary>
/// <param name="player">Target <see cref="Player"/>.</param>
/// <param name="newAppearance">New individual <see cref="RoleTypeId"/> appearance.</param>
/// <param name="objects">Custom value that will be used to modify slightly the Appearance depending of Role selected.</param>
/// <param name="update">Whether or not the change-role requect should sent imidiately.</param>
/// <returns>A boolean indicating whether or not a target <see cref="RoleTypeId"/> will be used as new appearance.</returns>
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))
{
Expand All @@ -317,7 +318,7 @@ public bool TrySetIndividualAppearance(Player player, RoleTypeId newAppearance,

if (update)
{
UpdateAppearanceFor(player);
UpdateAppearanceFor(player, objects);
}

return true;
Expand Down Expand Up @@ -395,7 +396,8 @@ public void UpdateAppearance()
/// Updates current player visibility, for target <see cref="Player"/>.
/// </summary>
/// <param name="player">Target <see cref="Player"/>.</param>
public void UpdateAppearanceFor(Player player)
/// <param name="objects">Custom value that will be used to modify slightly the Appearance depending of Role selected.</param>
public void UpdateAppearanceFor(Player player, object[] objects = null)
{
RoleTypeId roleTypeId = Type;
if (Base is IObfuscatedRole obfuscatedRole)
Expand Down

0 comments on commit 4cb2243

Please sign in to comment.