ProjectileComponent.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using Content.Shared.Damage;
  2. using Content.Shared.FixedPoint;
  3. using Robust.Shared.Audio;
  4. using Robust.Shared.GameStates;
  5. using Robust.Shared.Prototypes;
  6. namespace Content.Shared.Projectiles;
  7. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
  8. public sealed partial class ProjectileComponent : Component
  9. {
  10. /// <summary>
  11. /// The angle of the fired projectile.
  12. /// </summary>
  13. [DataField, AutoNetworkedField]
  14. public Angle Angle;
  15. /// <summary>
  16. /// The effect that appears when a projectile collides with an entity.
  17. /// </summary>
  18. [DataField, ViewVariables(VVAccess.ReadWrite)]
  19. public EntProtoId? ImpactEffect;
  20. /// <summary>
  21. /// User that shot this projectile.
  22. /// </summary>
  23. [DataField, AutoNetworkedField]
  24. public EntityUid? Shooter;
  25. /// <summary>
  26. /// Weapon used to shoot.
  27. /// </summary>
  28. [DataField, AutoNetworkedField]
  29. public EntityUid? Weapon;
  30. /// <summary>
  31. /// The projectile spawns inside the shooter most of the time, this prevents entities from shooting themselves.
  32. /// </summary>
  33. [DataField, AutoNetworkedField]
  34. public bool IgnoreShooter = true;
  35. /// <summary>
  36. /// The amount of damage the projectile will do.
  37. /// </summary>
  38. [DataField(required: true)] [ViewVariables(VVAccess.ReadWrite)]
  39. public DamageSpecifier Damage = new();
  40. /// <summary>
  41. /// If the projectile should be deleted on collision.
  42. /// </summary>
  43. [DataField]
  44. public bool DeleteOnCollide = true;
  45. /// <summary>
  46. /// Ignore all damage resistances the target has.
  47. /// </summary>
  48. [DataField]
  49. public bool IgnoreResistances = false;
  50. /// <summary>
  51. /// Get that juicy FPS hit sound.
  52. /// </summary>
  53. [DataField]
  54. public SoundSpecifier? SoundHit;
  55. /// <summary>
  56. /// Force the projectiles sound to play rather than potentially playing the entity's sound.
  57. /// </summary>
  58. [DataField]
  59. public bool ForceSound = false;
  60. /// <summary>
  61. /// Whether this projectile will only collide with entities if it was shot from a gun (if <see cref="Weapon"/> is not null).
  62. /// </summary>
  63. [DataField]
  64. public bool OnlyCollideWhenShot = false;
  65. /// <summary>
  66. /// If true, the projectile has hit enough targets and should no longer interact with further collisions pending deletion.
  67. /// </summary>
  68. [DataField]
  69. public bool ProjectileSpent;
  70. /// <summary>
  71. /// When a projectile has this threshold set, it will continue to penetrate entities until the damage dealt reaches this threshold.
  72. /// </summary>
  73. [DataField]
  74. public FixedPoint2 PenetrationThreshold = FixedPoint2.Zero;
  75. /// <summary>
  76. /// If set, the projectile will not penetrate objects that lack the ability to take these damage types.
  77. /// </summary>
  78. [DataField]
  79. public List<string>? PenetrationDamageTypeRequirement;
  80. /// <summary>
  81. /// Tracks the amount of damage dealt for penetration purposes.
  82. /// </summary>
  83. [DataField]
  84. public FixedPoint2 PenetrationAmount = FixedPoint2.Zero;
  85. }