2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.GameTicking;
|
2021-12-13 16:45:49 +11:00
|
|
|
using Content.Shared.Administration;
|
2023-08-30 21:46:11 -07:00
|
|
|
using Content.Shared.Mind;
|
2021-02-01 16:49:43 -08:00
|
|
|
using Robust.Shared.Console;
|
2020-03-03 20:37:26 +01:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Ghost
|
2020-03-03 20:37:26 +01:00
|
|
|
{
|
2020-10-30 16:06:48 +01:00
|
|
|
[AnyCommand]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class Ghost : IConsoleCommand
|
2020-03-03 20:37:26 +01:00
|
|
|
{
|
2023-08-28 16:53:24 -07:00
|
|
|
[Dependency] private readonly IEntityManager _entities = default!;
|
|
|
|
|
|
2020-03-03 20:37:26 +01:00
|
|
|
public string Command => "ghost";
|
|
|
|
|
public string Description => "Give up on life and become a ghost.";
|
|
|
|
|
public string Help => "ghost";
|
|
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2020-03-03 20:37:26 +01:00
|
|
|
{
|
2023-10-28 09:59:53 +11:00
|
|
|
var player = shell.Player;
|
2020-03-03 20:37:26 +01:00
|
|
|
if (player == null)
|
|
|
|
|
{
|
2023-01-19 03:56:45 +01:00
|
|
|
shell.WriteLine("You have no session, you can't ghost.");
|
2020-03-03 20:37:26 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-30 21:46:11 -07:00
|
|
|
var minds = _entities.System<SharedMindSystem>();
|
2023-08-28 16:53:24 -07:00
|
|
|
if (!minds.TryGetMind(player, out var mindId, out var mind))
|
2020-08-25 05:37:54 -06:00
|
|
|
{
|
2023-10-07 12:00:48 +11:00
|
|
|
mindId = minds.CreateMind(player.UserId);
|
|
|
|
|
mind = _entities.GetComponent<MindComponent>(mindId);
|
2020-03-03 20:37:26 +01:00
|
|
|
}
|
|
|
|
|
|
2023-08-28 16:53:24 -07:00
|
|
|
if (!EntitySystem.Get<GameTicker>().OnGhostAttempt(mindId, true, true, mind))
|
2020-08-14 08:13:32 -05:00
|
|
|
{
|
2023-01-19 03:56:45 +01:00
|
|
|
shell.WriteLine("You can't ghost right now.");
|
2020-08-14 08:13:32 -05:00
|
|
|
}
|
2020-03-03 20:37:26 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|