diff --git a/Content.Server/SimpleStation14/Weapons/Ranged/Components/RandomFireGunOnDropComponent.cs b/Content.Server/SimpleStation14/Weapons/Ranged/Components/RandomFireGunOnDropComponent.cs deleted file mode 100644 index 0866e27b42..0000000000 --- a/Content.Server/SimpleStation14/Weapons/Ranged/Components/RandomFireGunOnDropComponent.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Content.Server.SimpleStation14.Weapons.Ranged.Components; - -[RegisterComponent] -public sealed partial class RandomFireGunOnDropComponent : Component -{ - [DataField, ViewVariables(VVAccess.ReadWrite)] - public float FireOnDropChance = 0.1f; -} diff --git a/Content.Server/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs b/Content.Server/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs new file mode 100644 index 0000000000..fdd58b1e3f --- /dev/null +++ b/Content.Server/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs @@ -0,0 +1,35 @@ +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.Server/SimpleStation14/Weapons/Ranged/Systems/RandomFireGunOnDropSystem.cs b/Content.Server/SimpleStation14/Weapons/Ranged/Systems/RandomFireGunOnDropSystem.cs deleted file mode 100644 index fcac63d25c..0000000000 --- a/Content.Server/SimpleStation14/Weapons/Ranged/Systems/RandomFireGunOnDropSystem.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Content.Server.SimpleStation14.Weapons.Ranged.Components; -using Content.Shared.Throwing; -using Content.Shared.Weapons.Ranged.Components; -using Content.Shared.Weapons.Ranged.Systems; -using Robust.Shared.Random; -using Serilog; - -namespace Content.Server.SimpleStation14.Weapons.Ranged.Systems; - -public sealed class RandomFireGunOnDropSystem : EntitySystem -{ - [Dependency] private readonly SharedGunSystem _gun = default!; - [Dependency] private readonly IRobustRandom _random = default!; - [Dependency] private readonly IEntityManager _entity = default!; - - - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(HandleLand); - } - - - private void HandleLand(EntityUid uid, RandomFireGunOnDropComponent component, ref LandEvent args) - { - Log.Warning($"{args.User} firing {uid}"); - - if (!_entity.TryGetComponent(uid, out var gun) || - args.User == null) - return; - - 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, gun, Transform(uid).Coordinates.Offset(Transform(uid).LocalRotation.ToVec())); - } -}