diff --git a/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs b/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs index 94e7b0d8a4..7e956d89de 100644 --- a/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs +++ b/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs @@ -287,9 +287,6 @@ namespace Content.Server.GameObjects.Components.Buckle SendMessage(new BuckleMessage(Owner, to)); - Owner.EntityManager.EventBus.SubscribeEvent(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(EventSource.Local, this); - return true; } @@ -407,7 +402,7 @@ namespace Content.Server.GameObjects.Components.Buckle /// too far from its strap. /// /// The move event of a buckled entity. - private void MoveEvent(MoveEvent moveEvent) + public void OnMoveEvent(MoveEvent moveEvent) { if (moveEvent.Sender != Owner) { diff --git a/Content.Server/GameObjects/EntitySystems/BuckleSystem.cs b/Content.Server/GameObjects/EntitySystems/BuckleSystem.cs index 9fbb049322..e957fbd6c7 100644 --- a/Content.Server/GameObjects/EntitySystems/BuckleSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/BuckleSystem.cs @@ -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(EventSource.Local, this, MoveEvent); + } + + public override void Shutdown() + { + base.Shutdown(); + + EntityManager.EventBus.UnsubscribeEvent(EventSource.Local, this); + } + + private void MoveEvent(MoveEvent ev) + { + if (ev.Sender.TryGetComponent(out BuckleComponent buckle)) + { + buckle.OnMoveEvent(ev); + } } public override void Update(float frameTime)