From 70867d88cc36bc6eeb0b1c7f7da16d5ec40c687a Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Mon, 26 Oct 2020 12:11:46 +0100 Subject: [PATCH] Today I join Zumorica in leaving behind our crimes against humanity (#2396) --- .../Pulling/SharedPullableComponent.cs | 24 ------------------- .../EntitySystems/SharedPullingSystem.cs | 21 ++++++++++++++++ 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/Content.Shared/GameObjects/Components/Pulling/SharedPullableComponent.cs b/Content.Shared/GameObjects/Components/Pulling/SharedPullableComponent.cs index 4ca9bd022a..81eff1c395 100644 --- a/Content.Shared/GameObjects/Components/Pulling/SharedPullableComponent.cs +++ b/Content.Shared/GameObjects/Components/Pulling/SharedPullableComponent.cs @@ -146,26 +146,6 @@ namespace Content.Shared.GameObjects.Components.Pulling return controller.TryMoveTo(Puller.Transform.Coordinates, to); } - private void PullerMoved(MoveEvent moveEvent) - { - if (Puller == null) - { - return; - } - - if (moveEvent.Sender != Puller) - { - return; - } - - if (!Owner.TryGetComponent(out IPhysicsComponent? physics)) - { - return; - } - - physics.WakeBody(); - } - public override ComponentState GetComponentState() { return new PullableComponentState(Puller?.Uid); @@ -202,13 +182,9 @@ namespace Content.Shared.GameObjects.Components.Pulling switch (message) { case PullStartedMessage msg: - Owner.EntityManager.EventBus.SubscribeEvent(EventSource.Local, this, PullerMoved); - AddPullingStatuses(msg.Puller.Owner); break; case PullStoppedMessage msg: - Owner.EntityManager.EventBus.UnsubscribeEvent(EventSource.Local, this); - RemovePullingStatuses(msg.Puller.Owner); break; } diff --git a/Content.Shared/GameObjects/EntitySystems/SharedPullingSystem.cs b/Content.Shared/GameObjects/EntitySystems/SharedPullingSystem.cs index 72b4bb3d3e..2eaf43921a 100644 --- a/Content.Shared/GameObjects/EntitySystems/SharedPullingSystem.cs +++ b/Content.Shared/GameObjects/EntitySystems/SharedPullingSystem.cs @@ -6,6 +6,8 @@ using Content.Shared.Input; using Content.Shared.Physics.Pull; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components; +using Robust.Shared.GameObjects.Components.Transform; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Input.Binding; using Robust.Shared.Interfaces.GameObjects; @@ -17,6 +19,9 @@ namespace Content.Shared.GameObjects.EntitySystems [UsedImplicitly] public class SharedPullingSystem : EntitySystem { + /// + /// A mapping of pullers to the entity that they are pulling. + /// private readonly Dictionary _pullers = new Dictionary(); @@ -26,6 +31,7 @@ namespace Content.Shared.GameObjects.EntitySystems SubscribeLocalEvent(OnPullStarted); SubscribeLocalEvent(OnPullStopped); + SubscribeLocalEvent(PullerMoved); CommandBinds.Builder .Bind(ContentKeyFunctions.MovePulledObject, new PointerInputCmdHandler(HandleMovePulledObject)) @@ -43,6 +49,21 @@ namespace Content.Shared.GameObjects.EntitySystems RemovePuller(message.Puller.Owner); } + private void PullerMoved(MoveEvent ev) + { + if (!TryGetPulled(ev.Sender, out var pulled)) + { + return; + } + + if (!pulled.TryGetComponent(out IPhysicsComponent? physics)) + { + return; + } + + physics.WakeBody(); + } + private bool HandleMovePulledObject(ICommonSession? session, EntityCoordinates coords, EntityUid uid) { var player = session?.AttachedEntity;