1
0

ProjectileComponent.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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)]
  39. [ViewVariables(VVAccess.ReadWrite)]
  40. public DamageSpecifier Damage = new();
  41. /// <summary>
  42. /// If the projectile should be deleted on collision.
  43. /// </summary>
  44. [DataField]
  45. public bool DeleteOnCollide = true;
  46. /// <summary>
  47. /// Ignore all damage resistances the target has.
  48. /// </summary>
  49. [DataField]
  50. public bool IgnoreResistances = false;
  51. /// <summary>
  52. /// Get that juicy FPS hit sound.
  53. /// </summary>
  54. [DataField]
  55. public SoundSpecifier? SoundHit;
  56. /// <summary>
  57. /// Force the projectiles sound to play rather than potentially playing the entity's sound.
  58. /// </summary>
  59. [DataField]
  60. public bool ForceSound = false;
  61. /// <summary>
  62. /// Whether this projectile will only collide with entities if it was shot from a gun (if <see cref="Weapon"/> is not null).
  63. /// </summary>
  64. [DataField]
  65. public bool OnlyCollideWhenShot = false;
  66. /// <summary>
  67. /// If true, the projectile has hit enough targets and should no longer interact with further collisions pending deletion.
  68. /// </summary>
  69. [DataField, AutoNetworkedField]
  70. public bool ProjectileSpent;
  71. /// <summary>
  72. /// When a projectile has this threshold set, it will continue to penetrate entities until the damage dealt reaches this threshold.
  73. /// </summary>
  74. [DataField]
  75. public FixedPoint2 PenetrationThreshold = FixedPoint2.Zero;
  76. /// <summary>
  77. /// If set, the projectile will not penetrate objects that lack the ability to take these damage types.
  78. /// </summary>
  79. [DataField]
  80. public List<string>? PenetrationDamageTypeRequirement;
  81. /// <summary>
  82. /// Tracks the amount of damage dealt for penetration purposes.
  83. /// </summary>
  84. [DataField]
  85. public FixedPoint2 PenetrationAmount = FixedPoint2.Zero;
  86. /// <summary>
  87. /// Sets the maximum range for a projectile fired with ShootAtFixedPointComponent.
  88. /// This can be set on both the Projectile and ShootAtFixedPoint Components.
  89. /// The default value is null for no cap. The minimum value between the two is used.
  90. /// </summary>
  91. [DataField, AutoNetworkedField]
  92. public float? MaxFixedRange;
  93. [DataField, AutoNetworkedField]
  94. public bool DamagedEntity;
  95. }