Fix spray nozzle not cleaning reagents properly (#35950)

* init, god help us all

* further refining

* final round of bugfixes

* whoopsies

* To file scoped namespace

* first review

* oopsie

* oopsie woopsie

* pie is on my face

* persistence

* datafieldn't

* make PreviousTileRef nullable

* change component to file scoped namespace

* Minor tweaks:

- We clamp the reaction amount to a minimum value because when working with percentages and dividing, we approach numbers like 0.01 and never actually properly delete the entity (because we check for zero). This allows us to react with a minimum amount and cleans things up nicely.
- Minor clarification to comments.
- Rebalancing of the spray nozzle projectile.

* the scug lies!!!!

* undo file scoped namespace in system

* kid named warning

---------

Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com>
This commit is contained in:
ArtisticRoomba
2025-04-19 19:41:24 -07:00
committed by GitHub
parent a90c16b8d1
commit 44925b9be7
4 changed files with 94 additions and 47 deletions

View File

@@ -1,4 +1,4 @@
using Content.Shared.FixedPoint;
using Robust.Shared.Map;
namespace Content.Server.Chemistry.Components
{
@@ -7,11 +7,31 @@ namespace Content.Server.Chemistry.Components
{
public const string SolutionName = "vapor";
[DataField("transferAmount")]
public FixedPoint2 TransferAmount = FixedPoint2.New(0.5);
/// <summary>
/// Stores data on the previously reacted tile. We only want to do reaction checks once per tile.
/// </summary>
[DataField]
public TileRef? PreviousTileRef;
public float ReactTimer;
[DataField("active")]
/// <summary>
/// Percentage of the reagent that is reacted with the TileReaction.
/// <example>
/// 0.5 = 50% of the reagent is reacted.
/// </example>
/// </summary>
[DataField]
public float TransferAmountPercentage;
/// <summary>
/// The minimum amount of the reagent that will be reacted with the TileReaction.
/// We do this to prevent floating point issues. A reagent with a low percentage transfer amount will
/// transfer 0.01~ forever and never get deleted.
/// <remarks>Defaults to 0.05 if not defined, a good general value.</remarks>
/// </summary>
[DataField]
public float MinimumTransferAmount = 0.05f;
[DataField]
public bool Active;
}
}