diff --git a/Content.Server/Projectiles/ProjectileSystem.cs b/Content.Server/Projectiles/ProjectileSystem.cs index eef12ea496..5c49ce68b5 100644 --- a/Content.Server/Projectiles/ProjectileSystem.cs +++ b/Content.Server/Projectiles/ProjectileSystem.cs @@ -1,7 +1,6 @@ using Content.Server.Administration.Logs; using Content.Server.Effects; using Content.Server.Hands.Systems; -using Content.Server.UserInterface; using Content.Server.Weapons.Ranged.Systems; using Content.Shared._White.Penetrated; using Content.Shared._White.Projectile; @@ -9,7 +8,6 @@ using Content.Shared.Damage; using Content.Shared.Database; using Content.Shared.DoAfter; -using Content.Shared.Interaction; using Content.Shared.Projectiles; using Content.Shared.Throwing; using Robust.Server.GameObjects; @@ -32,7 +30,6 @@ public sealed class ProjectileSystem : SharedProjectileSystem [Dependency] private readonly HandsSystem _hands = default!; [Dependency] private readonly PhysicsSystem _physics = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; - [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; [Dependency] private readonly PenetratedSystem _penetrated = default!; // WD EDIT END @@ -42,7 +39,6 @@ public override void Initialize() SubscribeLocalEvent(OnStartCollide); // WD EDIT START SubscribeLocalEvent(OnEmbed); - SubscribeLocalEvent(OnEmbedActivate, before: new[] {typeof(ActivatableUISystem)}); SubscribeLocalEvent(OnEmbedRemove); // WD EDIT END } @@ -109,15 +105,6 @@ private void OnEmbed(EntityUid uid, EmbeddableProjectileComponent component, ref _color.RaiseEffect(Color.Red, new List() { args.Embedded }, Filter.Pvs(args.Embedded, entityManager: EntityManager)); } - private void OnEmbedActivate(EntityUid uid, EmbeddableProjectileComponent component, ActivateInWorldEvent args) - { - if (args.Handled - || !AttemptEmbedRemove(uid, args.User, component)) - return; - - args.Handled = true; - } - private void OnEmbedRemove(EntityUid uid, EmbeddableProjectileComponent component, RemoveEmbeddedProjectileEvent args) { // Whacky prediction issues. @@ -160,23 +147,6 @@ private void OnEmbedRemove(EntityUid uid, EmbeddableProjectileComponent componen _hands.TryPickupAnyHand(args.User, uid); } - private bool AttemptEmbedRemove(EntityUid uid, EntityUid user, EmbeddableProjectileComponent? component = null) - { - if (!Resolve(uid, ref component, false) - || component.RemovalTime == null - || !TryComp(uid, out var physics) - || physics.BodyType != BodyType.Static) - return false; - - _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, component.RemovalTime.Value, - new RemoveEmbeddedProjectileEvent(), eventTarget: uid, target: uid) - { - DistanceThreshold = SharedInteractionSystem.InteractionRange, - }); - - return true; - } - private void FreePenetrated(EntityUid uid, PenetratedProjectileComponent? penetratedProjectile = null) { if (!Resolve(uid, ref penetratedProjectile) diff --git a/Content.Shared/Projectiles/SharedProjectileSystem.cs b/Content.Shared/Projectiles/SharedProjectileSystem.cs index ca920830eb..c5f024b424 100644 --- a/Content.Shared/Projectiles/SharedProjectileSystem.cs +++ b/Content.Shared/Projectiles/SharedProjectileSystem.cs @@ -7,6 +7,7 @@ using Content.Shared.Hands.EntitySystems; using Content.Shared.Interaction; using Content.Shared.Throwing; +using Content.Shared.UserInterface; using Robust.Shared.Audio.Systems; using Robust.Shared.Map; using Robust.Shared.Network; @@ -26,6 +27,7 @@ public abstract partial class SharedProjectileSystem : EntitySystem [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; + [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; // WD EDIT public override void Initialize() { @@ -35,6 +37,7 @@ public override void Initialize() SubscribeLocalEvent(OnEmbedProjectileHit); SubscribeLocalEvent(OnEmbedThrowDoHit); SubscribeLocalEvent(OnAttemptPacifiedThrow); + SubscribeLocalEvent(OnEmbedActivate, before: new[] {typeof(ActivatableUISystem)}); // WD EDI } private void OnEmbedThrowDoHit(EntityUid uid, EmbeddableProjectileComponent component, ThrowDoHitEvent args) @@ -121,6 +124,34 @@ private void OnAttemptPacifiedThrow(Entity ent, r { args.Cancel("pacified-cannot-throw-embed"); } + + // WD EDIT START + private void OnEmbedActivate(EntityUid uid, EmbeddableProjectileComponent component, ActivateInWorldEvent args) + { + if (args.Handled + || !AttemptEmbedRemove(uid, args.User, component)) + return; + + args.Handled = true; + } + + private bool AttemptEmbedRemove(EntityUid uid, EntityUid user, EmbeddableProjectileComponent? component = null) + { + if (!Resolve(uid, ref component, false) + || component.RemovalTime == null + || !TryComp(uid, out var physics) + || physics.BodyType != BodyType.Static) + return false; + + _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, component.RemovalTime.Value, + new RemoveEmbeddedProjectileEvent(), eventTarget: uid, target: uid) + { + DistanceThreshold = SharedInteractionSystem.InteractionRange, + }); + + return true; + } + // WD EDIT END } [Serializable, NetSerializable]