From b0c1c1bec7ec8b3aefdcb66b3134526a00e7d34f Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT Date: Fri, 3 Nov 2023 18:16:37 -0700 Subject: [PATCH 1/5] fffff --- .../Ranged/Systems/FireOnDropSystem.cs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Content.Server/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs 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. + } +} From d4c4d0ca20604aed18e7618e3e5293d464c1f9f5 Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT Date: Fri, 3 Nov 2023 18:30:25 -0700 Subject: [PATCH 2/5] add partial GunComponent with drop chance, make FireOnDropSystem shared, use drop chance per component instead of a hardcoded value --- .../Ranged/Systems/FireOnDropSystem.cs | 35 ------------------- .../Weapons/Ranged/Components/GunComponent.cs | 8 +++++ .../Ranged/Systems/FireOnDropSystem.cs | 29 +++++++++++++++ 3 files changed, 37 insertions(+), 35 deletions(-) delete mode 100644 Content.Server/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs create mode 100644 Content.Shared/SimpleStation14/Weapons/Ranged/Components/GunComponent.cs create mode 100644 Content.Shared/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs 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())); + } +} From d40913478e615aeb48a32c630b72ce6b94a3e305 Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT Date: Sun, 10 Dec 2023 16:07:02 -0800 Subject: [PATCH 3/5] 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())); - } -} From af3499f00b897d15f27a945804231368a3a2ae40 Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT Date: Sat, 16 Dec 2023 23:43:44 -0800 Subject: [PATCH 4/5] revert to commit "fffff" --- .../RandomFireGunOnDropComponent.cs | 8 ---- .../Ranged/Systems/FireOnDropSystem.cs | 35 +++++++++++++++++ .../Systems/RandomFireGunOnDropSystem.cs | 38 ------------------- 3 files changed, 35 insertions(+), 46 deletions(-) delete mode 100644 Content.Server/SimpleStation14/Weapons/Ranged/Components/RandomFireGunOnDropComponent.cs create mode 100644 Content.Server/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs delete mode 100644 Content.Server/SimpleStation14/Weapons/Ranged/Systems/RandomFireGunOnDropSystem.cs 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())); - } -} From 65836cb89b32e55189073acbed420d9b6f0a0228 Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT Date: Sun, 17 Dec 2023 00:33:45 -0800 Subject: [PATCH 5/5] :electron: --- .../Weapons/Ranged/Systems/FireOnDropSystem.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Content.Server/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs b/Content.Server/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs index fdd58b1e3f..49cdbe959f 100644 --- a/Content.Server/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs +++ b/Content.Server/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs @@ -22,11 +22,8 @@ public override void Initialize() 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: + // TODO: This shouldn't be a hardcoded 10% roll. I wanted to base it off mass, but most 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 ¯\_(ツ)_/¯ 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.