public static IEnumerable <TorPlayer> PartyPlayers(this TorPlayer torPlayer, TorPlayerPredicateDelegate playerQualifier = null) { playerQualifier = playerQualifier ?? (ctx => true); // resolve playerQualifier to something sane var playerGroupId = torPlayer.GroupId; // If we're solo, only have the torPlayer on the list... // We can't build this list using the 'normal' query, as all solo players have the common GroupId of zero. // We don't want a list of 'solo' players (what the normal query would do), we want a list with only the solo torPlayer on it. if (playerGroupId == 0) { return(ObjectManager.GetObjects <TorPlayer>().Where(p => (p == BuddyTor.Me) && playerQualifier(p))); } // NB: IsInParty() is implemented in terms of PartyPlayers(). Be careful not to implement this method in terms of // IsInParty(); otherwise, infinite recursive descent will occur. return (ObjectManager.GetObjects <TorPlayer>().Where(p => !p.IsDeleted && playerQualifier(p) && (p.GroupId == playerGroupId))); }
public static IEnumerable<TorPlayer> PartyPlayers(this TorPlayer torPlayer, TorPlayerPredicateDelegate playerQualifier = null) { playerQualifier = playerQualifier ?? (ctx => true); // resolve playerQualifier to something sane var playerGroupId = torPlayer.GroupId; // If we're solo, only have the torPlayer on the list... // We can't build this list using the 'normal' query, as all solo players have the common GroupId of zero. // We don't want a list of 'solo' players (what the normal query would do), we want a list with only the solo torPlayer on it. if (playerGroupId == 0) { return ObjectManager.GetObjects<TorPlayer>().Where(p => (p == BuddyTor.Me) && playerQualifier(p)); } // NB: IsInParty() is implemented in terms of PartyPlayers(). Be careful not to implement this method in terms of // IsInParty(); otherwise, infinite recursive descent will occur. return ObjectManager.GetObjects<TorPlayer>().Where(p => !p.IsDeleted && playerQualifier(p) && (p.GroupId == playerGroupId)); }