From: Winkarst-cpu <74284083+Winkarst-cpu@users.noreply.github.com> Date: Tue, 19 Aug 2025 14:40:21 +0000 (+0300) Subject: Cleanup: Un-hardcode reagents standout (#39752) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=be2eeb3cb14795cf24862263ff868a53a14ffe71;p=space-station-14.git Cleanup: Un-hardcode reagents standout (#39752) --- diff --git a/Content.Shared/Chemistry/Reagent/ReagentPrototype.cs b/Content.Shared/Chemistry/Reagent/ReagentPrototype.cs index 1a3d17c340..7689a27cd0 100644 --- a/Content.Shared/Chemistry/Reagent/ReagentPrototype.cs +++ b/Content.Shared/Chemistry/Reagent/ReagentPrototype.cs @@ -63,6 +63,12 @@ namespace Content.Shared.Chemistry.Reagent [DataField] public bool Recognizable; + /// + /// Whether this reagent stands out (blood, slime). + /// + [DataField] + public bool Standsout; + [DataField] public ProtoId? Flavor; diff --git a/Content.Shared/Fluids/SharedPuddleSystem.cs b/Content.Shared/Fluids/SharedPuddleSystem.cs index a2f0764ce0..2d0fffa37b 100644 --- a/Content.Shared/Fluids/SharedPuddleSystem.cs +++ b/Content.Shared/Fluids/SharedPuddleSystem.cs @@ -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 Blood = "Blood"; - private static readonly ProtoId Slime = "Slime"; - private static readonly ProtoId CopperBlood = "CopperBlood"; - - private static readonly string[] StandoutReagents = [Blood, Slime, CopperBlood]; + private string[] _standoutReagents = []; /// /// 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(HandlePuddleExamined); SubscribeLocalEvent(OnEntRemoved); + SubscribeLocalEvent(OnPrototypesReloaded); + + CacheStandsout(); InitializeSpillable(); } + private void OnPrototypesReloaded(PrototypesReloadedEventArgs ev) + { + if (ev.WasModified()) + CacheStandsout(); + } + + /// + /// Used to cache standout reagents for future use. + /// + private void CacheStandsout() + { + _standoutReagents = [.. _prototypeManager.EnumeratePrototypes().Where(x => x.Standsout).Select(x => x.ID)]; + } + protected virtual void OnSolutionUpdate(Entity 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) diff --git a/Resources/Prototypes/Reagents/biological.yml b/Resources/Prototypes/Reagents/biological.yml index 1a4fc93426..d6063cd9a7 100644 --- a/Resources/Prototypes/Reagents/biological.yml +++ b/Resources/Prototypes/Reagents/biological.yml @@ -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: