MeleeThrowOnHitComponent.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System.Numerics;
  2. using Robust.Shared.GameStates;
  3. using Robust.Shared.Physics.Components;
  4. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  5. namespace Content.Shared.Weapons.Melee.Components;
  6. /// <summary>
  7. /// This is used for a melee weapon that throws whatever gets hit by it in a line
  8. /// until it hits a wall or a time limit is exhausted.
  9. /// </summary>
  10. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
  11. [Access(typeof(MeleeThrowOnHitSystem))]
  12. public sealed partial class MeleeThrowOnHitComponent : Component
  13. {
  14. /// <summary>
  15. /// The speed at which hit entities should be thrown.
  16. /// </summary>
  17. [DataField, AutoNetworkedField]
  18. public float Speed = 10f;
  19. /// <summary>
  20. /// The maximum distance the hit entity should be thrown.
  21. /// </summary>
  22. [DataField, AutoNetworkedField]
  23. public float Distance = 20f;
  24. /// <summary>
  25. /// Whether or not anchorable entities should be unanchored when hit.
  26. /// </summary>
  27. [DataField, AutoNetworkedField]
  28. public bool UnanchorOnHit;
  29. /// <summary>
  30. /// How long should this stun the target, if applicable?
  31. /// </summary>
  32. [DataField, AutoNetworkedField]
  33. public TimeSpan? StunTime;
  34. /// <summary>
  35. /// Should this also work on a throw-hit?
  36. /// </summary>
  37. [DataField, AutoNetworkedField]
  38. public bool ActivateOnThrown;
  39. }
  40. /// <summary>
  41. /// Raised a weapon entity with <see cref="MeleeThrowOnHitComponent"/> to see if a throw is allowed.
  42. /// </summary>
  43. [ByRefEvent]
  44. public record struct AttemptMeleeThrowOnHitEvent(EntityUid Target, EntityUid? User, bool Cancelled = false, bool Handled = false);
  45. /// <summary>
  46. /// Raised a target entity before it is thrown by <see cref="MeleeThrowOnHitComponent"/>.
  47. /// </summary>
  48. [ByRefEvent]
  49. public record struct MeleeThrowOnHitStartEvent(EntityUid Weapon, EntityUid? User);