Today I join Zumorica in leaving behind our crimes against humanity (#2396)

This commit is contained in:
DrSmugleaf
2020-10-26 12:11:46 +01:00
committed by GitHub
parent ebe8a82033
commit 70867d88cc
2 changed files with 21 additions and 24 deletions

View File

@@ -146,26 +146,6 @@ namespace Content.Shared.GameObjects.Components.Pulling
return controller.TryMoveTo(Puller.Transform.Coordinates, to); 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() public override ComponentState GetComponentState()
{ {
return new PullableComponentState(Puller?.Uid); return new PullableComponentState(Puller?.Uid);
@@ -202,13 +182,9 @@ namespace Content.Shared.GameObjects.Components.Pulling
switch (message) switch (message)
{ {
case PullStartedMessage msg: case PullStartedMessage msg:
Owner.EntityManager.EventBus.SubscribeEvent<MoveEvent>(EventSource.Local, this, PullerMoved);
AddPullingStatuses(msg.Puller.Owner); AddPullingStatuses(msg.Puller.Owner);
break; break;
case PullStoppedMessage msg: case PullStoppedMessage msg:
Owner.EntityManager.EventBus.UnsubscribeEvent<MoveEvent>(EventSource.Local, this);
RemovePullingStatuses(msg.Puller.Owner); RemovePullingStatuses(msg.Puller.Owner);
break; break;
} }

View File

@@ -6,6 +6,8 @@ using Content.Shared.Input;
using Content.Shared.Physics.Pull; using Content.Shared.Physics.Pull;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.GameObjects.Components.Transform;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Input.Binding; using Robust.Shared.Input.Binding;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
@@ -17,6 +19,9 @@ namespace Content.Shared.GameObjects.EntitySystems
[UsedImplicitly] [UsedImplicitly]
public class SharedPullingSystem : EntitySystem public class SharedPullingSystem : EntitySystem
{ {
/// <summary>
/// A mapping of pullers to the entity that they are pulling.
/// </summary>
private readonly Dictionary<IEntity, IEntity> _pullers = private readonly Dictionary<IEntity, IEntity> _pullers =
new Dictionary<IEntity, IEntity>(); new Dictionary<IEntity, IEntity>();
@@ -26,6 +31,7 @@ namespace Content.Shared.GameObjects.EntitySystems
SubscribeLocalEvent<PullStartedMessage>(OnPullStarted); SubscribeLocalEvent<PullStartedMessage>(OnPullStarted);
SubscribeLocalEvent<PullStoppedMessage>(OnPullStopped); SubscribeLocalEvent<PullStoppedMessage>(OnPullStopped);
SubscribeLocalEvent<MoveEvent>(PullerMoved);
CommandBinds.Builder CommandBinds.Builder
.Bind(ContentKeyFunctions.MovePulledObject, new PointerInputCmdHandler(HandleMovePulledObject)) .Bind(ContentKeyFunctions.MovePulledObject, new PointerInputCmdHandler(HandleMovePulledObject))
@@ -43,6 +49,21 @@ namespace Content.Shared.GameObjects.EntitySystems
RemovePuller(message.Puller.Owner); 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) private bool HandleMovePulledObject(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
{ {
var player = session?.AttachedEntity; var player = session?.AttachedEntity;