diff --git a/Content.Server/Administration/Commands/AGhost.cs b/Content.Server/Administration/Commands/AGhost.cs index aff615a193..db64864eb4 100644 --- a/Content.Server/Administration/Commands/AGhost.cs +++ b/Content.Server/Administration/Commands/AGhost.cs @@ -2,6 +2,7 @@ using Content.Server.Ghost.Components; using Content.Server.Players; using Content.Shared.Administration; +using Content.Shared.Ghost; using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.GameObjects; @@ -55,7 +56,8 @@ namespace Content.Server.Administration.Commands mind.TransferTo(ghost); } - ghost.GetComponent().CanReturnToBody = canReturn; + var comp = ghost.GetComponent(); + EntitySystem.Get().SetCanReturnToBody(comp, canReturn); } } } diff --git a/Content.Server/GameTicking/GameTicker.Spawning.cs b/Content.Server/GameTicking/GameTicker.Spawning.cs index cab3c3c1d1..4d24d6249a 100644 --- a/Content.Server/GameTicking/GameTicker.Spawning.cs +++ b/Content.Server/GameTicking/GameTicker.Spawning.cs @@ -13,6 +13,7 @@ using Content.Server.Roles; using Content.Server.Spawners.Components; using Content.Server.Speech.Components; using Content.Shared.GameTicking; +using Content.Shared.Ghost; using Content.Shared.Inventory; using Content.Shared.Preferences; using Content.Shared.Roles; @@ -144,7 +145,8 @@ namespace Content.Server.GameTicking var mob = SpawnObserverMob(); mob.Name = name; - mob.GetComponent().CanReturnToBody = false; + var ghost = mob.GetComponent(); + EntitySystem.Get().SetCanReturnToBody(ghost, false); data.Mind.TransferTo(mob); _playersInLobby[player] = LobbyPlayerStatus.Observer; diff --git a/Content.Server/GameTicking/Presets/GamePreset.cs b/Content.Server/GameTicking/Presets/GamePreset.cs index e76d442ba5..922ce47c02 100644 --- a/Content.Server/GameTicking/Presets/GamePreset.cs +++ b/Content.Server/GameTicking/Presets/GamePreset.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using Content.Server.Ghost.Components; using Content.Shared.Damage; using Content.Shared.Damage.Components; +using Content.Shared.Ghost; using Content.Shared.MobState; using Content.Shared.Preferences; using Robust.Server.Player; @@ -75,7 +76,7 @@ namespace Content.Server.GameTicking.Presets ghost.Name = mind.CharacterName ?? string.Empty; var ghostComponent = ghost.GetComponent(); - ghostComponent.CanReturnToBody = canReturn; + EntitySystem.Get().SetCanReturnToBody(ghostComponent, canReturn); if (canReturn) mind.Visit(ghost); diff --git a/Content.Server/Mind/Components/MindComponent.cs b/Content.Server/Mind/Components/MindComponent.cs index b724e8a10c..987e04db63 100644 --- a/Content.Server/Mind/Components/MindComponent.cs +++ b/Content.Server/Mind/Components/MindComponent.cs @@ -1,6 +1,7 @@ using Content.Server.GameTicking; using Content.Server.Ghost.Components; using Content.Shared.Examine; +using Content.Shared.Ghost; using Content.Shared.MobState; using Robust.Shared.GameObjects; using Robust.Shared.IoC; @@ -86,7 +87,7 @@ namespace Content.Server.Mind.Components { if (visiting.TryGetComponent(out GhostComponent? ghost)) { - ghost.CanReturnToBody = false; + EntitySystem.Get().SetCanReturnToBody(ghost, false); } Mind!.TransferTo(visiting); @@ -108,7 +109,7 @@ namespace Content.Server.Mind.Components var ghost = Owner.EntityManager.SpawnEntity("MobObserver", spawnPosition); var ghostComponent = ghost.GetComponent(); - ghostComponent.CanReturnToBody = false; + EntitySystem.Get().SetCanReturnToBody(ghostComponent, false); if (Mind != null) { diff --git a/Content.Shared/Ghost/SharedGhostComponent.cs b/Content.Shared/Ghost/SharedGhostComponent.cs index 77806356ac..e335225911 100644 --- a/Content.Shared/Ghost/SharedGhostComponent.cs +++ b/Content.Shared/Ghost/SharedGhostComponent.cs @@ -16,8 +16,9 @@ namespace Content.Shared.Ghost public override string Name => "Ghost"; /// - /// Changed by + /// Changed by /// + // TODO MIRROR change this to use friend classes when thats merged [DataField("canReturnToBody")] [ViewVariables(VVAccess.ReadWrite)] public bool CanReturnToBody { get; set; } diff --git a/Content.Shared/Ghost/SharedGhostSystem.cs b/Content.Shared/Ghost/SharedGhostSystem.cs index 0099d34f37..7b54432150 100644 --- a/Content.Shared/Ghost/SharedGhostSystem.cs +++ b/Content.Shared/Ghost/SharedGhostSystem.cs @@ -10,36 +10,20 @@ namespace Content.Shared.Ghost public override void Initialize() { base.Initialize(); - - SubscribeLocalEvent(OnGhostChangeCanReturnToBody); } - private void OnGhostChangeCanReturnToBody(EntityUid uid, SharedGhostComponent component, GhostChangeCanReturnToBodyEvent args) + public void SetCanReturnToBody(SharedGhostComponent component, bool canReturn) { - if (component.CanReturnToBody == args.CanReturnToBody) + if (component.CanReturnToBody == canReturn) { return; } - component.CanReturnToBody = args.CanReturnToBody; + component.CanReturnToBody = canReturn; component.Dirty(); } } - /// - /// Raised to change the value of - /// - [Serializable, NetSerializable] - public class GhostChangeCanReturnToBodyEvent : EntityEventArgs - { - public GhostChangeCanReturnToBodyEvent(bool canReturnToBody) - { - CanReturnToBody = canReturnToBody; - } - - public bool CanReturnToBody { get; } - } - [Serializable, NetSerializable] public class GhostWarpsRequestEvent : EntityEventArgs {