-using System.Numerics;
+using System.Numerics;
using Content.Client.UserInterface.Controls;
using Content.Shared.Chat.Prototypes;
using Content.Shared.Speech;
+using Content.Shared.Whitelist;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls;
[Dependency] private readonly ISharedPlayerManager _playerManager = default!;
private readonly SpriteSystem _spriteSystem;
+ private readonly EntityWhitelistSystem _whitelistSystem;
public event Action<ProtoId<EmotePrototype>>? OnPlayEmote;
RobustXamlLoader.Load(this);
_spriteSystem = _entManager.System<SpriteSystem>();
+ _whitelistSystem = _entManager.System<EntityWhitelistSystem>();
var main = FindControl<RadialContainer>("Main");
var player = _playerManager.LocalSession?.AttachedEntity;
if (emote.Category == EmoteCategory.Invalid ||
emote.ChatTriggers.Count == 0 ||
- !(player.HasValue && (emote.Whitelist?.IsValid(player.Value, _entManager) ?? true)) ||
- (emote.Blacklist?.IsValid(player.Value, _entManager) ?? false))
+ !(player.HasValue && _whitelistSystem.IsWhitelistPassOrNull(emote.Whitelist, player.Value)) ||
+ _whitelistSystem.IsBlacklistPass(emote.Blacklist, player.Value))
continue;
if (!emote.Available &&
using Content.Client.UserInterface.Systems.MenuBar.Widgets;
using Content.Shared.Construction.Prototypes;
using Content.Shared.Tag;
+using Content.Shared.Whitelist;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Placement;
/// </summary>
internal sealed class ConstructionMenuPresenter : IDisposable
{
+ [Dependency] private readonly EntityManager _entManager = default!;
[Dependency] private readonly IEntitySystemManager _systemManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IPlacementManager _placementManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
private readonly IConstructionMenuView _constructionView;
+ private readonly EntityWhitelistSystem _whitelistSystem;
private ConstructionSystem? _constructionSystem;
private ConstructionPrototype? _selected;
// This is a lot easier than a factory
IoCManager.InjectDependencies(this);
_constructionView = new ConstructionMenu();
+ _whitelistSystem = _entManager.System<EntityWhitelistSystem>();
// This is required so that if we load after the system is initialized, we can bind to it immediately
if (_systemManager.TryGetEntitySystem<ConstructionSystem>(out var constructionSystem))
if (_playerManager.LocalSession == null
|| _playerManager.LocalEntity == null
- || (recipe.EntityWhitelist != null && !recipe.EntityWhitelist.IsValid(_playerManager.LocalEntity.Value)))
+ || _whitelistSystem.IsWhitelistFail(recipe.EntityWhitelist, _playerManager.LocalEntity.Value))
continue;
if (!string.IsNullOrEmpty(search))
bool ignoreActionBlocker = false
)
{
- if (!(emote.Whitelist?.IsValid(source, EntityManager) ?? true))
- return;
- if (emote.Blacklist?.IsValid(source, EntityManager) ?? false)
+ if (_whitelistSystem.IsWhitelistFailOrNull(emote.Whitelist, source) || _whitelistSystem.IsBlacklistPass(emote.Blacklist, source))
return;
if (!emote.Available &&
using Content.Shared.Players;
using Content.Shared.Radio;
using Content.Shared.Speech;
+using Content.Shared.Whitelist;
using Robust.Server.Player;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly ReplacementAccentSystem _wordreplacement = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
public const int VoiceRange = 10; // how far voice goes in world units
public const int WhisperClearRange = 2; // how far whisper goes while still being understandable, in world units
using Content.Shared.Interaction;
using Content.Shared.Tag;
using Content.Shared.Weapons.Melee.Events;
+using Content.Shared.Whitelist;
using Robust.Server.GameObjects;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Prototypes;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly TransformSystem _transform = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
public override void Initialize()
{
private void OnAttacked(Entity<GatherableComponent> gatherable, ref AttackedEvent args)
{
- if (gatherable.Comp.ToolWhitelist?.IsValid(args.Used, EntityManager) != true)
+ if (_whitelistSystem.IsWhitelistFailOrNull(gatherable.Comp.ToolWhitelist, args.Used))
return;
Gather(gatherable, args.User);
if (args.Handled || !args.Complex)
return;
- if (gatherable.Comp.ToolWhitelist?.IsValid(args.User, EntityManager) != true)
+ if (_whitelistSystem.IsWhitelistFailOrNull(gatherable.Comp.ToolWhitelist, args.User))
return;
Gather(gatherable, args.User);
using System.Numerics;
using Content.Shared.NPC.Components;
using Content.Shared.NPC.Systems;
+using Content.Shared.Whitelist;
using Robust.Shared.Collections;
using Robust.Shared.Map;
using Robust.Shared.Random;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly NPCSystem _npc = default!;
[Dependency] private readonly IRobustRandom _random = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
public override void Initialize()
{
foreach (var friend in friends)
{
- if (imprinting.Comp.Whitelist?.IsValid(friend) != false)
+ if (_whitelistSystem.IsWhitelistPassOrNull(imprinting.Comp.Whitelist, friend))
{
AddImprintingTarget(imprinting, friend, imprinting.Comp);
}
using Content.Shared.Weapons.Melee;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Events;
+using Content.Shared.Whitelist;
using Microsoft.Extensions.ObjectPool;
using Robust.Server.Containers;
using Robust.Shared.Prototypes;
[Dependency] private readonly SolutionContainerSystem _solutions = default!;
[Dependency] private readonly WeldableSystem _weldable = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
private EntityQuery<PuddleComponent> _puddleQuery;
private EntityQuery<TransformComponent> _xformQuery;
return 0f;
}
- if (heldGun.Whitelist?.IsValid(targetUid, EntityManager) != true)
+ if (_whitelistSystem.IsWhitelistFailOrNull(heldGun.Whitelist, targetUid))
{
return 0f;
}
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Storage.Components;
using Robust.Server.Containers;
+using Content.Shared.Whitelist;
namespace Content.Server.Power.EntitySystems;
[Dependency] private readonly PowerCellSystem _powerCell = default!;
[Dependency] private readonly BatterySystem _battery = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
public override void Initialize()
{
if (!receiverComponent.Powered)
return;
- if (component.Whitelist?.IsValid(targetEntity, EntityManager) == false)
+ if (_whitelistSystem.IsWhitelistFail(component.Whitelist, targetEntity))
return;
if (!SearchForBattery(targetEntity, out var batteryUid, out var heldBattery))
using Robust.Shared.Physics.Components;
using Robust.Shared.Utility;
using Robust.Shared.Map.Components;
+using Content.Shared.Whitelist;
namespace Content.Server.Revenant.EntitySystems;
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
[Dependency] private readonly GhostSystem _ghost = default!;
[Dependency] private readonly TileSystem _tile = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
private void InitializeAbilities()
{
foreach (var ent in _lookup.GetEntitiesInRange(uid, component.MalfunctionRadius))
{
- if (component.MalfunctionWhitelist?.IsValid(ent, EntityManager) == false)
- continue;
-
- if (component.MalfunctionBlacklist?.IsValid(ent, EntityManager) == true)
+ if (_whitelistSystem.IsWhitelistFail(component.MalfunctionWhitelist, ent) ||
+ _whitelistSystem.IsBlacklistPass(component.MalfunctionBlacklist, ent))
continue;
_emag.DoEmagEffect(uid, ent); //it does not emag itself. adorable.
return false;
}
- if (component.ModuleWhitelist?.IsValid(module, EntityManager) == false)
+ if (_whitelistSystem.IsWhitelistFail(component.ModuleWhitelist, module))
{
if (user != null)
Popup.PopupEntity(Loc.GetString("borg-module-whitelist-deny"), uid, user.Value);
using Content.Shared.Silicons.Borgs;
using Content.Shared.Silicons.Borgs.Components;
using Content.Shared.Throwing;
+using Content.Shared.Whitelist;
using Content.Shared.Wires;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
[Dependency] private readonly ThrowingSystem _throwing = default!;
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
+
[ValidatePrototypeId<JobPrototype>]
public const string BorgJobId = "Borg";
return;
}
- if (component.BrainEntity == null &&
- brain != null &&
- component.BrainWhitelist?.IsValid(used) != false)
+ if (component.BrainEntity == null && brain != null &&
+ _whitelistSystem.IsWhitelistPassOrNull(component.BrainWhitelist, used))
{
if (_mind.TryGetMind(used, out _, out var mind) && mind.Session != null)
{
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Storage;
using Content.Shared.Verbs;
+using Content.Shared.Whitelist;
using Robust.Shared.Containers;
using Robust.Shared.Random;
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly IRobustRandom _random = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
public override void Initialize()
{
var user = args.User;
- var enabled = storage.Container.ContainedEntities.Any(item => comp.Whitelist?.IsValid(item, EntityManager) ?? true);
+ var enabled = storage.Container.ContainedEntities.Any(item => _whitelistSystem.IsWhitelistPassOrNull(comp.Whitelist, item));
// alt-click / alt-z to pick an item
args.Verbs.Add(new AlternativeVerb
private void TryPick(EntityUid uid, PickRandomComponent comp, StorageComponent storage, EntityUid user)
{
- var entities = storage.Container.ContainedEntities.Where(item => comp.Whitelist?.IsValid(item, EntityManager) ?? true).ToArray();
+ var entities = storage.Container.ContainedEntities.Where(item => _whitelistSystem.IsWhitelistPassOrNull(comp.Whitelist, item)).ToArray();
if (!entities.Any())
return;
using System.Linq;
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
+using Content.Shared.Whitelist;
using Content.Shared.Xenoarchaeology.XenoArtifacts;
using JetBrains.Annotations;
-using Robust.Shared.Prototypes;
using Robust.Shared.Random;
-using Robust.Shared.Serialization.Manager;
namespace Content.Server.Xenoarchaeology.XenoArtifacts;
public sealed partial class ArtifactSystem
{
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
+
private const int MaxEdgesPerNode = 4;
private readonly HashSet<int> _usedNodeIds = new();
private string GetRandomTrigger(EntityUid artifact, ref ArtifactNode node)
{
var allTriggers = _prototype.EnumeratePrototypes<ArtifactTriggerPrototype>()
- .Where(x => (x.Whitelist?.IsValid(artifact, EntityManager) ?? true) && (!x.Blacklist?.IsValid(artifact, EntityManager) ?? true)).ToList();
+ .Where(x => _whitelistSystem.IsWhitelistPassOrNull(x.Whitelist, artifact) &&
+ _whitelistSystem.IsBlacklistFailOrNull(x.Blacklist, artifact)).ToList();
var validDepth = allTriggers.Select(x => x.TargetDepth).Distinct().ToList();
var weights = GetDepthWeights(validDepth, node.Depth);
private string GetRandomEffect(EntityUid artifact, ref ArtifactNode node)
{
var allEffects = _prototype.EnumeratePrototypes<ArtifactEffectPrototype>()
- .Where(x => (x.Whitelist?.IsValid(artifact, EntityManager) ?? true) && (!x.Blacklist?.IsValid(artifact, EntityManager) ?? true)).ToList();
+ .Where(x => _whitelistSystem.IsWhitelistPassOrNull(x.Whitelist, artifact) &&
+ _whitelistSystem.IsBlacklistFailOrNull(x.Blacklist, artifact)).ToList();
var validDepth = allEffects.Select(x => x.TargetDepth).Distinct().ToList();
var weights = GetDepthWeights(validDepth, node.Depth);
using Content.Shared.Interaction.Events;
using Content.Shared.Popups;
using Content.Shared.Verbs;
+using Content.Shared.Whitelist;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
public override void Initialize()
{
if (slot.ContainerSlot == null)
return false;
- if ((!slot.Whitelist?.IsValid(usedUid) ?? false) ||
- (slot.Blacklist?.IsValid(usedUid) ?? false))
+ if (_whitelistSystem.IsWhitelistFail(slot.Whitelist, usedUid) || _whitelistSystem.IsBlacklistPass(slot.Blacklist, usedUid))
{
if (popup.HasValue && slot.WhitelistFailPopup.HasValue)
_popupSystem.PopupClient(Loc.GetString(slot.WhitelistFailPopup), uid, popup.Value);
using Content.Shared.Damage.Components;
+using Content.Shared.Whitelist;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Events;
using Robust.Shared.Physics.Systems;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
public override void Initialize()
{
if (HasComp<DamagedByContactComponent>(otherUid))
return;
- if (component.IgnoreWhitelist?.IsValid(otherUid) ?? false)
+ if (_whitelistSystem.IsWhitelistFail(component.IgnoreWhitelist, otherUid))
return;
var damagedByContact = EnsureComp<DamagedByContactComponent>(otherUid);
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Popups;
+using Content.Shared.Whitelist;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] protected readonly SharedContainerSystem ContainerSystem = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
public override void Initialize()
{
/// </summary>
protected void OnDevourAction(EntityUid uid, DevourerComponent component, DevourActionEvent args)
{
- if (args.Handled || component.Whitelist?.IsValid(args.Target, EntityManager) != true)
+ if (args.Handled || _whitelistSystem.IsWhitelistFailOrNull(component.Whitelist, args.Target))
return;
args.Handled = true;
using Content.Shared.Emag.Systems;
using Content.Shared.Item;
using Content.Shared.Throwing;
+using Content.Shared.Whitelist;
using Robust.Shared.Audio;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Events;
[Dependency] protected readonly IGameTiming GameTiming = default!;
[Dependency] protected readonly MetaDataSystem Metadata = default!;
[Dependency] protected readonly SharedJointSystem Joints = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
protected static TimeSpan ExitAttemptDelay = TimeSpan.FromSeconds(0.5);
if (!storable && !HasComp<BodyComponent>(entity))
return false;
- if (component.Blacklist?.IsValid(entity, EntityManager) == true)
- return false;
-
- if (component.Whitelist != null && component.Whitelist?.IsValid(entity, EntityManager) != true)
+ if (_whitelistSystem.IsBlacklistPass(component.Blacklist, entity) ||
+ _whitelistSystem.IsWhitelistFail(component.Whitelist, entity))
return false;
if (TryComp<PhysicsComponent>(entity, out var physics) && (physics.CanCollide) || storable)
[Dependency] private readonly ItemSlotsSystem _itemSlots = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
public override void Initialize()
{
protected bool CheckTarget(EntityUid target, EntityWhitelist? whitelist, EntityWhitelist? blacklist)
{
- return whitelist?.IsValid(target, EntityManager) != false &&
- blacklist?.IsValid(target, EntityManager) != true;
+ return _whitelistSystem.IsWhitelistPassOrNull(whitelist, target) &&
+ _whitelistSystem.IsBlacklistFailOrNull(blacklist, target);
}
//Draw the implant out of the target
-using Content.Shared.ActionBlocker;
+using Content.Shared.ActionBlocker;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Popups;
using Content.Shared.Storage;
using Content.Shared.Storage.EntitySystems;
+using Content.Shared.Whitelist;
using Robust.Shared.Containers;
using Robust.Shared.Input.Binding;
using Robust.Shared.Player;
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
/// <inheritdoc/>
public override void Initialize()
foreach (var slot in slots.Slots.Values)
{
if (!slot.HasItem
- && (slot.Whitelist?.IsValid(handItem.Value, EntityManager) ?? true)
+ && _whitelistSystem.IsWhitelistPassOrNull(slot.Whitelist, handItem.Value)
&& slot.Priority > (toInsertTo?.Priority ?? int.MinValue))
{
toInsertTo = slot;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Components;
using Content.Shared.Stacks;
+using Content.Shared.Whitelist;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
/// <summary>
/// Default volume for a sheet if the material's entity prototype has no material composition.
if (!CanTakeVolume(uid, volume, component))
return false;
- if (component.MaterialWhiteList != null && !component.MaterialWhiteList.Contains(materialId))
+ if (component.MaterialWhiteList == null ? false : component.MaterialWhiteList.Contains(materialId))
return false;
var amount = component.Storage.GetValueOrDefault(materialId);
if (!Resolve(toInsert, ref material, ref composition, false))
return false;
- if (storage.Whitelist?.IsValid(toInsert) == false)
+ if (_whitelistSystem.IsWhitelistFail(storage.Whitelist, toInsert))
return false;
if (HasComp<UnremoveableComponent>(toInsert))
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Prototypes;
using System.Diagnostics.CodeAnalysis;
+using Content.Shared.Whitelist;
namespace Content.Shared.Polymorph.Systems;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly ISerializationManager _serMan = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
public override void Initialize()
{
/// </summary>
public bool IsInvalid(ChameleonProjectorComponent comp, EntityUid target)
{
- return (comp.Whitelist?.IsValid(target, EntityManager) == false)
- || (comp.Blacklist?.IsValid(target, EntityManager) == true);
+ return _whitelistSystem.IsWhitelistFail(comp.Whitelist, target)
+ || _whitelistSystem.IsBlacklistPass(comp.Blacklist, target);
}
/// <summary>
using Content.Shared.Popups;
using Content.Shared.Stacks;
using Content.Shared.Verbs;
+using Content.Shared.Whitelist;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedStackSystem _stack = default!;
[Dependency] protected readonly SharedTransformSystem TransformSystem = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
[ValidatePrototypeId<EntityPrototype>] public const string EffectProto = "FultonEffect";
protected static readonly Vector2 EffectOffset = Vector2.Zero;
if (!CanFulton(targetUid))
return false;
- if (component.Whitelist?.IsValid(targetUid, EntityManager) != true)
+ if (_whitelistSystem.IsWhitelistFailOrNull(component.Whitelist, targetUid))
return false;
return true;
using Content.Shared.Shuttles.BUIStates;
using Content.Shared.Shuttles.Components;
using Content.Shared.Shuttles.UI.MapObjects;
+using Content.Shared.Whitelist;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Collision.Shapes;
[Dependency] private readonly ItemSlotsSystem _itemSlots = default!;
[Dependency] protected readonly SharedMapSystem Maps = default!;
[Dependency] protected readonly SharedTransformSystem XformSystem = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
public const float FTLRange = 512f;
public const float FTLBufferRange = 8f;
if (HasComp<FTLMapComponent>(mapUid))
return false;
- return destination.Whitelist?.IsValid(shuttleUid, EntityManager) != false;
+ return _whitelistSystem.IsWhitelistPassOrNull(destination.Whitelist, shuttleUid);
}
/// <summary>
using Content.Server.Storage.Components;
using Content.Shared.Inventory;
+using Content.Shared.Whitelist;
using Robust.Shared.Map;
using Robust.Shared.Physics.Components;
using Robust.Shared.Timing;
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedStorageSystem _storage = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
+
private static readonly TimeSpan ScanDelay = TimeSpan.FromSeconds(1);
foreach (var near in _lookup.GetEntitiesInRange(uid, comp.Range, LookupFlags.Dynamic | LookupFlags.Sundries))
{
- if (storage.Whitelist?.IsValid(near, EntityManager) == false)
+ if (_whitelistSystem.IsWhitelistFail(storage.Whitelist, near))
continue;
if (!_physicsQuery.TryGetComponent(near, out var physics) || physics.BodyStatus != BodyStatus.OnGround)
using Content.Shared.Tools.Systems;
using Content.Shared.Verbs;
using Content.Shared.Wall;
+using Content.Shared.Whitelist;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
[Dependency] protected readonly SharedPopupSystem Popup = default!;
[Dependency] protected readonly SharedTransformSystem TransformSystem = default!;
[Dependency] private readonly WeldableSystem _weldable = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
public const string ContainerName = "entity_storage";
var targetIsMob = HasComp<BodyComponent>(toInsert);
var storageIsItem = HasComp<ItemComponent>(container);
- var allowedToEat = component.Whitelist?.IsValid(toInsert) ?? HasComp<ItemComponent>(toInsert);
+ var allowedToEat = component.Whitelist == null ? HasComp<ItemComponent>(toInsert) : _whitelistSystem.IsValid(component.Whitelist, toInsert);
// BEFORE REPLACING THIS WITH, I.E. A PROPERTY:
// Make absolutely 100% sure you have worked out how to stop people ending up in backpacks.
[Dependency] protected readonly SharedTransformSystem TransformSystem = default!;
[Dependency] private readonly SharedUserInterfaceSystem _ui = default!;
[Dependency] protected readonly UseDelaySystem UseDelay = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
private EntityQuery<ItemComponent> _itemQuery;
private EntityQuery<StackComponent> _stackQuery;
return false;
}
- if (storageComp.Whitelist?.IsValid(insertEnt, EntityManager) == false)
- {
- reason = "comp-storage-invalid-container";
- return false;
- }
-
- if (storageComp.Blacklist?.IsValid(insertEnt, EntityManager) == true)
+ if (_whitelistSystem.IsWhitelistFail(storageComp.Whitelist, insertEnt) ||
+ _whitelistSystem.IsBlacklistPass(storageComp.Blacklist, insertEnt))
{
reason = "comp-storage-invalid-container";
return false;
using Content.Shared.Damage;
using Content.Shared.Projectiles;
using Content.Shared.Weapons.Melee.Events;
+using Content.Shared.Whitelist;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Network;
[Dependency] private readonly INetManager _netManager = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
public override void Initialize()
{
if (!args.OtherFixture.Hard ||
args.OurFixtureId != SharedProjectileSystem.ProjectileFixture ||
component.Amount <= 0 ||
- component.Whitelist?.IsValid(args.OtherEntity, EntityManager) == false ||
+ _whitelistSystem.IsWhitelistFail(component.Whitelist, args.OtherEntity) ||
!TryComp<ProjectileComponent>(uid, out var projectile) ||
projectile.Weapon == null)
{
private void OnBallisticInteractUsing(EntityUid uid, BallisticAmmoProviderComponent component, InteractUsingEvent args)
{
- if (args.Handled || component.Whitelist?.IsValid(args.Used, EntityManager) != true)
+ if (args.Handled)
+ return;
+
+ if (_whitelistSystem.IsWhitelistFailOrNull(component.Whitelist, args.Used))
return;
if (GetBallisticShots(component) >= component.Capacity)
public bool TryRevolverInsert(EntityUid revolverUid, RevolverAmmoProviderComponent component, EntityUid uid, EntityUid? user)
{
- if (component.Whitelist?.IsValid(uid, EntityManager) == false)
+ if (_whitelistSystem.IsWhitelistFail(component.Whitelist, uid))
return false;
// If it's a speedloader try to get ammo from it.
using Content.Shared.Weapons.Melee.Events;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Events;
+using Content.Shared.Whitelist;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
[Dependency] protected readonly TagSystem TagSystem = default!;
[Dependency] protected readonly ThrowingSystem ThrowingSystem = default!;
[Dependency] private readonly UseDelaySystem _useDelay = default!;
+ [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
private const float InteractNextFire = 0.3f;
private const double SafetyNextFire = 0.5;
return list.RequireAll;
}
+ /// The following are a list of "helper functions" that are basically the same as each other
+ /// to help make code that uses EntityWhitelist a bit more readable because at the moment
+ /// it is quite clunky having to write out component.Whitelist == null ? true : _whitelist.IsValid(component.Whitelist, uid)
+ /// several times in a row and makes comparisons easier to read
+
+ /// <summary>
+ /// Helper function to determine if Whitelist is not null and entity is on list
+ /// </summary>
+ public bool IsWhitelistPass(EntityWhitelist? whitelist, EntityUid uid)
+ {
+ if (whitelist == null)
+ return false;
+
+ return IsValid(whitelist, uid);
+ }
+
+ /// <summary>
+ /// Helper function to determine if Whitelist is not null and entity is not on the list
+ /// </summary>
+ public bool IsWhitelistFail(EntityWhitelist? whitelist, EntityUid uid)
+ {
+ if (whitelist == null)
+ return false;
+
+ return !IsValid(whitelist, uid);
+ }
+
+ /// <summary>
+ /// Helper function to determine if Whitelist is either null or the entity is on the list
+ /// </summary>
+ public bool IsWhitelistPassOrNull(EntityWhitelist? whitelist, EntityUid uid)
+ {
+ if (whitelist == null)
+ return true;
+
+ return IsValid(whitelist, uid);
+ }
+
+ /// <summary>
+ /// Helper function to determine if Whitelist is either null or the entity is not on the list
+ /// </summary>
+ public bool IsWhitelistFailOrNull(EntityWhitelist? whitelist, EntityUid uid)
+ {
+ if (whitelist == null)
+ return true;
+
+ return !IsValid(whitelist, uid);
+ }
+
+ /// <summary>
+ /// Helper function to determine if Blacklist is not null and entity is on list
+ /// Duplicate of equivalent Whitelist function
+ /// </summary>
+ public bool IsBlacklistPass(EntityWhitelist? blacklist, EntityUid uid)
+ {
+ return IsWhitelistPass(blacklist, uid);
+ }
+
+ /// <summary>
+ /// Helper function to determine if Blacklist is not null and entity is not on the list
+ /// Duplicate of equivalent Whitelist function
+ /// </summary>
+ public bool IsBlacklistFail(EntityWhitelist? blacklist, EntityUid uid)
+ {
+ return IsWhitelistFail(blacklist, uid);
+ }
+
+ /// <summary>
+ /// Helper function to determine if Blacklist is either null or the entity is on the list
+ /// Duplicate of equivalent Whitelist function
+ /// </summary>
+ public bool IsBlacklistPassOrNull(EntityWhitelist? blacklist, EntityUid uid)
+ {
+ return IsWhitelistPassOrNull(blacklist, uid);
+ }
+
+ /// <summary>
+ /// Helper function to determine if Blacklist is either null or the entity is not on the list
+ /// Duplicate of equivalent Whitelist function
+ /// </summary>
+ public bool IsBlacklistFailOrNull(EntityWhitelist? blacklist, EntityUid uid)
+ {
+ return IsWhitelistFailOrNull(blacklist, uid);
+ }
private void EnsureRegistrations(EntityWhitelist list)
{