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:
@@ -81,9 +81,7 @@ public partial class ChatSystem
|
||||
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 &&
|
||||
|
||||
@@ -22,6 +22,7 @@ using Content.Shared.Mobs.Systems;
|
||||
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;
|
||||
@@ -58,6 +59,7 @@ public sealed partial class ChatSystem : SharedChatSystem
|
||||
[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
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Server.Gatherable.Components;
|
||||
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;
|
||||
@@ -18,6 +19,7 @@ public sealed partial class GatherableSystem : EntitySystem
|
||||
[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()
|
||||
{
|
||||
@@ -30,7 +32,7 @@ public sealed partial class GatherableSystem : EntitySystem
|
||||
|
||||
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);
|
||||
@@ -41,7 +43,7 @@ public sealed partial class GatherableSystem : EntitySystem
|
||||
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);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
@@ -13,6 +14,7 @@ public sealed partial class NPCImprintingOnSpawnBehaviourSystem : SharedNPCImpri
|
||||
[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()
|
||||
{
|
||||
@@ -27,7 +29,7 @@ public sealed partial class NPCImprintingOnSpawnBehaviourSystem : SharedNPCImpri
|
||||
|
||||
foreach (var friend in friends)
|
||||
{
|
||||
if (imprinting.Comp.Whitelist?.IsValid(friend) != false)
|
||||
if (_whitelistSystem.IsWhitelistPassOrNull(imprinting.Comp.Whitelist, friend))
|
||||
{
|
||||
AddImprintingTarget(imprinting, friend, imprinting.Comp);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ using Content.Shared.Tools.Systems;
|
||||
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;
|
||||
@@ -46,6 +47,7 @@ public sealed class NPCUtilitySystem : EntitySystem
|
||||
[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;
|
||||
@@ -249,7 +251,7 @@ public sealed class NPCUtilitySystem : EntitySystem
|
||||
return 0f;
|
||||
}
|
||||
|
||||
if (heldGun.Whitelist?.IsValid(targetUid, EntityManager) != true)
|
||||
if (_whitelistSystem.IsWhitelistFailOrNull(heldGun.Whitelist, targetUid))
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ using Robust.Shared.Containers;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Shared.Storage.Components;
|
||||
using Robust.Server.Containers;
|
||||
using Content.Shared.Whitelist;
|
||||
|
||||
namespace Content.Server.Power.EntitySystems;
|
||||
|
||||
@@ -20,6 +21,7 @@ internal sealed class ChargerSystem : EntitySystem
|
||||
[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()
|
||||
{
|
||||
@@ -208,7 +210,7 @@ internal sealed class ChargerSystem : EntitySystem
|
||||
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))
|
||||
|
||||
@@ -28,6 +28,7 @@ using Content.Shared.Revenant.Components;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Content.Shared.Whitelist;
|
||||
|
||||
namespace Content.Server.Revenant.EntitySystems;
|
||||
|
||||
@@ -40,6 +41,7 @@ public sealed partial class RevenantSystem
|
||||
[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()
|
||||
{
|
||||
@@ -331,10 +333,8 @@ public sealed partial class RevenantSystem
|
||||
|
||||
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.
|
||||
|
||||
@@ -267,7 +267,7 @@ public sealed partial class BorgSystem
|
||||
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);
|
||||
|
||||
@@ -22,6 +22,7 @@ using Content.Shared.Roles;
|
||||
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;
|
||||
@@ -53,6 +54,8 @@ public sealed partial class BorgSystem : SharedBorgSystem
|
||||
[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";
|
||||
@@ -104,9 +107,8 @@ public sealed partial class BorgSystem : SharedBorgSystem
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Shared.Database;
|
||||
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;
|
||||
|
||||
@@ -15,6 +16,7 @@ public sealed class PickRandomSystem : EntitySystem
|
||||
[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()
|
||||
{
|
||||
@@ -30,7 +32,7 @@ public sealed class PickRandomSystem : EntitySystem
|
||||
|
||||
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
|
||||
@@ -48,7 +50,7 @@ public sealed class PickRandomSystem : EntitySystem
|
||||
|
||||
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;
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
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();
|
||||
@@ -81,7 +82,8 @@ public sealed partial class ArtifactSystem
|
||||
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);
|
||||
@@ -95,7 +97,8 @@ public sealed partial class ArtifactSystem
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user