mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
Merge pull request #47 from WanderingPix/Ghosts-included-in-GetClosestPlayer
Add argument for PlayerControl.GetClosestPlayer() to include ghosts
This commit is contained in:
1 file changed
+3
-2
@@ -513,6 +513,7 @@ public static class Extensions
|
|||||||
/// <param name="includeImpostors">Whether impostors should be included in the search.</param>
|
/// <param name="includeImpostors">Whether impostors should be included in the search.</param>
|
||||||
/// <param name="distance">The radius to search within.</param>
|
/// <param name="distance">The radius to search within.</param>
|
||||||
/// <param name="ignoreColliders">Whether colliders should be ignored when searching.</param>
|
/// <param name="ignoreColliders">Whether colliders should be ignored when searching.</param>
|
||||||
|
/// <param name="includeGhosts">Determines if Ghosts are included</param>
|
||||||
/// <param name="predicate">Optional predicate to test if the object is valid.</param>
|
/// <param name="predicate">Optional predicate to test if the object is valid.</param>
|
||||||
/// <returns>The closest player if there is one, false otherwise.</returns>
|
/// <returns>The closest player if there is one, false otherwise.</returns>
|
||||||
public static PlayerControl? GetClosestPlayer(
|
public static PlayerControl? GetClosestPlayer(
|
||||||
@@ -520,16 +521,16 @@ public static class Extensions
|
|||||||
bool includeImpostors,
|
bool includeImpostors,
|
||||||
float distance,
|
float distance,
|
||||||
bool ignoreColliders = false,
|
bool ignoreColliders = false,
|
||||||
|
bool includeGhosts = false,
|
||||||
Predicate<PlayerControl>? predicate = null)
|
Predicate<PlayerControl>? predicate = null)
|
||||||
{
|
{
|
||||||
var filteredPlayers = Helpers.GetClosestPlayers(playerControl, distance, ignoreColliders)
|
var filteredPlayers = Helpers.GetClosestPlayers(playerControl, distance, ignoreColliders)
|
||||||
.Where(
|
.Where(
|
||||||
playerInfo => !playerInfo.Data.Disconnected &&
|
playerInfo => !playerInfo.Data.Disconnected &&
|
||||||
playerInfo.PlayerId != playerControl.PlayerId &&
|
playerInfo.PlayerId != playerControl.PlayerId &&
|
||||||
!playerInfo.Data.IsDead &&
|
(includeGhosts || !playerInfo.Data.IsDead) &&
|
||||||
(includeImpostors || !playerInfo.Data.Role.IsImpostor))
|
(includeImpostors || !playerInfo.Data.Role.IsImpostor))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
return predicate != null ? filteredPlayers.Find(predicate) : filteredPlayers.FirstOrDefault();
|
return predicate != null ? filteredPlayers.Find(predicate) : filteredPlayers.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user