ChasingWalkComponent.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using Content.Server.Physics.Controllers;
  2. using Robust.Shared.Prototypes;
  3. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  4. namespace Content.Server.Physics.Components;
  5. /// <summary>
  6. /// A component which makes its entity chasing entity with selected component.
  7. /// </summary>
  8. [RegisterComponent, Access(typeof(ChasingWalkSystem)), AutoGenerateComponentPause]
  9. public sealed partial class ChasingWalkComponent : Component
  10. {
  11. /// <summary>
  12. /// The next moment in time when the entity is pushed toward its goal
  13. /// </summary>
  14. [DataField, ViewVariables(VVAccess.ReadWrite)]
  15. [AutoPausedField]
  16. public TimeSpan NextImpulseTime;
  17. /// <summary>
  18. /// Push-to-target frequency.
  19. /// </summary>
  20. [DataField, ViewVariables(VVAccess.ReadWrite)]
  21. public float ImpulseInterval = 2f;
  22. /// <summary>
  23. /// The minimum speed at which this entity will move.
  24. /// </summary>
  25. [DataField, ViewVariables(VVAccess.ReadWrite)]
  26. public float MinSpeed = 1.5f;
  27. /// <summary>
  28. /// The maximum speed at which this entity will move.
  29. /// </summary>
  30. [DataField, ViewVariables(VVAccess.ReadWrite)]
  31. public float MaxSpeed = 3f;
  32. /// <summary>
  33. /// The current speed.
  34. /// </summary>
  35. [DataField, ViewVariables(VVAccess.ReadWrite)]
  36. public float Speed;
  37. /// <summary>
  38. /// The minimum time interval in which an object can change its motion target.
  39. /// </summary>
  40. [DataField, ViewVariables(VVAccess.ReadWrite)]
  41. public float ChangeVectorMinInterval = 5f;
  42. /// <summary>
  43. /// The maximum time interval in which an object can change its motion target.
  44. /// </summary>
  45. [DataField, ViewVariables(VVAccess.ReadWrite)]
  46. public float ChangeVectorMaxInterval = 25f;
  47. /// <summary>
  48. /// The next change of direction time.
  49. /// </summary>
  50. [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
  51. [AutoPausedField]
  52. public TimeSpan NextChangeVectorTime;
  53. /// <summary>
  54. /// The component that the entity is chasing
  55. /// </summary>
  56. [DataField(required: true)]
  57. public ComponentRegistry ChasingComponent = [];
  58. /// <summary>
  59. /// The maximum radius in which the entity chooses the target component to follow
  60. /// </summary>
  61. [DataField, ViewVariables(VVAccess.ReadWrite)]
  62. public float MaxChaseRadius = 25;
  63. /// <summary>
  64. /// The entity uid, chasing by the component owner
  65. /// </summary>
  66. [DataField, ViewVariables(VVAccess.ReadWrite)]
  67. public EntityUid? ChasingEntity;
  68. }