GravityWellComponent.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using Content.Shared.Singularity.Components;
  2. using Content.Server.Singularity.EntitySystems;
  3. namespace Content.Server.Singularity.Components;
  4. /// <summary>
  5. /// The server-side version of <see cref="SharedGravityWellComponent"/>.
  6. /// Primarily managed by <see cref="GravityWellSystem"/>.
  7. /// </summary>
  8. [RegisterComponent, AutoGenerateComponentPause]
  9. public sealed partial class GravityWellComponent : Component
  10. {
  11. /// <summary>
  12. /// The maximum range at which the gravity well can push/pull entities.
  13. /// </summary>
  14. [DataField]
  15. public float MaxRange;
  16. /// <summary>
  17. /// The minimum range at which the gravity well can push/pull entities.
  18. /// This is effectively hardfloored at <see cref="GravityWellSystem.MinGravPulseRange"/>.
  19. /// </summary>
  20. [DataField]
  21. public float MinRange = 0f;
  22. /// <summary>
  23. /// The acceleration entities will experience towards the gravity well at a distance of 1m.
  24. /// Negative values accelerate entities away from the gravity well.
  25. /// Actual acceleration scales with the inverse of the distance to the singularity.
  26. /// </summary>
  27. [DataField]
  28. public float BaseRadialAcceleration = 0.0f;
  29. /// <summary>
  30. /// The acceleration entities will experience tangent to the gravity well at a distance of 1m.
  31. /// Positive tangential acceleration is counter-clockwise.
  32. /// Actual acceleration scales with the inverse of the distance to the singularity.
  33. /// </summary>
  34. [DataField]
  35. public float BaseTangentialAcceleration = 0.0f;
  36. #region Update Timing
  37. /// <summary>
  38. /// The amount of time that should elapse between automated updates to this gravity well.
  39. /// </summary>
  40. [DataField("gravPulsePeriod")]
  41. [ViewVariables(VVAccess.ReadOnly)]
  42. [Access(typeof(GravityWellSystem))]
  43. public TimeSpan TargetPulsePeriod { get; internal set; } = TimeSpan.FromSeconds(0.5);
  44. /// <summary>
  45. /// The next time at which this gravity well should pulse.
  46. /// </summary>
  47. [DataField, Access(typeof(GravityWellSystem)), AutoPausedField]
  48. public TimeSpan NextPulseTime { get; internal set; } = default!;
  49. /// <summary>
  50. /// The last time this gravity well pulsed.
  51. /// </summary>
  52. [ViewVariables(VVAccess.ReadOnly)]
  53. public TimeSpan LastPulseTime => NextPulseTime - TargetPulsePeriod;
  54. #endregion Update Timing
  55. }