SpillIfPuddlePresentTileReaction.cs 1.0 KB

123456789101112131415161718192021222324252627282930
  1. using Content.Server.Fluids.EntitySystems;
  2. using Content.Shared.Chemistry.Components;
  3. using Content.Shared.Chemistry.Reaction;
  4. using Content.Shared.Chemistry.Reagent;
  5. using Content.Shared.FixedPoint;
  6. using JetBrains.Annotations;
  7. using Robust.Shared.Map;
  8. namespace Content.Server.Chemistry.TileReactions
  9. {
  10. [UsedImplicitly]
  11. [DataDefinition]
  12. public sealed partial class SpillIfPuddlePresentTileReaction : ITileReaction
  13. {
  14. public FixedPoint2 TileReact(TileRef tile,
  15. ReagentPrototype reagent,
  16. FixedPoint2 reactVolume,
  17. IEntityManager entityManager,
  18. List<ReagentData>? data)
  19. {
  20. var spillSystem = entityManager.System<PuddleSystem>();
  21. if (reactVolume < 5 || !spillSystem.TryGetPuddle(tile, out _))
  22. return FixedPoint2.Zero;
  23. return spillSystem.TrySpillAt(tile, new Solution(reagent.ID, reactVolume, data), out _, sound: false, tileReact: false)
  24. ? reactVolume
  25. : FixedPoint2.Zero;
  26. }
  27. }
  28. }