From 73eb53da467138d27a464cc14bc3f61327bceb6c Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Fri, 3 Jul 2020 23:32:41 +0200 Subject: [PATCH] Fix a player's mob continuing to move after disconnecting (#1265) --- Content.Client/GameObjects/EntitySystems/MoverSystem.cs | 2 +- Content.Server/GameObjects/EntitySystems/MoverSystem.cs | 7 ++++++- Content.Server/GameTicking/GameTicker.cs | 2 ++ .../GameObjects/Components/Movement/IMoverComponent.cs | 2 +- .../GameObjects/EntitySystems/SharedMoverSystem.cs | 1 - 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Content.Client/GameObjects/EntitySystems/MoverSystem.cs b/Content.Client/GameObjects/EntitySystems/MoverSystem.cs index 0197ed1b97..37689e355c 100644 --- a/Content.Client/GameObjects/EntitySystems/MoverSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/MoverSystem.cs @@ -46,7 +46,7 @@ namespace Content.Client.GameObjects.EntitySystems protected override void SetController(PhysicsComponent physics) { - ((PhysicsComponent)physics).SetController(); + physics.SetController(); } } } diff --git a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs index e1cdd9348f..f33243f5be 100644 --- a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs @@ -79,7 +79,7 @@ namespace Content.Server.GameObjects.EntitySystems protected override void SetController(PhysicsComponent physics) { - ((PhysicsComponent) physics).SetController(); + physics.SetController(); } private static void PlayerAttached(PlayerAttachSystemMessage ev) @@ -96,6 +96,11 @@ namespace Content.Server.GameObjects.EntitySystems { ev.Entity.RemoveComponent(); } + + if (ev.Entity.TryGetComponent(out PhysicsComponent physics)) + { + (physics.Controller as MoverController)?.StopMoving(); + } } protected override void HandleFootsteps(IMoverComponent mover) diff --git a/Content.Server/GameTicking/GameTicker.cs b/Content.Server/GameTicking/GameTicker.cs index d5b4715572..4d89eb2351 100644 --- a/Content.Server/GameTicking/GameTicker.cs +++ b/Content.Server/GameTicking/GameTicker.cs @@ -22,6 +22,7 @@ using Content.Shared; using Content.Shared.Chat; using Content.Shared.GameObjects.Components.PDA; using Content.Shared.Jobs; +using Content.Shared.Physics; using Content.Shared.Preferences; using Prometheus; using Robust.Server.Interfaces; @@ -32,6 +33,7 @@ using Robust.Server.ServerStatus; using Robust.Shared.Configuration; using Robust.Shared.Enums; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.Configuration; using Robust.Shared.Interfaces.GameObjects; diff --git a/Content.Shared/GameObjects/Components/Movement/IMoverComponent.cs b/Content.Shared/GameObjects/Components/Movement/IMoverComponent.cs index 3074a970fd..975a2c6477 100644 --- a/Content.Shared/GameObjects/Components/Movement/IMoverComponent.cs +++ b/Content.Shared/GameObjects/Components/Movement/IMoverComponent.cs @@ -45,7 +45,7 @@ namespace Content.Shared.GameObjects.Components.Movement /// /// Toggles one of the four cardinal directions. Each of the four directions are - /// composed into a single direction vector, . Enabling + /// composed into a single direction vector, . Enabling /// opposite directions will cancel each other out, resulting in no direction. /// /// Direction to toggle. diff --git a/Content.Shared/GameObjects/EntitySystems/SharedMoverSystem.cs b/Content.Shared/GameObjects/EntitySystems/SharedMoverSystem.cs index 6df3b87d19..931648c5f1 100644 --- a/Content.Shared/GameObjects/EntitySystems/SharedMoverSystem.cs +++ b/Content.Shared/GameObjects/EntitySystems/SharedMoverSystem.cs @@ -54,7 +54,6 @@ namespace Content.Shared.GameObjects.EntitySystems base.Shutdown(); } - protected void UpdateKinematics(ITransformComponent transform, IMoverComponent mover, PhysicsComponent physics, CollidableComponent? collider = null) {