Ghosts now make use of the new "entity visibility" engine functionality
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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<VisibilityComponent>().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:
|
||||
|
||||
12
Content.Server/GameObjects/VisibilityFlags.cs
Normal file
12
Content.Server/GameObjects/VisibilityFlags.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace Content.Server.GameObjects
|
||||
{
|
||||
[Flags]
|
||||
public enum VisibilityFlags
|
||||
{
|
||||
None = 0,
|
||||
Normal = 1,
|
||||
Ghost = 2,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user