Ghost sprites and a bunch of fixes

This commit is contained in:
zumorica
2020-04-05 02:29:04 +02:00
parent 0902844457
commit a0d114c672
9 changed files with 57 additions and 16 deletions

View File

@@ -1,14 +1,14 @@
using Content.Client.UserInterface; using Content.Client.UserInterface;
using Content.Shared.Observer; using Content.Shared.GameObjects.Components.Observer;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Network; using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
namespace Content.Client.Observer namespace Content.Client.GameObjects.Components.Observer
{ {
[RegisterComponent] [RegisterComponent]
public class GhostComponent : SharedGhostComponent public class GhostComponent : SharedGhostComponent
@@ -25,6 +25,8 @@ namespace Content.Client.Observer
#pragma warning disable 649 #pragma warning disable 649
[Dependency] private readonly IGameHud _gameHud; [Dependency] private readonly IGameHud _gameHud;
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private IComponentManager _componentManager;
#pragma warning restore 649 #pragma warning restore 649
public override void OnRemove() public override void OnRemove()
@@ -34,6 +36,25 @@ namespace Content.Client.Observer
_gui?.Dispose(); _gui?.Dispose();
} }
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))
component.Visible = visibility;
}
}
public override void Initialize()
{
base.Initialize();
if (Owner.TryGetComponent(out SpriteComponent component))
component.Visible = _playerManager.LocalPlayer.ControlledEntity?.HasComponent<GhostComponent>() ?? false;
}
public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null,
IComponent component = null) IComponent component = null)
{ {
@@ -52,10 +73,13 @@ namespace Content.Client.Observer
} }
_gameHud.HandsContainer.AddChild(_gui); _gameHud.HandsContainer.AddChild(_gui);
SetGhostVisibility(true);
break; break;
case PlayerDetachedMsg _: case PlayerDetachedMsg _:
_gui.Parent?.RemoveChild(_gui); _gui.Parent?.RemoveChild(_gui);
SetGhostVisibility(false);
break; break;
} }
} }
@@ -69,7 +93,12 @@ namespace Content.Client.Observer
if (!(curState is GhostComponentState state)) return; if (!(curState is GhostComponentState state)) return;
_canReturnToBody = state.CanReturnToBody; _canReturnToBody = state.CanReturnToBody;
if (Owner == _playerManager.LocalPlayer.ControlledEntity)
{
_gui?.Update(); _gui?.Update();
} }
}
} }
} }

View File

@@ -1,5 +1,5 @@
using System.Data; using System.Data;
using Content.Client.Observer; using Content.Client.GameObjects.Components.Observer;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Shared.IoC; using Robust.Shared.IoC;

View File

@@ -1,4 +1,5 @@
using Content.Server.Players; using Content.Server.GameObjects.Components.Observer;
using Content.Server.Players;
using Robust.Server.Interfaces.Console; using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
@@ -30,10 +31,14 @@ namespace Content.Server.Administration
} }
else else
{ {
var canReturn = mind.CurrentEntity != null && !mind.CurrentEntity.HasComponent<GhostComponent>();
var entityManager = IoCManager.Resolve<IEntityManager>(); var entityManager = IoCManager.Resolve<IEntityManager>();
var ghost = entityManager.SpawnEntity("AdminObserver", player.AttachedEntity.Transform.GridPosition); var ghost = entityManager.SpawnEntity("AdminObserver", player.AttachedEntity.Transform.GridPosition);
if(canReturn)
mind.Visit(ghost); mind.Visit(ghost);
else
mind.TransferTo(ghost);
ghost.GetComponent<GhostComponent>().CanReturnToBody = canReturn;
} }
} }
} }

View File

@@ -1,4 +1,5 @@
using Content.Server.Interfaces.Chat; using Content.Server.GameObjects.Components.Observer;
using Content.Server.Interfaces.Chat;
using Content.Server.Observer; using Content.Server.Observer;
using Robust.Server.Interfaces.Console; using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;

View File

@@ -1,4 +1,5 @@
using System.Linq; using System.Linq;
using Content.Server.GameObjects.Components.Observer;
using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces; using Content.Server.Interfaces;
using Content.Server.Interfaces.Chat; using Content.Server.Interfaces.Chat;

View File

@@ -1,18 +1,16 @@
using System.Threading;
using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.EntitySystems;
using Content.Server.Players; using Content.Server.Players;
using Content.Shared.Observer; using Content.Shared.GameObjects.Components.Observer;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Interfaces.GameObjects; using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Network; using Robust.Shared.Interfaces.Network;
using Robust.Shared.Log;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
using Timer = Robust.Shared.Timers.Timer; using Timer = Robust.Shared.Timers.Timer;
namespace Content.Server.Observer namespace Content.Server.GameObjects.Components.Observer
{ {
[RegisterComponent] [RegisterComponent]
public class GhostComponent : SharedGhostComponent, IActionBlocker public class GhostComponent : SharedGhostComponent, IActionBlocker
@@ -46,6 +44,9 @@ namespace Content.Server.Observer
actor.playerSession.ContentData().Mind.UnVisit(); actor.playerSession.ContentData().Mind.UnVisit();
} }
break; break;
case PlayerAttachedMsg _:
Dirty();
break;
case PlayerDetachedMsg _: case PlayerDetachedMsg _:
Timer.Spawn(100, Owner.Delete); Timer.Spawn(100, Owner.Delete);
break; break;
@@ -54,7 +55,6 @@ namespace Content.Server.Observer
} }
} }
public bool CanInteract() => false; public bool CanInteract() => false;
public bool CanUse() => false; public bool CanUse() => false;
public bool CanThrow() => false; public bool CanThrow() => false;

View File

@@ -1,4 +1,5 @@
using Content.Server.GameObjects; using Content.Server.GameObjects;
using Content.Server.GameObjects.Components.Observer;
using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Server.Players; using Content.Server.Players;
@@ -7,6 +8,7 @@ using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map; using Robust.Shared.Map;
namespace Content.Server.Observer namespace Content.Server.Observer

View File

@@ -1,9 +1,8 @@
using System; using System;
using Content.Shared.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.Observer namespace Content.Shared.GameObjects.Components.Observer
{ {
public class SharedGhostComponent : Component public class SharedGhostComponent : Component
{ {

View File

@@ -16,3 +16,7 @@
DoRangeCheck: false DoRangeCheck: false
- type: IgnorePause - type: IgnorePause
- type: Ghost - type: Ghost
- type: Sprite
netsync: false
drawdepth: Mobs
texture: Mob/observer.png