diff --git a/Content.Server/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs b/Content.Server/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs deleted file mode 100644 index fdd58b1e3f..0000000000 --- a/Content.Server/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Content.Shared.Throwing; -using Content.Shared.Weapons.Ranged.Components; -using Content.Shared.Weapons.Ranged.Systems; -using Robust.Shared.Physics.Components; -using Robust.Shared.Random; - -namespace Content.Server.SimpleStation14.Weapons.Ranged.Systems; - -public sealed class FireOnDropSystem : EntitySystem -{ - [Dependency] private readonly SharedGunSystem _gun = default!; - [Dependency] private readonly IRobustRandom _random = default!; - - - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(HandleLand); - } - - - private void HandleLand(EntityUid uid, GunComponent component, ref LandEvent args) - { - var physicsComp = EntityManager.GetComponent(uid); - - // TODO: This shouldn't be a hardcoded 10% roll. I wanted to base it off mass, but items don't seem - // to care about their mass (most guns had the same). - // Then I wanted to base it off of item size, but the minigun still has a size of 5 at the time of writing, so :shrug: - if (_random.Prob(0.1f)) - _gun.AttemptShoot(uid, uid, component, Transform(uid).Coordinates.Offset(Transform(uid).LocalRotation.ToVec())); - // The gun fires itself (weird), with the target being its own position offset by its rotation as a point vector. - // The result being that it will always fire the direction that all gun sprites point in. - } -} diff --git a/Content.Shared/SimpleStation14/Weapons/Ranged/Components/GunComponent.cs b/Content.Shared/SimpleStation14/Weapons/Ranged/Components/GunComponent.cs new file mode 100644 index 0000000000..be124cb0c4 --- /dev/null +++ b/Content.Shared/SimpleStation14/Weapons/Ranged/Components/GunComponent.cs @@ -0,0 +1,8 @@ +// ReSharper disable once CheckNamespace // Extending the GunComponent to add a variable +namespace Content.Shared.Weapons.Ranged.Components; + +public partial class GunComponent +{ + [DataField, ViewVariables(VVAccess.ReadWrite)] + public float FireOnDropChance = 0.1f; +} diff --git a/Content.Shared/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs b/Content.Shared/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs new file mode 100644 index 0000000000..ac1b91fd73 --- /dev/null +++ b/Content.Shared/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs @@ -0,0 +1,29 @@ +using Content.Shared.Throwing; +using Content.Shared.Weapons.Ranged.Components; +using Content.Shared.Weapons.Ranged.Systems; +using Robust.Shared.Random; + +namespace Content.Shared.SimpleStation14.Weapons.Ranged.Systems; + +public sealed class FireOnDropSystem : EntitySystem +{ + [Dependency] private readonly SharedGunSystem _gun = default!; + [Dependency] private readonly IRobustRandom _random = default!; + + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(HandleLand); + } + + + private void HandleLand(EntityUid uid, GunComponent component, ref LandEvent args) + { + if (_random.Prob(component.FireOnDropChance)) + // The gun fires itself (weird), with the target being its own position offset by its rotation as a point vector. + // The result being that it will always fire the direction that all gun sprites point in. + _gun.AttemptShoot(uid, uid, component, Transform(uid).Coordinates.Offset(Transform(uid).LocalRotation.ToVec())); + } +}