From f98429b5f9d23d114402dd1d1ad9b31874296bef Mon Sep 17 00:00:00 2001 From: WanderingPixel <126269533+WanderingPix@users.noreply.github.com> Date: Thu, 31 Jul 2025 12:18:02 +0100 Subject: [PATCH] Update GetClosestPlayer method --- MiraAPI/Utilities/Extensions.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MiraAPI/Utilities/Extensions.cs b/MiraAPI/Utilities/Extensions.cs index 57887d8..5fbc671 100644 --- a/MiraAPI/Utilities/Extensions.cs +++ b/MiraAPI/Utilities/Extensions.cs @@ -513,6 +513,7 @@ public static class Extensions /// Whether impostors should be included in the search. /// The radius to search within. /// Whether colliders should be ignored when searching. + /// Determines if Ghosts are included /// Optional predicate to test if the object is valid. /// The closest player if there is one, false otherwise. public static PlayerControl? GetClosestPlayer( @@ -520,16 +521,16 @@ public static class Extensions bool includeImpostors, float distance, bool ignoreColliders = false, + bool includeGhosts = false, Predicate? predicate = null) { var filteredPlayers = Helpers.GetClosestPlayers(playerControl, distance, ignoreColliders) .Where( playerInfo => !playerInfo.Data.Disconnected && playerInfo.PlayerId != playerControl.PlayerId && - !playerInfo.Data.IsDead && + (includeGhosts || !playerInfo.Data.IsDead) && (includeImpostors || !playerInfo.Data.Role.IsImpostor)) .ToList(); - return predicate != null ? filteredPlayers.Find(predicate) : filteredPlayers.FirstOrDefault(); }