Puddles & spreader refactor (#15191)

This commit is contained in:
metalgearsloth
2023-04-10 15:37:03 +10:00
committed by GitHub
parent 3178ab83f6
commit 317a4013eb
141 changed files with 3046 additions and 3201 deletions

View File

@@ -17,25 +17,26 @@ namespace Content.Server.Atmos.Reactions
[DataField("molesPerUnit")] public float MolesPerUnit { get; } = 1;
[DataField("puddlePrototype")] public string? PuddlePrototype { get; } = "PuddleSmear";
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem)
{
// If any of the prototypes is invalid, we do nothing.
if (string.IsNullOrEmpty(Reagent) || string.IsNullOrEmpty(PuddlePrototype)) return ReactionResult.NoReaction;
if (string.IsNullOrEmpty(Reagent))
return ReactionResult.NoReaction;
// If we're not reacting on a tile, do nothing.
if (holder is not TileAtmosphere tile) return ReactionResult.NoReaction;
if (holder is not TileAtmosphere tile)
return ReactionResult.NoReaction;
// If we don't have enough moles of the specified gas, do nothing.
if (mixture.GetMoles(GasId) < MolesPerUnit) return ReactionResult.NoReaction;
if (mixture.GetMoles(GasId) < MolesPerUnit)
return ReactionResult.NoReaction;
// Remove the moles from the mixture...
mixture.AdjustMoles(GasId, -MolesPerUnit);
var tileRef = tile.GridIndices.GetTileRef(tile.GridIndex);
EntitySystem.Get<SpillableSystem>()
.SpillAt(tileRef, new Solution(Reagent, FixedPoint2.New(MolesPerUnit)), PuddlePrototype, sound: false);
EntitySystem.Get<PuddleSystem>()
.TrySpillAt(tileRef, new Solution(Reagent, FixedPoint2.New(MolesPerUnit)), out _, sound: false);
return ReactionResult.Reacting;
}