Cleanup: Un-hardcode reagents standout (#39752)

This commit is contained in:
Winkarst-cpu
2025-08-19 17:40:21 +03:00
committed by GitHub
parent 438090a505
commit be2eeb3cb1
3 changed files with 28 additions and 7 deletions

View File

@@ -63,6 +63,12 @@ namespace Content.Shared.Chemistry.Reagent
[DataField] [DataField]
public bool Recognizable; public bool Recognizable;
/// <summary>
/// Whether this reagent stands out (blood, slime).
/// </summary>
[DataField]
public bool Standsout;
[DataField] [DataField]
public ProtoId<FlavorPrototype>? Flavor; public ProtoId<FlavorPrototype>? Flavor;

View File

@@ -22,11 +22,7 @@ public abstract partial class SharedPuddleSystem : EntitySystem
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!; [Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!; [Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
private static readonly ProtoId<ReagentPrototype> Blood = "Blood"; private string[] _standoutReagents = [];
private static readonly ProtoId<ReagentPrototype> Slime = "Slime";
private static readonly ProtoId<ReagentPrototype> CopperBlood = "CopperBlood";
private static readonly string[] StandoutReagents = [Blood, Slime, CopperBlood];
/// <summary> /// <summary>
/// The lowest threshold to be considered for puddle sprite states as well as slipperiness of a puddle. /// 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, ExaminedEvent>(HandlePuddleExamined);
SubscribeLocalEvent<PuddleComponent, EntRemovedFromContainerMessage>(OnEntRemoved); SubscribeLocalEvent<PuddleComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnPrototypesReloaded);
CacheStandsout();
InitializeSpillable(); 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) protected virtual void OnSolutionUpdate(Entity<PuddleComponent> entity, ref SolutionContainerChangedEvent args)
{ {
if (args.SolutionId != entity.Comp.SolutionName) if (args.SolutionId != entity.Comp.SolutionName)
@@ -158,10 +171,10 @@ public abstract partial class SharedPuddleSystem : EntitySystem
// Kinda EH // Kinda EH
// Could potentially do alpha per-solution but future problem. // Could potentially do alpha per-solution but future problem.
color = solution.GetColorWithout(_prototypeManager, StandoutReagents); color = solution.GetColorWithout(_prototypeManager, _standoutReagents);
color = color.WithAlpha(0.7f); color = color.WithAlpha(0.7f);
foreach (var standout in StandoutReagents) foreach (var standout in _standoutReagents)
{ {
var quantity = solution.GetTotalPrototypeQuantity(standout); var quantity = solution.GetTotalPrototypeQuantity(standout);
if (quantity <= FixedPoint2.Zero) if (quantity <= FixedPoint2.Zero)

View File

@@ -12,6 +12,7 @@
metamorphicFillBaseName: fill- metamorphicFillBaseName: fill-
metamorphicChangeColor: false metamorphicChangeColor: false
recognizable: true recognizable: true
standsout: true
physicalDesc: reagent-physical-desc-ferrous physicalDesc: reagent-physical-desc-ferrous
metabolisms: metabolisms:
Drink: Drink:
@@ -64,6 +65,7 @@
flavor: slimy flavor: slimy
color: "#2cf274" color: "#2cf274"
recognizable: true recognizable: true
standsout: true
physicalDesc: reagent-physical-desc-viscous physicalDesc: reagent-physical-desc-viscous
viscosity: 0.25 viscosity: 0.25
tileReactions: tileReactions: