Files
crystall-punk-14/Content.Server/Ghost/Ghost.cs

40 lines
1.2 KiB
C#
Raw Normal View History

2021-06-09 22:19:39 +02:00
using Content.Server.GameTicking;
using Content.Shared.Administration;
using Content.Shared.Mind;
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
{
[AnyCommand]
public sealed class Ghost : IConsoleCommand
2020-03-03 20:37:26 +01: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";
public void Execute(IConsoleShell shell, string argStr, string[] args)
2020-03-03 20:37:26 +01:00
{
var player = shell.Player;
2020-03-03 20:37:26 +01:00
if (player == null)
{
shell.WriteLine("You have no session, you can't ghost.");
2020-03-03 20:37:26 +01:00
return;
}
var minds = _entities.System<SharedMindSystem>();
if (!minds.TryGetMind(player, out var mindId, out var mind))
{
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
}
if (!EntitySystem.Get<GameTicker>().OnGhostAttempt(mindId, true, true, mind))
{
shell.WriteLine("You can't ghost right now.");
}
2020-03-03 20:37:26 +01:00
}
}
}