Fix every BuckleComponent subscribing to EventBus when buckled (#2504)
This commit is contained in:
committed by
GitHub
parent
60dd0de96f
commit
6a469508ca
@@ -287,9 +287,6 @@ namespace Content.Server.GameObjects.Components.Buckle
|
||||
|
||||
SendMessage(new BuckleMessage(Owner, to));
|
||||
|
||||
Owner.EntityManager.EventBus.SubscribeEvent<MoveEvent>(EventSource.Local, this, MoveEvent);
|
||||
|
||||
|
||||
if (Owner.TryGetComponent(out PullableComponent? pullableComponent))
|
||||
{
|
||||
if (pullableComponent.Puller != null)
|
||||
@@ -373,8 +370,6 @@ namespace Content.Server.GameObjects.Components.Buckle
|
||||
|
||||
SendMessage(new UnbuckleMessage(Owner, oldBuckledTo.Owner));
|
||||
|
||||
Owner.EntityManager.EventBus.UnsubscribeEvent<MoveEvent>(EventSource.Local, this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -407,7 +402,7 @@ namespace Content.Server.GameObjects.Components.Buckle
|
||||
/// too far from its strap.
|
||||
/// </summary>
|
||||
/// <param name="moveEvent">The move event of a buckled entity.</param>
|
||||
private void MoveEvent(MoveEvent moveEvent)
|
||||
public void OnMoveEvent(MoveEvent moveEvent)
|
||||
{
|
||||
if (moveEvent.Sender != Owner)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
using Content.Server.GameObjects.EntitySystems.Click;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems
|
||||
@@ -15,6 +17,22 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
|
||||
UpdatesAfter.Add(typeof(InteractionSystem));
|
||||
UpdatesAfter.Add(typeof(InputSystem));
|
||||
EntityManager.EventBus.SubscribeEvent<MoveEvent>(EventSource.Local, this, MoveEvent);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
|
||||
EntityManager.EventBus.UnsubscribeEvent<MoveEvent>(EventSource.Local, this);
|
||||
}
|
||||
|
||||
private void MoveEvent(MoveEvent ev)
|
||||
{
|
||||
if (ev.Sender.TryGetComponent(out BuckleComponent buckle))
|
||||
{
|
||||
buckle.OnMoveEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
|
||||
Reference in New Issue
Block a user