fix getclosestplayer errors

This commit is contained in:
XtraCube committed 2024-08-31 00:10:04 -04:00
1 parent 409113e37a
commit aba4b30027
1 file changed
+1 -6
+1 -6
View File
@@ -331,15 +331,10 @@ public static class Extensions
/// <returns>The closest player if there is one, false otherwise.</returns>
public static PlayerControl? GetClosestPlayer(this PlayerControl playerControl, bool includeImpostors, float distance, bool ignoreColliders = false)
{
if (!ShipStatus.Instance)
{
return null;
}
var filteredPlayers = Helpers.GetClosestPlayers(playerControl, distance, ignoreColliders)
.Where(playerInfo => !playerInfo.Data.Disconnected && playerInfo.PlayerId != playerControl.PlayerId && !playerInfo.Data.IsDead &&
(includeImpostors || !playerInfo.Data.Role.IsImpostor));
return filteredPlayers.First();
return filteredPlayers.FirstOrDefault();
}
}