Files
wwdpublic/Content.Server/_White/Commands/SetCustomGhostCommand.cs
RedFoxIV 50b19259b8 Re: ghost (#849)
* it just works

* why hasn't it catastrophically failed yet

* not just gotta do the ui

oh god the ui

* that was easier than expected

* a devious misdirection

* touchups

* svin

* loc+fix

* touchups

* shitfix

* touchups x3

* for further use

* i hate this piece of shit engine

* touchups x4

* ribbit

also i'm retarded x2

* big tard energy

* bb

* rabbitson

* ?

* forgor

* k

* whoops

* fug
2025-09-27 08:38:24 +03:00

63 lines
1.9 KiB
C#

using Content.Server.Database;
using Content.Server.Players.PlayTimeTracking;
using Content.Server.Preferences.Managers;
using Content.Shared._White.CustomGhostSystem;
using Content.Shared.Administration;
using Content.Shared.Mind;
using Robust.Shared.Console;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Content.Server._White.Commands;
[AnyCommand]
public sealed class SetCustomGhostCommand : IConsoleCommand
{
[Dependency] private readonly IServerDbManager _db = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly IServerPreferencesManager _prefMan = default!;
public string Command => "setcustomghost";
public string Description => Loc.GetString("setcustomghost-command-description");
public string Help => Loc.GetString("setcustomghost-command-help-text");
public async void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not ICommonSession player)
{
shell.WriteLine(Loc.GetString("setcustomghost-command-no-session"));
return;
}
if (args.Length != 1)
{
shell.WriteLine(Help);
return;
}
var protoId = args[0];
if (!_proto.TryIndex<CustomGhostPrototype>(protoId, out var proto))
{
shell.WriteLine(Loc.GetString("setcustomghost-command-invalid-ghost-id"));
return;
}
if (!proto.CanUse(player, out var failReason))
{
shell.WriteLine(failReason);
return;
}
await _db.SaveGhostTypeAsync(player.UserId, protoId);
var prefs = _prefMan.GetPreferences(player.UserId);
prefs.CustomGhost = protoId;
shell.WriteLine(Loc.GetString("setcustomghost-command-saved"));
}
}