Skip to content

Commit 5734f02

Browse files
authored
Fix ghost actions disappearing when toggling visibility of other ghosts (space-wizards#21033)
1 parent 5ae3a02 commit 5734f02

File tree

2 files changed

+8
-32
lines changed

2 files changed

+8
-32
lines changed

Content.Client/Ghost/GhostSystem.cs

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Content.Client.Movement.Systems;
22
using Content.Shared.Actions;
33
using Content.Shared.Ghost;
4-
using Content.Shared.Popups;
54
using Robust.Client.Console;
65
using Robust.Client.GameObjects;
76
using Robust.Client.Graphics;
@@ -33,9 +32,10 @@ private bool GhostVisibility
3332

3433
_ghostVisibility = value;
3534

36-
foreach (var ghost in EntityQuery<GhostComponent, SpriteComponent>(true))
35+
var query = AllEntityQuery<GhostComponent, SpriteComponent>();
36+
while (query.MoveNext(out var uid, out _, out var sprite))
3737
{
38-
ghost.Item2.Visible = true;
38+
sprite.Visible = value || uid == _playerManager.LocalPlayer?.ControlledEntity;
3939
}
4040
}
4141
}
@@ -103,7 +103,10 @@ private void OnToggleGhosts(EntityUid uid, GhostComponent component, ToggleGhost
103103
return;
104104

105105
Popup.PopupEntity(Loc.GetString("ghost-gui-toggle-ghost-visibility-popup"), args.Performer);
106-
ToggleGhostVisibility();
106+
107+
if (uid == _playerManager.LocalPlayer?.ControlledEntity)
108+
ToggleGhostVisibility();
109+
107110
args.Handled = true;
108111
}
109112

@@ -204,7 +207,7 @@ public void OpenGhostRoles()
204207

205208
public void ToggleGhostVisibility()
206209
{
207-
_console.RemoteExecuteCommand(null, "toggleghosts");
210+
GhostVisibility = !GhostVisibility;
208211
}
209212
}
210213
}

Content.Server/Ghost/GhostSystem.cs

-27
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Content.Server.Roles.Jobs;
77
using Content.Server.Warps;
88
using Content.Shared.Actions;
9-
using Content.Shared.Administration;
109
using Content.Shared.Examine;
1110
using Content.Shared.Eye;
1211
using Content.Shared.Follower;
@@ -16,11 +15,9 @@
1615
using Content.Shared.Mobs.Components;
1716
using Content.Shared.Mobs.Systems;
1817
using Content.Shared.Movement.Events;
19-
using Content.Shared.Popups;
2018
using Content.Shared.Storage.Components;
2119
using Robust.Server.GameObjects;
2220
using Robust.Server.Player;
23-
using Robust.Shared.Console;
2421
using Robust.Shared.Physics.Components;
2522
using Robust.Shared.Physics.Systems;
2623
using Robust.Shared.Timing;
@@ -357,28 +354,4 @@ public bool DoGhostBooEvent(EntityUid target)
357354
return ghostBoo.Handled;
358355
}
359356
}
360-
361-
[AnyCommand]
362-
public sealed class ToggleGhostVisibility : IConsoleCommand
363-
{
364-
public string Command => "toggleghosts";
365-
public string Description => "Toggles ghost visibility";
366-
public string Help => $"{Command}";
367-
368-
public void Execute(IConsoleShell shell, string argStr, string[] args)
369-
{
370-
if (shell.Player == null)
371-
shell.WriteLine("You can only toggle ghost visibility on a client.");
372-
373-
var entityManager = IoCManager.Resolve<IEntityManager>();
374-
375-
var uid = shell.Player?.AttachedEntity;
376-
if (uid == null
377-
|| !entityManager.HasComponent<GhostComponent>(uid)
378-
|| !entityManager.TryGetComponent<EyeComponent>(uid, out var eyeComponent))
379-
return;
380-
381-
entityManager.System<EyeSystem>().SetVisibilityMask(uid.Value, eyeComponent.VisibilityMask ^ (int) VisibilityFlags.Ghost, eyeComponent);
382-
}
383-
}
384357
}

0 commit comments

Comments
 (0)