]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Messy drinker immunity and cleanup (#39989)
authorScarKy0 <106310278+ScarKy0@users.noreply.github.com>
Sat, 30 Aug 2025 15:38:28 +0000 (17:38 +0200)
committerGitHub <noreply@github.com>
Sat, 30 Aug 2025 15:38:28 +0000 (17:38 +0200)
init

Content.Shared/Nutrition/Components/MessyDrinkerComponent.cs
Content.Shared/Nutrition/EntitySystems/MessyDrinkerSystem.cs
Resources/Prototypes/tags.yml

index c077db823199cac3e6d99722bef7a2aee5d6f457..ea145019c2c44f2822f2672d6315ad5a9a554a76 100644 (file)
@@ -1,5 +1,6 @@
 using Content.Shared.FixedPoint;
 using Content.Shared.Nutrition.Prototypes;
+using Content.Shared.Tag;
 using Robust.Shared.GameStates;
 using Robust.Shared.Prototypes;
 
@@ -26,6 +27,13 @@ public sealed partial class MessyDrinkerComponent : Component
     [DataField, AutoNetworkedField]
     public List<ProtoId<EdiblePrototype>> SpillableTypes = new List<ProtoId<EdiblePrototype>> { "Drink" };
 
+    /// <summary>
+    /// Tag given to drinks that are immune to messy drinker.
+    /// For example, a spill-immune bottle.
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public ProtoId<TagPrototype> SpillImmuneTag = "MessyDrinkerImmune";
+
     [DataField, AutoNetworkedField]
     public LocId? SpillMessagePopup;
 }
index bf084e6054dc8bc8d16607f02194aaccd97f8079..d75e7bf018863a0d5573a381dce5f3cbd6a4c220 100644 (file)
@@ -2,6 +2,7 @@ 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;
 
@@ -13,6 +14,7 @@ public sealed class MessyDrinkerSystem : EntitySystem
     [Dependency] private readonly SharedPuddleSystem _puddle = default!;
     [Dependency] private readonly SharedPopupSystem _popup = default!;
     [Dependency] private readonly IGameTiming _timing = default!;
+    [Dependency] private readonly TagSystem _tag = default!;
 
     public override void Initialize()
     {
@@ -23,7 +25,11 @@ public sealed class MessyDrinkerSystem : EntitySystem
 
     private void OnIngested(Entity<MessyDrinkerComponent> ent, ref IngestingEvent ev)
     {
-        if (ev.Split.Volume <= ent.Comp.SpillAmount)
+        if (_tag.HasTag(ev.Food, ent.Comp.SpillImmuneTag))
+            return;
+
+        // Cannot spill if you're being forced to drink.
+        if (ev.ForceFed)
             return;
 
         var proto = _ingestion.GetEdibleType(ev.Food);
@@ -31,10 +37,6 @@ public sealed class MessyDrinkerSystem : EntitySystem
         if (proto == null || !ent.Comp.SpillableTypes.Contains(proto.Value))
             return;
 
-        // Cannot spill if you're being forced to drink.
-        if (ev.ForceFed)
-            return;
-
         // TODO: Replace with RandomPredicted once the engine PR is merged
         var seed = SharedRandomExtensions.HashCodeCombine(new() { (int)_timing.CurTick.Value, GetNetEntity(ent).Id });
         var rand = new System.Random(seed);
index a9b927cdcf78b8ada58b23dee569ea18caff4f48..4193ca52d1e862b84ab9e5961826d8b60ffcf21f 100644 (file)
 - type: Tag
   id: Medkit
 
+- type: Tag
+  id: MessyDrinkerImmune
+
 - type: Tag
   id: Metal