diff --git a/Content.Client/GameObjects/Components/Observer/GhostComponent.cs b/Content.Client/GameObjects/Components/Observer/GhostComponent.cs index 67b81a6345..21403b3a76 100644 --- a/Content.Client/GameObjects/Components/Observer/GhostComponent.cs +++ b/Content.Client/GameObjects/Components/Observer/GhostComponent.cs @@ -34,7 +34,6 @@ namespace Content.Client.GameObjects.Components.Observer private void SetGhostVisibility(bool visibility) { - // So, for now this is a client-side hack... Please, PLEASE someone make this work server-side. foreach (var ghost in _componentManager.GetAllComponents(typeof(GhostComponent))) { if (ghost.Owner.TryGetComponent(out SpriteComponent component)) diff --git a/Content.Server/GameObjects/Components/Observer/GhostComponent.cs b/Content.Server/GameObjects/Components/Observer/GhostComponent.cs index 4853900fed..6adc21ed33 100644 --- a/Content.Server/GameObjects/Components/Observer/GhostComponent.cs +++ b/Content.Server/GameObjects/Components/Observer/GhostComponent.cs @@ -2,6 +2,7 @@ using Content.Server.GameObjects.EntitySystems; using Content.Server.Players; using Content.Shared.GameObjects.Components.Observer; using Robust.Server.GameObjects; +using Robust.Server.GameObjects.Components; using Robust.Server.Interfaces.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; @@ -28,6 +29,13 @@ namespace Content.Server.GameObjects.Components.Observer } } + public override void Initialize() + { + base.Initialize(); + + Owner.EnsureComponent().Layer = (int)VisibilityFlags.Ghost; + } + public override ComponentState GetComponentState() => new GhostComponentState(CanReturnToBody); public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, @@ -44,10 +52,12 @@ namespace Content.Server.GameObjects.Components.Observer actor.playerSession.ContentData().Mind.UnVisit(); } break; - case PlayerAttachedMsg _: + case PlayerAttachedMsg msg: + msg.NewPlayer.VisibilityMask |= (int)VisibilityFlags.Ghost; Dirty(); break; - case PlayerDetachedMsg _: + case PlayerDetachedMsg msg: + msg.OldPlayer.VisibilityMask &= ~(int)VisibilityFlags.Ghost; Timer.Spawn(100, Owner.Delete); break; default: diff --git a/Content.Server/GameObjects/VisibilityFlags.cs b/Content.Server/GameObjects/VisibilityFlags.cs new file mode 100644 index 0000000000..d5e3ccb7fa --- /dev/null +++ b/Content.Server/GameObjects/VisibilityFlags.cs @@ -0,0 +1,12 @@ +using System; + +namespace Content.Server.GameObjects +{ + [Flags] + public enum VisibilityFlags + { + None = 0, + Normal = 1, + Ghost = 2, + } +}