CatStation/Content.Shared/Chemistry/EntitySystems/ScoopableSolutionSystem.cs
Whatstone a88d2c5164
Cleanup: Resolve remaining PopupSystem warnings in Content.Shared (#44685)
* PopupClient to PopupEntity/Coordinates

* PopupPredictedX to PopupEntity/Cursor/Coordinates

* The rest of the damn owl

* nullability fixes

* Buckle cleanup

* cleanup, address PR comments

* ExecutionSystem: one popup method

* correct my filthy lies

* Apply most of ajcm's suggestions

* return user to SharedItemRecallSystem.cs

* Fix lingering Ensnarable broadcast popups

* targeted drain popups

* fix lingering untargeted Guardian popups

I read the comment on GuardianHostRecall.  Oops.

* target stethoscope popups

* fix the PDA vibration popup

* Fix target for encryption key removal popup

* anomaly scanner: args.User, not uid

* disposal unit comment, bcast pda vibration popup
2026-07-16 21:54:33 +00:00

56 lines
2 KiB
C#

using Content.Shared.Chemistry.Components;
using Content.Shared.Interaction;
using Content.Shared.Popups;
using Robust.Shared.Network;
namespace Content.Shared.Chemistry.EntitySystems;
/// <summary>
/// Handles solution transfer when a beaker is used on a scoopable entity.
/// </summary>
public sealed partial class ScoopableSolutionSystem : EntitySystem
{
[Dependency] private INetManager _netManager = default!;
[Dependency] private SharedPopupSystem _popup = default!;
[Dependency] private SharedSolutionContainerSystem _solution = default!;
[Dependency] private SolutionTransferSystem _solutionTransfer = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ScoopableSolutionComponent, InteractUsingEvent>(OnInteractUsing);
}
private void OnInteractUsing(Entity<ScoopableSolutionComponent> ent, ref InteractUsingEvent args)
{
if (args.Handled)
return;
args.Handled = TryScoop(ent, args.Used, args.User);
}
public bool TryScoop(Entity<ScoopableSolutionComponent> ent, EntityUid beaker, EntityUid user)
{
if (!_solution.TryGetSolution(ent.Owner, ent.Comp.Solution, out var src, out var srcSolution) ||
!_solution.TryGetRefillableSolution(beaker, out var target, out _))
return false;
var scooped = _solutionTransfer.Transfer(new SolutionTransferData(user, ent, src.Value, beaker, target.Value, srcSolution.Volume));
if (scooped == 0)
return false;
_popup.PopupEntity(Loc.GetString(ent.Comp.Popup, ("scooped", ent.Owner), ("beaker", beaker)), user, user);
if (srcSolution.Volume == 0 && ent.Comp.Delete)
{
// deletion isnt predicted so do this to prevent spam clicking to see "the ash is empty!"
RemCompDeferred<ScoopableSolutionComponent>(ent);
if (!_netManager.IsClient)
QueueDel(ent);
}
return true;
}
}