Skip to content

Commit

Permalink
Fix ghost actions disappearing when toggling visibility of other ghos…
Browse files Browse the repository at this point in the history
  • Loading branch information
DrSmugleaf authored Oct 20, 2023
1 parent 5ae3a02 commit 5734f02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 32 deletions.
13 changes: 8 additions & 5 deletions Content.Client/Ghost/GhostSystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Content.Client.Movement.Systems;
using Content.Shared.Actions;
using Content.Shared.Ghost;
using Content.Shared.Popups;
using Robust.Client.Console;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
Expand Down Expand Up @@ -33,9 +32,10 @@ private bool GhostVisibility

_ghostVisibility = value;

foreach (var ghost in EntityQuery<GhostComponent, SpriteComponent>(true))
var query = AllEntityQuery<GhostComponent, SpriteComponent>();
while (query.MoveNext(out var uid, out _, out var sprite))
{
ghost.Item2.Visible = true;
sprite.Visible = value || uid == _playerManager.LocalPlayer?.ControlledEntity;
}
}
}
Expand Down Expand Up @@ -103,7 +103,10 @@ private void OnToggleGhosts(EntityUid uid, GhostComponent component, ToggleGhost
return;

Popup.PopupEntity(Loc.GetString("ghost-gui-toggle-ghost-visibility-popup"), args.Performer);
ToggleGhostVisibility();

if (uid == _playerManager.LocalPlayer?.ControlledEntity)
ToggleGhostVisibility();

args.Handled = true;
}

Expand Down Expand Up @@ -204,7 +207,7 @@ public void OpenGhostRoles()

public void ToggleGhostVisibility()
{
_console.RemoteExecuteCommand(null, "toggleghosts");
GhostVisibility = !GhostVisibility;
}
}
}
27 changes: 0 additions & 27 deletions Content.Server/Ghost/GhostSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Content.Server.Roles.Jobs;
using Content.Server.Warps;
using Content.Shared.Actions;
using Content.Shared.Administration;
using Content.Shared.Examine;
using Content.Shared.Eye;
using Content.Shared.Follower;
Expand All @@ -16,11 +15,9 @@
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Movement.Events;
using Content.Shared.Popups;
using Content.Shared.Storage.Components;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Timing;
Expand Down Expand Up @@ -357,28 +354,4 @@ public bool DoGhostBooEvent(EntityUid target)
return ghostBoo.Handled;
}
}

[AnyCommand]
public sealed class ToggleGhostVisibility : IConsoleCommand
{
public string Command => "toggleghosts";
public string Description => "Toggles ghost visibility";
public string Help => $"{Command}";

public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player == null)
shell.WriteLine("You can only toggle ghost visibility on a client.");

var entityManager = IoCManager.Resolve<IEntityManager>();

var uid = shell.Player?.AttachedEntity;
if (uid == null
|| !entityManager.HasComponent<GhostComponent>(uid)
|| !entityManager.TryGetComponent<EyeComponent>(uid, out var eyeComponent))
return;

entityManager.System<EyeSystem>().SetVisibilityMask(uid.Value, eyeComponent.VisibilityMask ^ (int) VisibilityFlags.Ghost, eyeComponent);
}
}
}

0 comments on commit 5734f02

Please sign in to comment.