diff --git a/Robust.Shared/Player/Filter.cs b/Robust.Shared/Player/Filter.cs
index dd69d8f7e5..e9cfe8cf07 100644
--- a/Robust.Shared/Player/Filter.cs
+++ b/Robust.Shared/Player/Filter.cs
@@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using JetBrains.Annotations;
using Robust.Shared.Configuration;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Players;
-using Robust.Shared.Utility;
namespace Robust.Shared.Player
{
@@ -123,6 +121,31 @@ namespace Robust.Shared.Player
return this;
}
+ ///
+ /// Add all players whose attached entity match a predicate.
+ /// Doesn't consider players without an attached entity.
+ ///
+ public Filter AddWhereAttachedEntity(Predicate predicate)
+ {
+ return AddWhere(session => session.AttachedEntity is { } entity && predicate(entity));
+ }
+
+ ///
+ /// Add all players whose entity is on a certain grid.
+ ///
+ public Filter AddInGrid(GridId gridId)
+ {
+ return AddWhereAttachedEntity(entity => entity.Transform.GridID == gridId);
+ }
+
+ ///
+ /// Add all players whose entity is on a certain map.
+ ///
+ public Filter AddInMap(MapId mapId)
+ {
+ return AddWhereAttachedEntity(entity => entity.Transform.MapID == mapId);
+ }
+
///
/// Adds all players in range of a position.
///
@@ -162,6 +185,18 @@ namespace Robust.Shared.Player
return this;
}
+ ///
+ /// Removes all players whose attached entity match a predicate.
+ /// Doesn't consider players without an attached entity.
+ ///
+ ///
+ ///
+ public Filter RemoveWhereAttachedEntity(Predicate predicate)
+ {
+ _recipients.RemoveWhere(session => session.AttachedEntity is { } entity && predicate(entity));
+ return this;
+ }
+
///
/// Removes all players in range of a position.
///
@@ -229,6 +264,22 @@ namespace Robust.Shared.Player
return Empty().AddAllPlayers();
}
+ ///
+ /// A new filter with all players whose attached entity is on a certain grid.
+ ///
+ public static Filter BroadcastGrid(GridId grid)
+ {
+ return Empty().AddInGrid(grid);
+ }
+
+ ///
+ /// A new filter with all players whose attached entity is on a certain map.
+ ///
+ public static Filter BroadcastMap(MapId map)
+ {
+ return Empty().AddInMap(map);
+ }
+
///
/// A filter with every player who's PVS overlaps this entity.
///