AtmosDeviceComponent.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using Content.Server.Atmos.Components;
  2. using Content.Shared.Atmos.Components;
  3. namespace Content.Server.Atmos.Piping.Components;
  4. /// <summary>
  5. /// Component for atmos devices which are updated in line with atmos, as part of a <see cref="GridAtmosphereComponent"/>
  6. /// </summary>
  7. [RegisterComponent]
  8. public sealed partial class AtmosDeviceComponent : Component
  9. {
  10. /// <summary>
  11. /// If true, this device must be anchored before it will receive any AtmosDeviceUpdateEvents.
  12. /// </summary>
  13. [ViewVariables(VVAccess.ReadWrite)]
  14. [DataField]
  15. public bool RequireAnchored = true;
  16. /// <summary>
  17. /// If true, update even when there is no grid atmosphere. Normally, atmos devices only
  18. /// update when inside a grid atmosphere, because they work with gases in the environment
  19. /// and won't do anything useful if there is no environment. This is useful for devices
  20. /// like gas canisters whose contents can still react if the canister itself is not inside
  21. /// a grid atmosphere.
  22. /// </summary>
  23. [DataField]
  24. public bool JoinSystem = false;
  25. /// <summary>
  26. /// If non-null, the grid that this device is part of.
  27. /// </summary>
  28. [ViewVariables]
  29. public EntityUid? JoinedGrid = null;
  30. /// <summary>
  31. /// Indicates that a device is not on a grid atmosphere but still being updated.
  32. /// </summary>
  33. [ViewVariables]
  34. public bool JoinedSystem = false;
  35. [ViewVariables]
  36. public TimeSpan LastProcess = TimeSpan.Zero;
  37. }
  38. /// <summary>
  39. /// Raised directed on an atmos device as part of the atmos update loop when the device should do processing.
  40. /// Use this for atmos devices instead of <see cref="EntitySystem.Update"/>.
  41. /// </summary>
  42. [ByRefEvent]
  43. public readonly struct AtmosDeviceUpdateEvent(float dt, Entity<GridAtmosphereComponent, GasTileOverlayComponent>? grid, Entity<MapAtmosphereComponent?>? map)
  44. {
  45. /// <summary>
  46. /// Time elapsed since last update, in seconds. Multiply values used in the update handler
  47. /// by this number to make them tickrate-invariant. Use this number instead of AtmosphereSystem.AtmosTime.
  48. /// </summary>
  49. public readonly float dt = dt;
  50. /// <summary>
  51. /// The grid that this device is currently on.
  52. /// </summary>
  53. public readonly Entity<GridAtmosphereComponent?, GasTileOverlayComponent?>? Grid = grid == null
  54. ? null
  55. : (grid.Value, grid.Value, grid.Value);
  56. /// <summary>
  57. /// The map that the device & grid is on.
  58. /// </summary>
  59. public readonly Entity<MapAtmosphereComponent?>? Map = map;
  60. }