view ghosts on round end (#11680)
* view ghosts on round end * now make it good * it toggles now i hope
This commit is contained in:
38
Content.Server/Administration/Commands/ShowGhostsCommand.cs
Normal file
38
Content.Server/Administration/Commands/ShowGhostsCommand.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Content.Server.Ghost;
|
||||
using Content.Server.Revenant.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
|
||||
namespace Content.Server.Administration.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public sealed class ShowGhostsCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
public string Command => "showghosts";
|
||||
public string Description => "makes all of the currently present ghosts visible. Cannot be reversed.";
|
||||
public string Help => "showghosts <visible>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bool.TryParse(args[0], out var visible))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-invalid-bool"));
|
||||
return;
|
||||
}
|
||||
|
||||
var ghostSys = _entities.EntitySysManager.GetEntitySystem<GhostSystem>();
|
||||
var revSys = _entities.EntitySysManager.GetEntitySystem<RevenantSystem>();
|
||||
|
||||
ghostSys.MakeVisible(visible);
|
||||
revSys.MakeVisible(visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using Content.Server.GameTicking;
|
||||
using Content.Server.Ghost.Components;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.MobState;
|
||||
using Content.Server.Players;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Server.Visible;
|
||||
@@ -32,6 +33,7 @@ namespace Content.Server.Ghost
|
||||
[Dependency] private readonly VisibilitySystem _visibilitySystem = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||
[Dependency] private readonly FollowerSystem _followerSystem = default!;
|
||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -53,6 +55,8 @@ namespace Content.Server.Ghost
|
||||
|
||||
SubscribeLocalEvent<GhostComponent, BooActionEvent>(OnActionPerform);
|
||||
SubscribeLocalEvent<GhostComponent, InsertIntoEntityStorageAttemptEvent>(OnEntityStorageInsertAttempt);
|
||||
|
||||
SubscribeLocalEvent<RoundEndTextAppendEvent>(_ => MakeVisible(true));
|
||||
}
|
||||
private void OnActionPerform(EntityUid uid, GhostComponent component, BooActionEvent args)
|
||||
{
|
||||
@@ -79,9 +83,14 @@ namespace Content.Server.Ghost
|
||||
private void OnRelayMoveInput(EntityUid uid, GhostOnMoveComponent component, ref MoveInputEvent args)
|
||||
{
|
||||
// Let's not ghost if our mind is visiting...
|
||||
if (EntityManager.HasComponent<VisitingMindComponent>(uid)) return;
|
||||
if (!EntityManager.TryGetComponent<MindComponent>(uid, out var mind) || !mind.HasMind || mind.Mind!.IsVisitingEntity) return;
|
||||
if (component.MustBeDead && TryComp<MobStateComponent>(uid, out var state) && !state.IsDead()) return;
|
||||
if (EntityManager.HasComponent<VisitingMindComponent>(uid))
|
||||
return;
|
||||
|
||||
if (!EntityManager.TryGetComponent<MindComponent>(uid, out var mind) || !mind.HasMind || mind.Mind!.IsVisitingEntity)
|
||||
return;
|
||||
|
||||
if (component.MustBeDead && (_mobState.IsAlive(uid) || _mobState.IsCritical(uid)))
|
||||
return;
|
||||
|
||||
_ticker.OnGhostAttempt(mind.Mind!, component.CanReturn);
|
||||
}
|
||||
@@ -91,9 +100,12 @@ namespace Content.Server.Ghost
|
||||
// Allow this entity to be seen by other ghosts.
|
||||
var visibility = EntityManager.EnsureComponent<VisibilityComponent>(component.Owner);
|
||||
|
||||
if (_ticker.RunLevel != GameRunLevel.PostRound)
|
||||
{
|
||||
_visibilitySystem.AddLayer(visibility, (int) VisibilityFlags.Ghost, false);
|
||||
_visibilitySystem.RemoveLayer(visibility, (int) VisibilityFlags.Normal, false);
|
||||
_visibilitySystem.RefreshVisibility(visibility);
|
||||
}
|
||||
|
||||
if (EntityManager.TryGetComponent(component.Owner, out EyeComponent? eye))
|
||||
{
|
||||
@@ -237,17 +249,38 @@ namespace Content.Server.Ghost
|
||||
|
||||
string playerInfo = $"{EntityManager.GetComponent<MetaDataComponent>(attached).EntityName} ({mind?.Mind?.CurrentJob?.Name ?? "Unknown"})";
|
||||
|
||||
if (TryComp<MobStateComponent>(attached, out var state) && !state.IsDead())
|
||||
if (_mobState.IsAlive(attached) || _mobState.IsCritical(attached))
|
||||
yield return new GhostWarp(attached, playerInfo, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnEntityStorageInsertAttempt(EntityUid uid, GhostComponent comp, InsertIntoEntityStorageAttemptEvent args)
|
||||
private void OnEntityStorageInsertAttempt(EntityUid uid, GhostComponent comp, InsertIntoEntityStorageAttemptEvent args)
|
||||
{
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the round ends, make all players able to see ghosts.
|
||||
/// </summary>
|
||||
public void MakeVisible(bool visible)
|
||||
{
|
||||
foreach (var (_, vis) in EntityQuery<GhostComponent, VisibilityComponent>())
|
||||
{
|
||||
if (visible)
|
||||
{
|
||||
_visibilitySystem.AddLayer(vis, (int) VisibilityFlags.Normal, false);
|
||||
_visibilitySystem.RemoveLayer(vis, (int) VisibilityFlags.Ghost, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_visibilitySystem.AddLayer(vis, (int) VisibilityFlags.Ghost, false);
|
||||
_visibilitySystem.RemoveLayer(vis, (int) VisibilityFlags.Normal, false);
|
||||
}
|
||||
_visibilitySystem.RefreshVisibility(vis);
|
||||
}
|
||||
}
|
||||
|
||||
public bool DoGhostBooEvent(EntityUid target)
|
||||
{
|
||||
var ghostBoo = new GhostBooEvent();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.Visible;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Visible;
|
||||
using Content.Shared.Revenant.Components;
|
||||
using Content.Shared.Revenant.EntitySystems;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -8,6 +9,7 @@ namespace Content.Server.Revenant.EntitySystems;
|
||||
public sealed class CorporealSystem : SharedCorporealSystem
|
||||
{
|
||||
[Dependency] private readonly VisibilitySystem _visibilitySystem = default!;
|
||||
[Dependency] private readonly GameTicker _ticker = default!;
|
||||
|
||||
public override void OnStartup(EntityUid uid, CorporealComponent component, ComponentStartup args)
|
||||
{
|
||||
@@ -25,7 +27,7 @@ public sealed class CorporealSystem : SharedCorporealSystem
|
||||
{
|
||||
base.OnShutdown(uid, component, args);
|
||||
|
||||
if (TryComp<VisibilityComponent>(uid, out var visibility))
|
||||
if (TryComp<VisibilityComponent>(uid, out var visibility) && _ticker.RunLevel != GameRunLevel.PostRound)
|
||||
{
|
||||
_visibilitySystem.AddLayer(visibility, (int) VisibilityFlags.Ghost, false);
|
||||
_visibilitySystem.RemoveLayer(visibility, (int) VisibilityFlags.Normal, false);
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Shared.Alert;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Shared.Stunnable;
|
||||
using Content.Shared.Revenant;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -42,6 +43,8 @@ public sealed partial class RevenantSystem : EntitySystem
|
||||
[Dependency] private readonly SharedStunSystem _stun = default!;
|
||||
[Dependency] private readonly TagSystem _tag = default!;
|
||||
[Dependency] private readonly StoreSystem _store = default!;
|
||||
[Dependency] private readonly VisibilitySystem _visibility = default!;
|
||||
[Dependency] private readonly GameTicker _ticker = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -54,6 +57,7 @@ public sealed partial class RevenantSystem : EntitySystem
|
||||
SubscribeLocalEvent<RevenantComponent, ExaminedEvent>(OnExamine);
|
||||
SubscribeLocalEvent<RevenantComponent, StatusEffectAddedEvent>(OnStatusAdded);
|
||||
SubscribeLocalEvent<RevenantComponent, StatusEffectEndedEvent>(OnStatusEnded);
|
||||
SubscribeLocalEvent<RoundEndTextAppendEvent>(_ => MakeVisible(true));
|
||||
|
||||
InitializeAbilities();
|
||||
}
|
||||
@@ -68,6 +72,13 @@ public sealed partial class RevenantSystem : EntitySystem
|
||||
_appearance.SetData(uid, RevenantVisuals.Harvesting, false);
|
||||
_appearance.SetData(uid, RevenantVisuals.Stunned, false);
|
||||
|
||||
if (_ticker.RunLevel == GameRunLevel.PostRound && TryComp<VisibilityComponent>(uid, out var visibility))
|
||||
{
|
||||
_visibility.AddLayer(visibility, (int) VisibilityFlags.Ghost, false);
|
||||
_visibility.RemoveLayer(visibility, (int) VisibilityFlags.Normal, false);
|
||||
_visibility.RefreshVisibility(visibility);
|
||||
}
|
||||
|
||||
//ghost vision
|
||||
if (TryComp(component.Owner, out EyeComponent? eye))
|
||||
eye.VisibilityMask |= (uint) (VisibilityFlags.Ghost);
|
||||
@@ -164,6 +175,24 @@ public sealed partial class RevenantSystem : EntitySystem
|
||||
_store.ToggleUi(uid, store);
|
||||
}
|
||||
|
||||
public void MakeVisible(bool visible)
|
||||
{
|
||||
foreach (var (_, vis) in EntityQuery<RevenantComponent, VisibilityComponent>())
|
||||
{
|
||||
if (visible)
|
||||
{
|
||||
_visibility.AddLayer(vis, (int) VisibilityFlags.Normal, false);
|
||||
_visibility.RemoveLayer(vis, (int) VisibilityFlags.Ghost, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_visibility.AddLayer(vis, (int) VisibilityFlags.Ghost, false);
|
||||
_visibility.RemoveLayer(vis, (int) VisibilityFlags.Normal, false);
|
||||
}
|
||||
_visibility.RefreshVisibility(vis);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
Reference in New Issue
Block a user