Reset movement on player (de)attach (#12073)
This commit is contained in:
@@ -5,6 +5,7 @@ using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Content.Shared.Shuttles.Systems;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Player;
|
||||
@@ -18,6 +19,37 @@ namespace Content.Server.Physics.Controllers
|
||||
|
||||
private Dictionary<ShuttleComponent, List<(PilotComponent, InputMoverComponent, TransformComponent)>> _shuttlePilots = new();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<RelayInputMoverComponent, PlayerAttachedEvent>(OnRelayPlayerAttached);
|
||||
SubscribeLocalEvent<RelayInputMoverComponent, PlayerDetachedEvent>(OnRelayPlayerDetached);
|
||||
SubscribeLocalEvent<InputMoverComponent, PlayerAttachedEvent>(OnPlayerAttached);
|
||||
SubscribeLocalEvent<InputMoverComponent, PlayerDetachedEvent>(OnPlayerDetached);
|
||||
}
|
||||
|
||||
private void OnRelayPlayerAttached(EntityUid uid, RelayInputMoverComponent component, PlayerAttachedEvent args)
|
||||
{
|
||||
if (TryComp<InputMoverComponent>(component.RelayEntity, out var inputMover))
|
||||
SetMoveInput(inputMover, MoveButtons.None);
|
||||
}
|
||||
|
||||
private void OnRelayPlayerDetached(EntityUid uid, RelayInputMoverComponent component, PlayerDetachedEvent args)
|
||||
{
|
||||
if (TryComp<InputMoverComponent>(component.RelayEntity, out var inputMover))
|
||||
SetMoveInput(inputMover, MoveButtons.None);
|
||||
}
|
||||
|
||||
private void OnPlayerAttached(EntityUid uid, InputMoverComponent component, PlayerAttachedEvent args)
|
||||
{
|
||||
SetMoveInput(component, MoveButtons.None);
|
||||
}
|
||||
|
||||
private void OnPlayerDetached(EntityUid uid, InputMoverComponent component, PlayerDetachedEvent args)
|
||||
{
|
||||
SetMoveInput(component, MoveButtons.None);
|
||||
}
|
||||
|
||||
protected override bool CanSound()
|
||||
{
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user