From d40913478e615aeb48a32c630b72ce6b94a3e305 Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT Date: Sun, 10 Dec 2023 16:07:02 -0800 Subject: [PATCH] I'm going to find something better to do --- .../RandomFireGunOnDropComponent.cs | 8 ++++ .../Systems/RandomFireGunOnDropSystem.cs | 38 +++++++++++++++++++ .../Weapons/Ranged/Components/GunComponent.cs | 8 ---- .../Ranged/Systems/FireOnDropSystem.cs | 29 -------------- 4 files changed, 46 insertions(+), 37 deletions(-) create mode 100644 Content.Server/SimpleStation14/Weapons/Ranged/Components/RandomFireGunOnDropComponent.cs create mode 100644 Content.Server/SimpleStation14/Weapons/Ranged/Systems/RandomFireGunOnDropSystem.cs delete mode 100644 Content.Shared/SimpleStation14/Weapons/Ranged/Components/GunComponent.cs delete mode 100644 Content.Shared/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs diff --git a/Content.Server/SimpleStation14/Weapons/Ranged/Components/RandomFireGunOnDropComponent.cs b/Content.Server/SimpleStation14/Weapons/Ranged/Components/RandomFireGunOnDropComponent.cs new file mode 100644 index 0000000000..0866e27b42 --- /dev/null +++ b/Content.Server/SimpleStation14/Weapons/Ranged/Components/RandomFireGunOnDropComponent.cs @@ -0,0 +1,8 @@ +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/RandomFireGunOnDropSystem.cs b/Content.Server/SimpleStation14/Weapons/Ranged/Systems/RandomFireGunOnDropSystem.cs new file mode 100644 index 0000000000..fcac63d25c --- /dev/null +++ b/Content.Server/SimpleStation14/Weapons/Ranged/Systems/RandomFireGunOnDropSystem.cs @@ -0,0 +1,38 @@ +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())); + } +} diff --git a/Content.Shared/SimpleStation14/Weapons/Ranged/Components/GunComponent.cs b/Content.Shared/SimpleStation14/Weapons/Ranged/Components/GunComponent.cs deleted file mode 100644 index be124cb0c4..0000000000 --- a/Content.Shared/SimpleStation14/Weapons/Ranged/Components/GunComponent.cs +++ /dev/null @@ -1,8 +0,0 @@ -// 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 deleted file mode 100644 index ac1b91fd73..0000000000 --- a/Content.Shared/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs +++ /dev/null @@ -1,29 +0,0 @@ -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())); - } -}