diff --git a/Content.Server/GameObjects/Components/Body/Behavior/BrainBehavior.cs b/Content.Server/GameObjects/Components/Body/Behavior/BrainBehavior.cs index d5533a961d..5b740f75f1 100644 --- a/Content.Server/GameObjects/Components/Body/Behavior/BrainBehavior.cs +++ b/Content.Server/GameObjects/Components/Body/Behavior/BrainBehavior.cs @@ -1,7 +1,9 @@ #nullable enable using Content.Server.GameObjects.Components.Mobs; +using Content.Server.GameObjects.Components.Observer; using Content.Shared.GameObjects.Components.Body; using Content.Shared.GameObjects.Components.Body.Part; +using Content.Shared.GameObjects.Components.Movement; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; @@ -56,6 +58,13 @@ namespace Content.Server.GameObjects.Components.Body.Behavior newEntity.EnsureComponent(); var oldMind = oldEntity.EnsureComponent(); + if (!newEntity.HasComponent()) + newEntity.AddComponent(); + + // TODO: This is an awful solution. + if (!newEntity.HasComponent()) + newEntity.AddComponent(); + oldMind.Mind?.TransferTo(newEntity); } } diff --git a/Content.Server/GameObjects/Components/Body/BodyComponent.cs b/Content.Server/GameObjects/Components/Body/BodyComponent.cs index 8f9eea9aac..8adec50390 100644 --- a/Content.Server/GameObjects/Components/Body/BodyComponent.cs +++ b/Content.Server/GameObjects/Components/Body/BodyComponent.cs @@ -1,6 +1,7 @@ #nullable enable using System; using Content.Server.Commands.Observer; +using Content.Server.GameObjects.Components.Observer; using Content.Shared.Audio; using Content.Shared.GameObjects.Components.Body; using Content.Shared.GameObjects.Components.Body.Part; @@ -25,7 +26,8 @@ namespace Content.Server.GameObjects.Components.Body [RegisterComponent] [ComponentReference(typeof(SharedBodyComponent))] [ComponentReference(typeof(IBody))] - public class BodyComponent : SharedBodyComponent, IRelayMoveInput + [ComponentReference(typeof(IGhostOnMove))] + public class BodyComponent : SharedBodyComponent, IRelayMoveInput, IGhostOnMove { private Container _partContainer = default!; diff --git a/Content.Server/GameObjects/Components/Observer/GhostOnMoveComponent.cs b/Content.Server/GameObjects/Components/Observer/GhostOnMoveComponent.cs new file mode 100644 index 0000000000..3ba9cc3a16 --- /dev/null +++ b/Content.Server/GameObjects/Components/Observer/GhostOnMoveComponent.cs @@ -0,0 +1,41 @@ +#nullable enable +using System; +using Content.Server.Commands.Observer; +using Content.Server.GameObjects.Components.Mobs; +using Content.Server.GameObjects.Components.Movement; +using Content.Shared.GameObjects.Components.Movement; +using Robust.Server.Console; +using Robust.Shared.Console; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Players; +using Robust.Shared.Serialization; + +namespace Content.Server.GameObjects.Components.Observer +{ + [RegisterComponent] + [ComponentReference(typeof(IGhostOnMove))] + public class GhostOnMoveComponent : Component, IRelayMoveInput, IGhostOnMove + { + public override string Name => "GhostOnMove"; + + public bool CanReturn { get; set; } + + public override void ExposeData(ObjectSerializer serializer) + { + base.ExposeData(serializer); + + serializer.DataField(this, x => x.CanReturn, "canReturn", true); + } + + void IRelayMoveInput.MoveInputPressed(ICommonSession session) + { + // Let's not ghost if our mind is visiting... + if (Owner.HasComponent()) return; + if (!Owner.TryGetComponent(out MindComponent? mind) || !mind.HasMind || mind.Mind!.IsVisitingEntity) return; + + var host = IoCManager.Resolve(); + new Ghost().Execute(new ConsoleShell(host, session), string.Empty, Array.Empty()); + } + } +} diff --git a/Content.Server/GameObjects/Components/Observer/IGhostOnMove.cs b/Content.Server/GameObjects/Components/Observer/IGhostOnMove.cs new file mode 100644 index 0000000000..5ba726d2f1 --- /dev/null +++ b/Content.Server/GameObjects/Components/Observer/IGhostOnMove.cs @@ -0,0 +1,8 @@ +using Content.Shared.GameObjects.Components.Movement; + +namespace Content.Server.GameObjects.Components.Observer +{ + public interface IGhostOnMove + { + } +} diff --git a/Content.Shared/GameObjects/Components/Movement/SharedDummyInputMoverComponent.cs b/Content.Shared/GameObjects/Components/Movement/SharedDummyInputMoverComponent.cs new file mode 100644 index 0000000000..07a5804b4a --- /dev/null +++ b/Content.Shared/GameObjects/Components/Movement/SharedDummyInputMoverComponent.cs @@ -0,0 +1,29 @@ +using Robust.Shared.GameObjects; +using Robust.Shared.Map; +using Robust.Shared.Maths; + +namespace Content.Shared.GameObjects.Components.Movement +{ + [RegisterComponent] + [ComponentReference(typeof(IMoverComponent))] + public class SharedDummyInputMoverComponent : Component, IMoverComponent + { + public override string Name => "DummyInputMover"; + public float CurrentWalkSpeed => 0f; + public float CurrentSprintSpeed => 0f; + public float CurrentPushSpeed => 0f; + public float GrabRange => 0f; + public bool Sprinting => false; + public (Vector2 walking, Vector2 sprinting) VelocityDir => (Vector2.Zero, Vector2.Zero); + public EntityCoordinates LastPosition { get; set; } + public float StepSoundDistance { get; set; } + + public void SetVelocityDirection(Direction direction, ushort subTick, bool enabled) + { + } + + public void SetSprinting(ushort subTick, bool walking) + { + } + } +}