1
0

ThrusterComponent.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System.Numerics;
  2. using Content.Server.Shuttles.Systems;
  3. using Content.Shared.Damage;
  4. using Robust.Shared.GameStates;
  5. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  6. namespace Content.Server.Shuttles.Components
  7. {
  8. [RegisterComponent, NetworkedComponent, AutoGenerateComponentPause]
  9. [Access(typeof(ThrusterSystem))]
  10. public sealed partial class ThrusterComponent : Component
  11. {
  12. /// <summary>
  13. /// Whether the thruster has been force to be enabled / disabled (e.g. VV, interaction, etc.)
  14. /// </summary>
  15. [DataField, ViewVariables(VVAccess.ReadWrite)]
  16. public bool Enabled { get; set; } = true;
  17. /// <summary>
  18. /// This determines whether the thruster is actually enabled for the purposes of thrust
  19. /// </summary>
  20. public bool IsOn;
  21. // Need to serialize this because RefreshParts isn't called on Init and this will break post-mapinit maps!
  22. [ViewVariables(VVAccess.ReadWrite), DataField("thrust")]
  23. public float Thrust = 100f;
  24. [DataField("thrusterType")]
  25. public ThrusterType Type = ThrusterType.Linear;
  26. [DataField("burnShape")] public List<Vector2> BurnPoly = new()
  27. {
  28. new Vector2(-0.4f, 0.5f),
  29. new Vector2(-0.1f, 1.2f),
  30. new Vector2(0.1f, 1.2f),
  31. new Vector2(0.4f, 0.5f)
  32. };
  33. /// <summary>
  34. /// How much damage is done per second to anything colliding with our thrust.
  35. /// </summary>
  36. [DataField("damage")] public DamageSpecifier? Damage = new();
  37. [DataField("requireSpace")]
  38. public bool RequireSpace = true;
  39. // Used for burns
  40. public List<EntityUid> Colliding = new();
  41. public bool Firing = false;
  42. /// <summary>
  43. /// How often thruster deals damage.
  44. /// </summary>
  45. [DataField]
  46. public TimeSpan FireCooldown = TimeSpan.FromSeconds(2);
  47. /// <summary>
  48. /// Next time we tick damage for anyone colliding.
  49. /// </summary>
  50. [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField]
  51. public TimeSpan NextFire = TimeSpan.Zero;
  52. }
  53. public enum ThrusterType
  54. {
  55. Linear,
  56. // Angular meaning rotational.
  57. Angular,
  58. }
  59. }