CatStation/Content.Shared/Nutrition/EntitySystems/MessyDrinkerSystem.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

50 lines
1.6 KiB
C#

using Content.Shared.Fluids;
using Content.Shared.Nutrition.Components;
using Content.Shared.Popups;
using Content.Shared.Random.Helpers;
using Content.Shared.Tag;
using Robust.Shared.Random;
using Robust.Shared.Timing;
namespace Content.Shared.Nutrition.EntitySystems;
public sealed partial class MessyDrinkerSystem : EntitySystem
{
[Dependency] private IngestionSystem _ingestion = default!;
[Dependency] private SharedPuddleSystem _puddle = default!;
[Dependency] private SharedPopupSystem _popup = default!;
[Dependency] private IGameTiming _timing = default!;
[Dependency] private TagSystem _tag = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MessyDrinkerComponent, IngestingEvent>(OnIngested);
}
private void OnIngested(Entity<MessyDrinkerComponent> ent, ref IngestingEvent ev)
{
if (ent.Comp.SpillImmuneTag != null && _tag.HasTag(ev.Food, ent.Comp.SpillImmuneTag.Value))
return;
// Cannot spill if you're being forced to drink.
if (ev.ForceFed)
return;
var proto = _ingestion.GetEdibleType(ev.Food);
if (proto == null || !ent.Comp.SpillableTypes.Contains(proto.Value))
return;
if (!SharedRandomExtensions.PredictedProb(_timing, ent.Comp.SpillChance, GetNetEntity(ent)))
return;
if (ent.Comp.SpillMessagePopup != null)
_popup.PopupEntity(Loc.GetString(ent.Comp.SpillMessagePopup), ent, ent, PopupType.MediumCaution);
var split = ev.Split.SplitSolution(ent.Comp.SpillAmount);
_puddle.TrySpillAt(ent, split, out _);
}
}