Skip to content

Commit

Permalink
Replace deprecated whitelist functions
Browse files Browse the repository at this point in the history
  • Loading branch information
NullWanderer authored and VMSolidus committed Dec 5, 2024
1 parent 110b7a7 commit 6ce8761
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Shared.Access.Systems;
using Content.Shared.Shipyard;
using Content.Shared.Whitelist;
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Shared.Prototypes;
Expand All @@ -10,6 +11,7 @@ public sealed class ShipyardConsoleBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;

private readonly AccessReaderSystem _access;
private readonly EntityWhitelistSystem _whitelist;
Expand All @@ -27,7 +29,7 @@ protected override void Open()
{
base.Open();

_menu = new ShipyardConsoleMenu(Owner, _proto, EntMan, _player, _access, _whitelist);
_menu = new ShipyardConsoleMenu(Owner, _proto, EntMan, _player, _access, _whitelistSystem);
_menu.OpenCentered();
_menu.OnClose += Close;
_menu.OnPurchased += Purchase;
Expand Down
5 changes: 3 additions & 2 deletions Content.Client/DeltaV/Shipyard/UI/ShipyardConsoleMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Shared.Access.Systems;
using Content.Shared.Shipyard;
using Content.Shared.Shipyard.Prototypes;
using Content.Shared.Whitelist;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.Player;
Expand All @@ -25,7 +26,7 @@ public sealed partial class ShipyardConsoleMenu : FancyWindow
public Entity<ShipyardConsoleComponent> Console;
private string? _category;

public ShipyardConsoleMenu(EntityUid console, IPrototypeManager proto, IEntityManager entMan, IPlayerManager player, AccessReaderSystem access)
public ShipyardConsoleMenu(EntityUid console, IPrototypeManager proto, IEntityManager entMan, IPlayerManager player, AccessReaderSystem access, EntityWhitelistSystem whitelist)
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
Expand All @@ -37,7 +38,7 @@ public ShipyardConsoleMenu(EntityUid console, IPrototypeManager proto, IEntityMa
// don't include ships that aren't allowed by whitelist, server won't accept them anyway
foreach (var vessel in proto.EnumeratePrototypes<VesselPrototype>())
{
if (whitelist.IsWhitelistPassOrNull(vessel.Whitelist, console))
if (whitelist.IsWhitelistPass(vessel.Whitelist, console))
_vessels.Add(vessel);
}
_vessels.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.CurrentCultureIgnoreCase));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
using Content.Shared.Popups;
using Content.Shared.Throwing;
using Content.Shared.UserInterface;
using Content.Shared.Whitelist;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
Expand Down Expand Up @@ -76,6 +77,7 @@ public sealed partial class DeepFryerSystem : SharedDeepfryerSystem
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly AmbientSoundSystem _ambientSoundSystem = default!;
[Dependency] private readonly MetaDataSystem _metaDataSystem = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;

private static readonly string CookingDamageType = "Heat";
private static readonly float CookingDamageAmount = 10.0f;
Expand Down Expand Up @@ -306,7 +308,7 @@ private void DeepFry(EntityUid uid, DeepFryerComponent component, EntityUid item
// just in case the attempt is relevant to any system in the future.
//
// The blacklist overrides all.
if (component.Blacklist != null && component.Blacklist.IsValid(item, EntityManager))
if (component.Blacklist != null && _whitelistSystem.IsWhitelistPass(component.Blacklist, item))
{
_popupSystem.PopupEntity(
Loc.GetString("deep-fryer-blacklist-item-failed",
Expand Down Expand Up @@ -348,7 +350,7 @@ private void DeepFry(EntityUid uid, DeepFryerComponent component, EntityUid item
_ => 10
} * component.SolutionSizeCoefficient);

if (component.Whitelist != null && component.Whitelist.IsValid(item, EntityManager) ||
if (component.Whitelist != null && _whitelistSystem.IsWhitelistPass(component.Whitelist, item) ||
beingEvent.TurnIntoFood)
MakeEdible(uid, component, item, solutionQuantity);
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Shared.Stealth;
using Content.Shared.Stealth.Components;
using Content.Shared.Whitelist;
using Robust.Shared.Physics.Events;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Timing;
Expand All @@ -13,6 +14,7 @@ public sealed class PsionicInvisibleContactsSystem : EntitySystem
{
[Dependency] private readonly SharedStealthSystem _stealth = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;

public override void Initialize()
{
Expand All @@ -28,7 +30,7 @@ private void OnEntityEnter(EntityUid uid, PsionicInvisibleContactsComponent comp
var otherUid = args.OtherEntity;
var ourEntity = args.OurEntity;

if (!component.Whitelist.IsValid(otherUid))
if (_whitelistSystem.IsWhitelistFail(component.Whitelist, otherUid))
return;

// This will go up twice per web hit, since webs also have a flammable fixture.
Expand All @@ -48,7 +50,7 @@ private void OnEntityExit(EntityUid uid, PsionicInvisibleContactsComponent compo
var otherUid = args.OtherEntity;
var ourEntity = args.OurEntity;

if (!component.Whitelist.IsValid(otherUid))
if (_whitelistSystem.IsWhitelistFail(component.Whitelist, otherUid))
return;

if (!HasComp<PsionicallyInvisibleComponent>(ourEntity))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Shared.Access.Systems;
using Content.Shared.Popups;
using Content.Shared.Shipyard.Prototypes;
using Content.Shared.Whitelist;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Prototypes;

Expand All @@ -16,6 +17,7 @@ public abstract class SharedShipyardConsoleSystem : EntitySystem
[Dependency] protected readonly IPrototypeManager _proto = default!;
[Dependency] protected readonly SharedAudioSystem Audio = default!;
[Dependency] protected readonly SharedPopupSystem Popup = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;

public override void Initialize()
{
Expand All @@ -37,7 +39,7 @@ private void OnPurchase(Entity<ShipyardConsoleComponent> ent, ref ShipyardConsol
return;
}

if (!_proto.TryIndex(msg.Vessel, out var vessel) || vessel.Whitelist?.IsValid(ent) == false)
if (!_proto.TryIndex(msg.Vessel, out var vessel) || _whitelistSystem.IsWhitelistFail(vessel.Whitelist, ent))
return;

TryPurchase(ent, user, vessel);
Expand Down

0 comments on commit 6ce8761

Please sign in to comment.