Break pulling on container insertion (#3602)
* Break pulling on container insertion * Paul's review Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -1,14 +1,16 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using Content.Shared.GameObjects.Components.Pulling;
|
using Content.Shared.GameObjects.Components.Pulling;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
using Content.Shared.Physics.Pull;
|
using Content.Shared.Physics.Pull;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Input.Binding;
|
using Robust.Shared.Input.Binding;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
|
using Robust.Shared.Physics.Dynamics.Joints;
|
||||||
using Robust.Shared.Players;
|
using Robust.Shared.Players;
|
||||||
|
|
||||||
namespace Content.Shared.GameObjects.EntitySystems
|
namespace Content.Shared.GameObjects.EntitySystems
|
||||||
@@ -29,6 +31,7 @@ namespace Content.Shared.GameObjects.EntitySystems
|
|||||||
SubscribeLocalEvent<PullStartedMessage>(OnPullStarted);
|
SubscribeLocalEvent<PullStartedMessage>(OnPullStarted);
|
||||||
SubscribeLocalEvent<PullStoppedMessage>(OnPullStopped);
|
SubscribeLocalEvent<PullStoppedMessage>(OnPullStopped);
|
||||||
SubscribeLocalEvent<MoveEvent>(PullerMoved);
|
SubscribeLocalEvent<MoveEvent>(PullerMoved);
|
||||||
|
SubscribeLocalEvent<EntInsertedIntoContainerMessage>(HandleContainerInsert);
|
||||||
|
|
||||||
CommandBinds.Builder
|
CommandBinds.Builder
|
||||||
.Bind(ContentKeyFunctions.MovePulledObject, new PointerInputCmdHandler(HandleMovePulledObject))
|
.Bind(ContentKeyFunctions.MovePulledObject, new PointerInputCmdHandler(HandleMovePulledObject))
|
||||||
@@ -67,6 +70,27 @@ namespace Content.Shared.GameObjects.EntitySystems
|
|||||||
physics.WakeBody();
|
physics.WakeBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: When Joint networking is less shitcodey fix this to use a dedicated joints message.
|
||||||
|
private void HandleContainerInsert(EntInsertedIntoContainerMessage message)
|
||||||
|
{
|
||||||
|
if (message.Entity.TryGetComponent(out SharedPullableComponent? pullable))
|
||||||
|
{
|
||||||
|
pullable.TryStopPull();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.Entity.TryGetComponent(out SharedPullerComponent? puller))
|
||||||
|
{
|
||||||
|
if (puller.Pulling == null) return;
|
||||||
|
|
||||||
|
if (!puller.Pulling.TryGetComponent(out SharedPullableComponent? pulling))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pulling.TryStopPull();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user