Shotgun spread refactor (#27773)

* Moves spread data to new component

* Refactors shotgun spread code

* Makes shotgun cartridges and projectiles use new component

* Attempts to fix nullable build error

* Fixes hitscan weapons that I broke :(

* Saviour commit?

---------

Co-authored-by: EmoGarbage404 <retron404@gmail.com>
This commit is contained in:
RiceMar1244
2024-08-03 09:26:32 -04:00
committed by GitHub
parent 64273cb914
commit b432dc6125
6 changed files with 144 additions and 61 deletions

View File

@@ -0,0 +1,32 @@
using Content.Shared.Weapons.Ranged.Systems;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
namespace Content.Shared.Projectiles;
/// <summary>
/// Spawns a spread of the projectiles when fired
/// </summary>
[RegisterComponent, NetworkedComponent, Access(typeof(SharedGunSystem))]
public sealed partial class ProjectileSpreadComponent : Component
{
/// <summary>
/// The entity prototype that will be fired by the rest of the spread.
/// Will generally be the same entity prototype as the first projectile being fired.
/// Needed for ammo components that do not specify a fired prototype, unlike cartridges.
/// </summary>
[DataField(required: true)]
public EntProtoId Proto;
/// <summary>
/// How much the ammo spreads when shot, in degrees. Does nothing if count is 0.
/// </summary>
[DataField]
public Angle Spread = Angle.FromDegrees(5);
/// <summary>
/// How many prototypes are spawned when shot.
/// </summary>
[DataField]
public int Count = 1;
}