]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Cleanup: Un-hardcode reagents standout (#39752)
authorWinkarst-cpu <74284083+Winkarst-cpu@users.noreply.github.com>
Tue, 19 Aug 2025 14:40:21 +0000 (17:40 +0300)
committerGitHub <noreply@github.com>
Tue, 19 Aug 2025 14:40:21 +0000 (10:40 -0400)
Content.Shared/Chemistry/Reagent/ReagentPrototype.cs
Content.Shared/Fluids/SharedPuddleSystem.cs
Resources/Prototypes/Reagents/biological.yml

index 1a3d17c340b1a4d28ba9c60024322cbe89dbb365..7689a27cd00269272ad5ee8bb17630bf11714164 100644 (file)
@@ -63,6 +63,12 @@ namespace Content.Shared.Chemistry.Reagent
         [DataField]
         public bool Recognizable;
 
+        /// <summary>
+        /// Whether this reagent stands out (blood, slime).
+        /// </summary>
+        [DataField]
+        public bool Standsout;
+
         [DataField]
         public ProtoId<FlavorPrototype>? Flavor;
 
index a2f0764ce0418834ad1643c8472c26e33d3fe5ee..2d0fffa37b6b3054984a3fda4975999d9821caf2 100644 (file)
@@ -22,11 +22,7 @@ public abstract partial class SharedPuddleSystem : EntitySystem
     [Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
     [Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
 
-    private static readonly ProtoId<ReagentPrototype> Blood = "Blood";
-    private static readonly ProtoId<ReagentPrototype> Slime = "Slime";
-    private static readonly ProtoId<ReagentPrototype> CopperBlood = "CopperBlood";
-
-    private static readonly string[] StandoutReagents = [Blood, Slime, CopperBlood];
+    private string[] _standoutReagents = [];
 
     /// <summary>
     /// The lowest threshold to be considered for puddle sprite states as well as slipperiness of a puddle.
@@ -48,9 +44,26 @@ public abstract partial class SharedPuddleSystem : EntitySystem
         SubscribeLocalEvent<PuddleComponent, ExaminedEvent>(HandlePuddleExamined);
         SubscribeLocalEvent<PuddleComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
 
+        SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnPrototypesReloaded);
+
+        CacheStandsout();
         InitializeSpillable();
     }
 
+    private void OnPrototypesReloaded(PrototypesReloadedEventArgs ev)
+    {
+        if (ev.WasModified<ReagentPrototype>())
+            CacheStandsout();
+    }
+
+    /// <summary>
+    /// Used to cache standout reagents for future use.
+    /// </summary>
+    private void CacheStandsout()
+    {
+        _standoutReagents = [.. _prototypeManager.EnumeratePrototypes<ReagentPrototype>().Where(x => x.Standsout).Select(x => x.ID)];
+    }
+
     protected virtual void OnSolutionUpdate(Entity<PuddleComponent> entity, ref SolutionContainerChangedEvent args)
     {
         if (args.SolutionId != entity.Comp.SolutionName)
@@ -158,10 +171,10 @@ public abstract partial class SharedPuddleSystem : EntitySystem
             // Kinda EH
             // Could potentially do alpha per-solution but future problem.
 
-            color = solution.GetColorWithout(_prototypeManager, StandoutReagents);
+            color = solution.GetColorWithout(_prototypeManager, _standoutReagents);
             color = color.WithAlpha(0.7f);
 
-            foreach (var standout in StandoutReagents)
+            foreach (var standout in _standoutReagents)
             {
                 var quantity = solution.GetTotalPrototypeQuantity(standout);
                 if (quantity <= FixedPoint2.Zero)
index 1a4fc9342629b37030164670d2fca72a7751176c..d6063cd9a7933d8560e22f7031cc2046d003c209 100644 (file)
@@ -12,6 +12,7 @@
   metamorphicFillBaseName: fill-
   metamorphicChangeColor: false
   recognizable: true
+  standsout: true
   physicalDesc: reagent-physical-desc-ferrous
   metabolisms:
     Drink:
@@ -64,6 +65,7 @@
   flavor: slimy
   color: "#2cf274"
   recognizable: true
+  standsout: true
   physicalDesc: reagent-physical-desc-viscous
   viscosity: 0.25
   tileReactions: