From 31263f859700232fa8c8d0c127b04a6c0255b9c1 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Sun, 24 May 2020 11:40:49 +0200 Subject: [PATCH] Fixes ghosts being affected by gravity. Fixes #980 --- .../GameObjects/EntitySystems/MoverSystem.cs | 4 +++- .../Movement/MovementIgnoreGravityComponent.cs | 10 ++++++++++ Content.Shared/Physics/MoverController.cs | 7 ++++--- Resources/Prototypes/Entities/Mobs/observer.yml | 2 ++ 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 Content.Shared/GameObjects/Components/Movement/MovementIgnoreGravityComponent.cs diff --git a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs index 11b7d51ae4..8a2d72eef3 100644 --- a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs @@ -5,6 +5,7 @@ using Content.Server.GameObjects.Components.Sound; using Content.Server.Interfaces.GameObjects.Components.Movement; using Content.Shared.Audio; using Content.Shared.GameObjects.Components.Inventory; +using Content.Shared.GameObjects.Components.Movement; using Content.Shared.Maps; using Content.Shared.Physics; using JetBrains.Annotations; @@ -151,7 +152,8 @@ namespace Content.Server.GameObjects.EntitySystems physics.SetController(); } - var weightless = _physicsManager.IsWeightless(transform.GridPosition); + var weightless = !transform.Owner.HasComponent() && + _physicsManager.IsWeightless(transform.GridPosition); if (weightless && collider != null) { diff --git a/Content.Shared/GameObjects/Components/Movement/MovementIgnoreGravityComponent.cs b/Content.Shared/GameObjects/Components/Movement/MovementIgnoreGravityComponent.cs new file mode 100644 index 0000000000..a603b58d84 --- /dev/null +++ b/Content.Shared/GameObjects/Components/Movement/MovementIgnoreGravityComponent.cs @@ -0,0 +1,10 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.GameObjects.Components.Movement +{ + [RegisterComponent] + public sealed class MovementIgnoreGravityComponent : Component + { + public override string Name => "MovementIgnoreGravity"; + } +} diff --git a/Content.Shared/Physics/MoverController.cs b/Content.Shared/Physics/MoverController.cs index 72159f632b..60284842bc 100644 --- a/Content.Shared/Physics/MoverController.cs +++ b/Content.Shared/Physics/MoverController.cs @@ -1,4 +1,4 @@ -using System; +using Content.Shared.GameObjects.Components.Movement; using Robust.Shared.Interfaces.Physics; using Robust.Shared.IoC; using Robust.Shared.Maths; @@ -6,7 +6,7 @@ using Robust.Shared.Physics; namespace Content.Shared.Physics { - public class MoverController: VirtualController + public class MoverController : VirtualController { private Vector2 _velocity; private SharedPhysicsComponent _component = null; @@ -29,7 +29,8 @@ namespace Content.Shared.Physics public void Move(Vector2 velocityDirection, float speed) { - if (IoCManager.Resolve().IsWeightless(_component.Owner.Transform.GridPosition)) return; + if (!_component.Owner.HasComponent() && IoCManager + .Resolve().IsWeightless(_component.Owner.Transform.GridPosition)) return; Push(velocityDirection, speed); } diff --git a/Resources/Prototypes/Entities/Mobs/observer.yml b/Resources/Prototypes/Entities/Mobs/observer.yml index bd663ed181..362ce3d704 100644 --- a/Resources/Prototypes/Entities/Mobs/observer.yml +++ b/Resources/Prototypes/Entities/Mobs/observer.yml @@ -26,3 +26,5 @@ - type: MovementSpeedModifier baseSprintSpeed: 14 baseWalkSpeed: 7 + + - type: MovementIgnoreGravity