Adds Administration verb category and AHelp verb. (#5773)
* Adds Administration verb category and AHelp verb. For more convenient adminin'. * abbreviate verb category to Admin * Add explosion verb to admin category
This commit is contained in:
committed by
GitHub
parent
e3e1291e54
commit
4de2896f58
@@ -24,6 +24,7 @@ using Content.Shared.Verbs;
|
|||||||
using Robust.Server.Console;
|
using Robust.Server.Console;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
|
using Robust.Shared.Console;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
@@ -38,6 +39,7 @@ namespace Content.Server.Administration
|
|||||||
public class AdminVerbSystem : EntitySystem
|
public class AdminVerbSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IConGroupController _groupController = default!;
|
[Dependency] private readonly IConGroupController _groupController = default!;
|
||||||
|
[Dependency] private readonly IConsoleHost _console = default!;
|
||||||
[Dependency] private readonly IAdminManager _adminManager = default!;
|
[Dependency] private readonly IAdminManager _adminManager = default!;
|
||||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
[Dependency] private readonly EuiManager _euiManager = default!;
|
[Dependency] private readonly EuiManager _euiManager = default!;
|
||||||
@@ -48,11 +50,51 @@ namespace Content.Server.Administration
|
|||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
|
SubscribeLocalEvent<GetOtherVerbsEvent>(AddAdminVerbs);
|
||||||
SubscribeLocalEvent<GetOtherVerbsEvent>(AddDebugVerbs);
|
SubscribeLocalEvent<GetOtherVerbsEvent>(AddDebugVerbs);
|
||||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
||||||
SubscribeLocalEvent<SolutionContainerManagerComponent, SolutionChangedEvent>(OnSolutionChanged);
|
SubscribeLocalEvent<SolutionContainerManagerComponent, SolutionChangedEvent>(OnSolutionChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddAdminVerbs(GetOtherVerbsEvent args)
|
||||||
|
{
|
||||||
|
if (!EntityManager.TryGetComponent<ActorComponent?>(args.User, out var actor))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var player = actor.PlayerSession;
|
||||||
|
|
||||||
|
// Ahelp
|
||||||
|
if (_adminManager.IsAdmin(player) && TryComp(args.Target, out ActorComponent? targetActor))
|
||||||
|
{
|
||||||
|
Verb verb = new();
|
||||||
|
verb.Text = Loc.GetString("ahelp-verb-get-data-text");
|
||||||
|
verb.Category = VerbCategory.Admin;
|
||||||
|
verb.IconTexture = "/Textures/Interface/gavel.svg.192dpi.png";
|
||||||
|
verb.Act = () => _console.RemoteExecuteCommand(player, $"openahelp \"{targetActor.PlayerSession.UserId}\"");;
|
||||||
|
verb.Impact = LogImpact.Low;
|
||||||
|
args.Verbs.Add(verb);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Atillery
|
||||||
|
if (_adminManager.HasAdminFlag(player, AdminFlags.Fun))
|
||||||
|
{
|
||||||
|
Verb verb = new();
|
||||||
|
verb.Text = Loc.GetString("explode-verb-get-data-text");
|
||||||
|
verb.Category = VerbCategory.Admin;
|
||||||
|
verb.Act = () =>
|
||||||
|
{
|
||||||
|
var coords = Transform(args.Target).Coordinates;
|
||||||
|
Timer.Spawn(_gameTiming.TickPeriod, () => _explosions.SpawnExplosion(coords, 0, 1, 2, 1), CancellationToken.None);
|
||||||
|
if (TryComp(args.Target, out SharedBodyComponent? body))
|
||||||
|
{
|
||||||
|
body.Gib();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
verb.Impact = LogImpact.Extreme; // if you're just outright killing a person, I guess that deserves to be extreme?
|
||||||
|
args.Verbs.Add(verb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void AddDebugVerbs(GetOtherVerbsEvent args)
|
private void AddDebugVerbs(GetOtherVerbsEvent args)
|
||||||
{
|
{
|
||||||
if (!EntityManager.TryGetComponent<ActorComponent?>(args.User, out var actor))
|
if (!EntityManager.TryGetComponent<ActorComponent?>(args.User, out var actor))
|
||||||
@@ -116,25 +158,6 @@ namespace Content.Server.Administration
|
|||||||
args.Verbs.Add(verb);
|
args.Verbs.Add(verb);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Atillery
|
|
||||||
if (_adminManager.HasAdminFlag(player, AdminFlags.Fun))
|
|
||||||
{
|
|
||||||
Verb verb = new();
|
|
||||||
verb.Text = Loc.GetString("explode-verb-get-data-text");
|
|
||||||
verb.Category = VerbCategory.Debug;
|
|
||||||
verb.Act = () =>
|
|
||||||
{
|
|
||||||
var coords = Transform(args.Target).Coordinates;
|
|
||||||
Timer.Spawn(_gameTiming.TickPeriod, () => _explosions.SpawnExplosion(coords, 0, 1, 2, 1), CancellationToken.None);
|
|
||||||
if (TryComp(args.Target, out SharedBodyComponent? body))
|
|
||||||
{
|
|
||||||
body.Gib();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
verb.Impact = LogImpact.Extreme; // if you're just outright killing a person, I guess that deserves to be extreme?
|
|
||||||
args.Verbs.Add(verb);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set clothing verb
|
// Set clothing verb
|
||||||
if (_groupController.CanCommand(player, "setoutfit") &&
|
if (_groupController.CanCommand(player, "setoutfit") &&
|
||||||
EntityManager.HasComponent<InventoryComponent>(args.Target))
|
EntityManager.HasComponent<InventoryComponent>(args.Target))
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ namespace Content.Shared.Verbs
|
|||||||
IconsOnly = iconsOnly;
|
IconsOnly = iconsOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly VerbCategory Admin =
|
||||||
|
new("verb-categories-admin", "/Textures/Interface/character.svg.192dpi.png");
|
||||||
|
|
||||||
public static readonly VerbCategory Debug =
|
public static readonly VerbCategory Debug =
|
||||||
new("verb-categories-debug", "/Textures/Interface/VerbIcons/debug.svg.192dpi.png");
|
new("verb-categories-debug", "/Textures/Interface/VerbIcons/debug.svg.192dpi.png");
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
delete-verb-get-data-text = Delete
|
delete-verb-get-data-text = Delete
|
||||||
edit-solutions-verb-get-data-text = Edit Solutions
|
edit-solutions-verb-get-data-text = Edit Solutions
|
||||||
explode-verb-get-data-text = Explode
|
explode-verb-get-data-text = Explode
|
||||||
|
ahelp-verb-get-data-text = Message
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ verb-self-target-pronoun = Yourself
|
|||||||
|
|
||||||
# verb categories & common verbs. These appear across multiple systems, so they may as well go here.
|
# verb categories & common verbs. These appear across multiple systems, so they may as well go here.
|
||||||
|
|
||||||
|
verb-categories-admin = Admin
|
||||||
verb-categories-debug = Debug
|
verb-categories-debug = Debug
|
||||||
verb-categories-eject = Eject
|
verb-categories-eject = Eject
|
||||||
verb-categories-insert = Insert
|
verb-categories-insert = Insert
|
||||||
|
|||||||
Reference in New Issue
Block a user