Puddles & spreader refactor (#15191)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user