DrainComponent.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using Content.Shared.Chemistry.Components;
  2. using Content.Shared.Tag;
  3. using Robust.Shared.Audio;
  4. namespace Content.Shared.Fluids.Components;
  5. /// <summary>
  6. /// A Drain allows an entity to absorb liquid in a disposal goal. Drains can be filled manually (with the Empty verb)
  7. /// or they can absorb puddles of liquid around them when AutoDrain is set to true.
  8. /// When the entity also has a SolutionContainerManager attached with a solution named drainBuffer, this solution
  9. /// gets filled until the drain is full.
  10. /// When the drain is full, it can be unclogged using a plunger (i.e. an entity with a Plunger tag attached).
  11. /// Later this can be refactored into a proper Plunger component if needed.
  12. /// </summary>
  13. [RegisterComponent, Access(typeof(SharedDrainSystem))]
  14. public sealed partial class DrainComponent : Component
  15. {
  16. public const string SolutionName = "drainBuffer";
  17. [ValidatePrototypeId<TagPrototype>]
  18. public const string PlungerTag = "Plunger";
  19. [ViewVariables]
  20. public Entity<SolutionComponent>? Solution = null;
  21. [DataField]
  22. public float Accumulator = 0f;
  23. /// <summary>
  24. /// If true, automatically transfers solutions from nearby puddles and drains them. True for floor drains;
  25. /// false for things like toilets and sinks.
  26. /// </summary>
  27. [DataField]
  28. public bool AutoDrain = true;
  29. /// <summary>
  30. /// How many units per second the drain can absorb from the surrounding puddles.
  31. /// Divided by puddles, so if there are 5 puddles this will take 1/5 from each puddle.
  32. /// This will stay fixed to 1 second no matter what DrainFrequency is.
  33. /// </summary>
  34. [DataField]
  35. public float UnitsPerSecond = 6f;
  36. /// <summary>
  37. /// How many units are ejected from the buffer per second.
  38. /// </summary>
  39. [DataField]
  40. public float UnitsDestroyedPerSecond = 3f;
  41. /// <summary>
  42. /// How many (unobstructed) tiles away the drain will
  43. /// drain puddles from.
  44. /// </summary>
  45. [DataField]
  46. public float Range = 2.5f;
  47. /// <summary>
  48. /// How often in seconds the drain checks for puddles around it.
  49. /// If the EntityQuery seems a bit unperformant this can be increased.
  50. /// </summary>
  51. [DataField]
  52. public float DrainFrequency = 1f;
  53. /// <summary>
  54. /// How much time it takes to unclog it with a plunger
  55. /// </summary>
  56. [DataField]
  57. public float UnclogDuration = 1f;
  58. /// <summary>
  59. /// What's the probability of uncloging on each try
  60. /// </summary>
  61. [DataField]
  62. public float UnclogProbability = 0.75f;
  63. [DataField]
  64. public SoundSpecifier ManualDrainSound = new SoundPathSpecifier("/Audio/Effects/Fluids/slosh.ogg");
  65. [DataField]
  66. public SoundSpecifier PlungerSound = new SoundPathSpecifier("/Audio/Items/Janitor/plunger.ogg");
  67. [DataField]
  68. public SoundSpecifier UnclogSound = new SoundPathSpecifier("/Audio/Effects/Fluids/glug.ogg");
  69. }