From 028ca7a7320c38921bbf541f091b1ccfcb277936 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Sat, 18 Apr 2020 12:10:50 +0200 Subject: [PATCH] Remove hardcoded ghosting from MoverSystem. --- .../Components/Mobs/SpeciesComponent.cs | 13 ++++++++++++- .../GameObjects/EntitySystems/MoverSystem.cs | 14 ++++++++++---- .../Components/Movement/IRelayMoveInput.cs | 9 +++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 Content.Server/Interfaces/GameObjects/Components/Movement/IRelayMoveInput.cs diff --git a/Content.Server/GameObjects/Components/Mobs/SpeciesComponent.cs b/Content.Server/GameObjects/Components/Mobs/SpeciesComponent.cs index f3952cb92d..d3db6ac632 100644 --- a/Content.Server/GameObjects/Components/Mobs/SpeciesComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/SpeciesComponent.cs @@ -3,9 +3,12 @@ using System.Collections.Generic; using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.EntitySystems; using Content.Server.Interfaces; +using Content.Server.Interfaces.GameObjects.Components.Movement; +using Content.Server.Observer; using Content.Shared.GameObjects; using Content.Shared.GameObjects.Components.Mobs; using Robust.Server.GameObjects; +using Robust.Server.Interfaces.Player; using Robust.Shared.ContentPack; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; @@ -15,7 +18,7 @@ using Robust.Shared.Serialization; namespace Content.Server.GameObjects { [RegisterComponent] - public class SpeciesComponent : SharedSpeciesComponent, IActionBlocker, IOnDamageBehavior, IExAct + public class SpeciesComponent : SharedSpeciesComponent, IActionBlocker, IOnDamageBehavior, IExAct, IRelayMoveInput { /// /// Damagestates are reached by reaching a certain damage threshold, they will block actions after being reached @@ -198,6 +201,14 @@ namespace Content.Server.GameObjects Owner.GetComponent().TakeDamage(DamageType.Brute, bruteDamage, null); Owner.GetComponent().TakeDamage(DamageType.Heat, burnDamage, null); } + + void IRelayMoveInput.MoveInputPressed(IPlayerSession session) + { + if (CurrentDamageState is DeadState) + { + new Ghost().Execute(null, session, null); + } + } } /// diff --git a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs index 4b2038d855..82a38ca8ca 100644 --- a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs @@ -186,13 +186,19 @@ namespace Content.Server.GameObjects.EntitySystems private static void HandleDirChange(ICommonSession session, Direction dir, bool state) { - if (!TryGetAttachedComponent(session as IPlayerSession, out IMoverComponent moverComp)) + var playerSes = session as IPlayerSession; + if (!TryGetAttachedComponent(playerSes, out IMoverComponent moverComp)) return; - var owner = (session as IPlayerSession)?.AttachedEntity; + var owner = playerSes?.AttachedEntity; - if (owner != null && owner.TryGetComponent(out SpeciesComponent species) && species.CurrentDamageState is DeadState) - new Ghost().Execute(null, (IPlayerSession)session, null); + if (owner != null) + { + foreach (var comp in owner.GetAllComponents()) + { + comp.MoveInputPressed(playerSes); + } + } moverComp.SetVelocityDirection(dir, state); } diff --git a/Content.Server/Interfaces/GameObjects/Components/Movement/IRelayMoveInput.cs b/Content.Server/Interfaces/GameObjects/Components/Movement/IRelayMoveInput.cs new file mode 100644 index 0000000000..53df4ed7e1 --- /dev/null +++ b/Content.Server/Interfaces/GameObjects/Components/Movement/IRelayMoveInput.cs @@ -0,0 +1,9 @@ +using Robust.Server.Interfaces.Player; + +namespace Content.Server.Interfaces.GameObjects.Components.Movement +{ + public interface IRelayMoveInput + { + void MoveInputPressed(IPlayerSession session); + } +}