* Shelve * 22 file diff * What if it was just better * Hold that thought * Near final Commit, then YAML hell * 95% done with cs * Working Commit * Final Commit (Before reviews tear it apart and kill me) * Add a really stupid comment. * KILL * EXPLODE TEST FAILS WITH MY MIND * I hate it here * TACTICAL NUCLEAR STRIKE * Wait what the fuck was I doing? * Comments * Me when I'm stupid * Food doesn't need solutions * API improvements with some API weirdness * Move non-API out of API * Better comment * Fixes and spelling mistakes * Final fixes * Final fixes for real... * Kill food and drink localization files because I hate them. * Water droplet fix * Utensil fixes * Fix verb priority (It should've been 2) * A few minor localization fixes * merge conflict and stuff * MERGE CONFLICT NUCLEAR WAR!!! * Cleanup --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using Content.Server.Fluids.EntitySystems;
|
|
using Content.Server.Nutrition.Components;
|
|
using Content.Shared.Nutrition;
|
|
using Content.Shared.Nutrition.EntitySystems;
|
|
using Content.Shared.Popups;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.Nutrition.EntitySystems;
|
|
|
|
public sealed class MessyDrinkerSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly IngestionSystem _ingestion = default!;
|
|
[Dependency] private readonly PuddleSystem _puddle = default!;
|
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<MessyDrinkerComponent, IngestingEvent>(OnIngested);
|
|
}
|
|
|
|
private void OnIngested(Entity<MessyDrinkerComponent> ent, ref IngestingEvent ev)
|
|
{
|
|
if (ev.Split.Volume <= ent.Comp.SpillAmount)
|
|
return;
|
|
|
|
var proto = _ingestion.GetEdibleType(ev.Food);
|
|
|
|
if (proto == null || !ent.Comp.SpillableTypes.Contains(proto.Value))
|
|
return;
|
|
|
|
// Cannot spill if you're being forced to drink.
|
|
if (ev.ForceFed)
|
|
return;
|
|
|
|
if (!_random.Prob(ent.Comp.SpillChance))
|
|
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 _);
|
|
}
|
|
}
|