Skip to content

Commit c141e3a

Browse files
committed
Plumbing Sinks and Smart Dispensers now respect reagent filters
1 parent e6a1e85 commit c141e3a

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

Content.Server/_Starlight/Plumbing/EntitySystems/PlumbingOutputSystem.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
using System.Linq;
12
using Content.Server.Popups;
3+
using Content.Shared._Starlight.Chemistry.Components;
24
using Content.Shared._Starlight.Plumbing.Components;
35
using Content.Shared.Chemistry.Components;
46
using Content.Shared.Chemistry.EntitySystems;
57
using Content.Shared.FixedPoint;
68
using Content.Shared.Interaction;
79
using JetBrains.Annotations;
10+
using NetCord;
811

912
namespace Content.Server._Starlight.Plumbing.EntitySystems;
1013

@@ -35,6 +38,19 @@ private void OnOutputInteractUsing(Entity<PlumbingOutputComponent> ent, ref Inte
3538
if (!_solutionSystem.TryGetSolution(ent.Owner, ent.Comp.SolutionName, out var outputSolutionEnt, out var outputSolution))
3639
return;
3740

41+
// Starlight Start
42+
if (TryComp<RefillReagentFilterComponent>(args.Used, out var filter)
43+
&& outputSolution.Contents.Any(sol => !filter.Reagents.Contains(sol.Reagent.Prototype)))
44+
{
45+
// Incorrect reagents being put into our lovely automenders (and anything with filters)!
46+
if (args.User is { Valid: true })
47+
_popup.PopupEntity(Loc.GetString(filter.Popup), ent.Owner, args.User);
48+
49+
args.Handled = true;
50+
return;
51+
}
52+
// Starlight End
53+
3854
var transferAmount = outputSolution.Volume;
3955
if (TryComp<SolutionTransferComponent>(args.Used, out var transferComp))
4056
transferAmount = FixedPoint2.Min(transferAmount, transferComp.TransferAmount);

Content.Server/_Starlight/Plumbing/EntitySystems/PlumbingSmartDispenserSystem.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using Content.Server._Starlight.Plumbing.Components;
2+
using Content.Server.Hands.Systems;
3+
using Content.Shared._Starlight.Chemistry.Components;
24
using Content.Shared._Starlight.Plumbing;
35
using Content.Shared._Starlight.Plumbing.Components;
46
using Content.Shared.Chemistry;
@@ -12,7 +14,6 @@
1214
using Content.Shared.Labels.Components;
1315
using Content.Shared.Popups;
1416
using JetBrains.Annotations;
15-
using Content.Server.Hands.Systems;
1617
using Robust.Server.GameObjects;
1718
using Robust.Shared.Player;
1819
using Robust.Shared.Prototypes;
@@ -454,6 +455,18 @@ private bool TryDispenseReagent(
454455
if (sourceReagent is not { } sourceReagentValue)
455456
return false;
456457

458+
// Starlight Start
459+
if (TryComp<RefillReagentFilterComponent>(targetContainer, out var filter)
460+
&& !filter.Reagents.Contains(reagentId))
461+
{
462+
// Incorrect reagents being put into our lovely automenders (and anything with filters)!
463+
if (showPopup && user is { Valid: true })
464+
_popup.PopupEntity(Loc.GetString(filter.Popup), ent.Owner, user.Value);
465+
466+
return false;
467+
}
468+
// Starlight End
469+
457470
if (!_solutionSystem.TryGetFitsInDispenser(targetContainer, out var targetEnt, out var targetSolution)
458471
&& !_solutionSystem.TryGetRefillableSolution(targetContainer, out targetEnt, out targetSolution)
459472
&& (!TryComp<InjectorComponent>(targetContainer, out var injector)

0 commit comments

Comments
 (0)