Replace obsolete EntityWhitelist IsValid usages (#28465)
* Replace obsolete whitelist is valid with whitelist system * Consistency * Fix logic * Bork * I figured out how to get whitelists on the client lol * test fail * woops * HELP ME FUNCTIONS * Fix errors * simplify --------- Co-authored-by: plykiya <plykiya@protonmail.com>
This commit is contained in:
@@ -9,6 +9,7 @@ using Content.Shared.Interaction;
|
||||
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;
|
||||
@@ -31,6 +32,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
[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()
|
||||
{
|
||||
@@ -266,8 +268,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
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);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
@@ -11,6 +12,7 @@ public sealed class DamageContactsSystem : EntitySystem
|
||||
[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()
|
||||
{
|
||||
@@ -63,7 +65,7 @@ public sealed class DamageContactsSystem : EntitySystem
|
||||
if (HasComp<DamagedByContactComponent>(otherUid))
|
||||
return;
|
||||
|
||||
if (component.IgnoreWhitelist?.IsValid(otherUid) ?? false)
|
||||
if (_whitelistSystem.IsWhitelistFail(component.IgnoreWhitelist, otherUid))
|
||||
return;
|
||||
|
||||
var damagedByContact = EnsureComp<DamagedByContactComponent>(otherUid);
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Shared.DoAfter;
|
||||
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;
|
||||
@@ -18,6 +19,7 @@ public abstract class SharedDevourSystem : EntitySystem
|
||||
[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()
|
||||
{
|
||||
@@ -41,7 +43,7 @@ public abstract class SharedDevourSystem : EntitySystem
|
||||
/// </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;
|
||||
|
||||
@@ -6,6 +6,7 @@ using Content.Shared.DragDrop;
|
||||
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;
|
||||
@@ -25,6 +26,7 @@ public abstract class SharedDisposalUnitSystem : EntitySystem
|
||||
[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);
|
||||
|
||||
@@ -113,10 +115,8 @@ public abstract class SharedDisposalUnitSystem : EntitySystem
|
||||
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)
|
||||
|
||||
@@ -20,6 +20,7 @@ public abstract class SharedImplanterSystem : EntitySystem
|
||||
[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()
|
||||
{
|
||||
@@ -105,8 +106,8 @@ public abstract class SharedImplanterSystem : EntitySystem
|
||||
|
||||
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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
@@ -7,6 +7,7 @@ using Content.Shared.Inventory;
|
||||
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;
|
||||
@@ -25,6 +26,7 @@ public sealed class SmartEquipSystem : EntitySystem
|
||||
[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()
|
||||
@@ -182,7 +184,7 @@ public sealed class SmartEquipSystem : EntitySystem
|
||||
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;
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Linq;
|
||||
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;
|
||||
@@ -17,6 +18,7 @@ public abstract class SharedMaterialStorageSystem : EntitySystem
|
||||
[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.
|
||||
@@ -121,7 +123,7 @@ public abstract class SharedMaterialStorageSystem : EntitySystem
|
||||
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);
|
||||
@@ -239,7 +241,7 @@ public abstract class SharedMaterialStorageSystem : EntitySystem
|
||||
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))
|
||||
|
||||
@@ -6,6 +6,7 @@ using Content.Shared.Popups;
|
||||
using Robust.Shared.Serialization.Manager;
|
||||
using Robust.Shared.Prototypes;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Shared.Whitelist;
|
||||
|
||||
namespace Content.Shared.Polymorph.Systems;
|
||||
|
||||
@@ -18,6 +19,7 @@ public abstract class SharedChameleonProjectorSystem : EntitySystem
|
||||
[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()
|
||||
{
|
||||
@@ -49,8 +51,8 @@ public abstract class SharedChameleonProjectorSystem : EntitySystem
|
||||
/// </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>
|
||||
|
||||
@@ -6,6 +6,7 @@ using Content.Shared.Interaction;
|
||||
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;
|
||||
@@ -30,6 +31,7 @@ public abstract partial class SharedFultonSystem : EntitySystem
|
||||
[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;
|
||||
@@ -176,7 +178,7 @@ public abstract partial class SharedFultonSystem : EntitySystem
|
||||
if (!CanFulton(targetUid))
|
||||
return false;
|
||||
|
||||
if (component.Whitelist?.IsValid(targetUid, EntityManager) != true)
|
||||
if (_whitelistSystem.IsWhitelistFailOrNull(component.Whitelist, targetUid))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Shared.Containers.ItemSlots;
|
||||
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;
|
||||
@@ -15,6 +16,7 @@ public abstract partial class SharedShuttleSystem : EntitySystem
|
||||
[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;
|
||||
@@ -83,7 +85,7 @@ public abstract partial class SharedShuttleSystem : EntitySystem
|
||||
if (HasComp<FTLMapComponent>(mapUid))
|
||||
return false;
|
||||
|
||||
return destination.Whitelist?.IsValid(shuttleUid, EntityManager) != false;
|
||||
return _whitelistSystem.IsWhitelistPassOrNull(destination.Whitelist, shuttleUid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -16,6 +17,8 @@ public sealed class MagnetPickupSystem : EntitySystem
|
||||
[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);
|
||||
|
||||
@@ -63,7 +66,7 @@ public sealed class MagnetPickupSystem : EntitySystem
|
||||
|
||||
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)
|
||||
|
||||
@@ -15,6 +15,7 @@ using Content.Shared.Storage.Components;
|
||||
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;
|
||||
@@ -45,6 +46,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
|
||||
[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";
|
||||
|
||||
@@ -432,7 +434,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
|
||||
|
||||
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.
|
||||
|
||||
@@ -55,6 +55,7 @@ public abstract class SharedStorageSystem : EntitySystem
|
||||
[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;
|
||||
@@ -860,13 +861,8 @@ public abstract class SharedStorageSystem : EntitySystem
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
@@ -15,6 +16,7 @@ public abstract class SharedDamageMarkerSystem : EntitySystem
|
||||
[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()
|
||||
{
|
||||
@@ -58,7 +60,7 @@ public abstract class SharedDamageMarkerSystem : EntitySystem
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,10 @@ public abstract partial class SharedGunSystem
|
||||
|
||||
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)
|
||||
|
||||
@@ -89,7 +89,7 @@ public partial class SharedGunSystem
|
||||
|
||||
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.
|
||||
|
||||
@@ -21,6 +21,7 @@ using Content.Shared.Weapons.Melee;
|
||||
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;
|
||||
@@ -63,6 +64,7 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
[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;
|
||||
|
||||
@@ -60,6 +60,90 @@ public sealed class EntityWhitelistSystem : EntitySystem
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user