Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ghosting in lobby #29648

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions Content.Server/Ghost/GhostCommand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Server.GameTicking;
using Content.Server.Popups;
using Content.Shared.Administration;
using Content.Shared.GameTicking;
using Content.Shared.Mind;
using Robust.Shared.Console;

Expand All @@ -10,6 +11,8 @@ namespace Content.Server.Ghost
public sealed class GhostCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entities = default!;
[Dependency] private readonly GameTicker _ticker = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;

public string Command => "ghost";
public string Description => Loc.GetString("ghost-command-description");
Expand All @@ -34,14 +37,20 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
return;
}

var minds = _entities.System<SharedMindSystem>();
if (!minds.TryGetMind(player, out var mindId, out var mind))
if (_ticker.PlayerGameStatuses.TryGetValue(player.UserId, out var status) &&
status != PlayerGameStatus.JoinedGame)
{
mindId = minds.CreateMind(player.UserId);
shell.WriteLine(Loc.GetString("ghost-command-lobby"));
return;
}

if (!_mind.TryGetMind(player, out var mindId, out var mind))
{
mindId = _mind.CreateMind(player.UserId);
mind = _entities.GetComponent<MindComponent>(mindId);
}

if (!_entities.System<GameTicker>().OnGhostAttempt(mindId, true, true, mind))
if (!_ticker.OnGhostAttempt(mindId, true, true, mind))
{
shell.WriteLine(Loc.GetString("ghost-command-denied"));
}
Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/en-US/chat/commands/ghost-command.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ ghost-command-help-text = The ghost command turns you into a ghost and makes the
Please note that you cannot return to your character's body after ghosting.
ghost-command-no-session = You have no session, you can't ghost.
ghost-command-denied = You cannot ghost right now.
ghost-command-lobby = You cannot ghost in lobby.
Loading