Command resolve killing and LEC conversions batch 2 (#38367)

commit progress
This commit is contained in:
Kyle Tyo
2025-06-17 14:01:28 -04:00
committed by GitHub
parent 57babe15ee
commit 0e1ff2644f
18 changed files with 130 additions and 126 deletions

View File

@@ -6,16 +6,17 @@ using Robust.Shared.Console;
namespace Content.Server.Movement;
[AdminCommand(AdminFlags.Fun)]
public sealed class LockEyesCommand : IConsoleCommand
public sealed class LockEyesCommand : LocalizedEntityCommands
{
public string Command => $"lockeyes";
public string Description => Loc.GetString("lockeyes-command-description");
public string Help => Loc.GetString("lockeyes-command-help");
public void Execute(IConsoleShell shell, string argStr, string[] args)
[Dependency] private readonly SharedMoverController _controller = default!;
public override string Command => $"lockeyes";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
shell.WriteError(Loc.GetString("shell-need-exactly-one-argument"));
return;
}
@@ -25,7 +26,6 @@ public sealed class LockEyesCommand : IConsoleCommand
return;
}
var system = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<SharedMoverController>();
system.CameraRotationLocked = value;
_controller.CameraRotationLocked = value;
}
}

View File

@@ -6,14 +6,12 @@ using Robust.Shared.Console;
namespace Content.Server.Movement;
[AdminCommand(AdminFlags.Fun)]
public sealed class RotateEyesCommand : IConsoleCommand
public sealed class RotateEyesCommand : LocalizedEntityCommands
{
public string Command => "rotateeyes";
public string Description => Loc.GetString("rotateeyes-command-description");
public string Help => Loc.GetString("rotateeyes-command-help");
public void Execute(IConsoleShell shell, string argStr, string[] args)
public override string Command => "rotateeyes";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
var entManager = IoCManager.Resolve<IEntityManager>();
var rotation = Angle.Zero;
if (args.Length == 1)
@@ -28,7 +26,7 @@ public sealed class RotateEyesCommand : IConsoleCommand
}
var count = 0;
var query = entManager.EntityQueryEnumerator<InputMoverComponent>();
var query = EntityManager.EntityQueryEnumerator<InputMoverComponent>();
while (query.MoveNext(out var uid, out var mover))
{
if (mover.TargetRelativeRotation.Equals(rotation))
@@ -36,10 +34,10 @@ public sealed class RotateEyesCommand : IConsoleCommand
mover.TargetRelativeRotation = rotation;
entManager.Dirty(uid, mover);
EntityManager.Dirty(uid, mover);
count++;
}
shell.WriteLine(Loc.GetString("rotateeyes-command-count", ("count", count)));
shell.WriteLine(Loc.GetString("cmd-rotateeyes-command-count", ("count", count)));
}
}

View File

@@ -7,12 +7,13 @@ using Robust.Shared.Console;
namespace Content.Server.NPC.Commands;
[AdminCommand(AdminFlags.Debug)]
public sealed class NPCCommand : IConsoleCommand
public sealed class NpcCommand : LocalizedEntityCommands
{
public string Command => "npc";
public string Description => "Opens the debug window for NPCs";
public string Help => $"{Command}";
public void Execute(IConsoleShell shell, string argStr, string[] args)
[Dependency] private readonly EuiManager _euiManager = default!;
public override string Command => "npc";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not { } playerSession)
{
@@ -20,7 +21,6 @@ public sealed class NPCCommand : IConsoleCommand
return;
}
var euiManager = IoCManager.Resolve<EuiManager>();
euiManager.OpenEui(new NPCEui(), playerSession);
_euiManager.OpenEui(new NPCEui(), playerSession);
}
}

View File

@@ -7,41 +7,40 @@ using Robust.Shared.Console;
namespace Content.Server.Power
{
[AdminCommand(AdminFlags.Debug)]
public sealed class SetBatteryPercentCommand : IConsoleCommand
public sealed class SetBatteryPercentCommand : LocalizedEntityCommands
{
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly BatterySystem _batterySystem = default!;
public string Command => "setbatterypercent";
public string Description => "Drains or recharges a battery by entity uid and percentage, i.e.: forall with Battery do setbatterypercent $ID 0";
public string Help => $"{Command} <id> <percent>";
public override string Command => "setbatterypercent";
public void Execute(IConsoleShell shell, string argStr, string[] args)
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 2)
{
shell.WriteLine($"Invalid amount of arguments.\n{Help}");
shell.WriteLine(Loc.GetString($"shell-wrong-arguments-number-need-specific",
("properAmount", 2),
("currentAmount", args.Length)));
return;
}
if (!NetEntity.TryParse(args[0], out var netEnt) || !_entManager.TryGetEntity(netEnt, out var id))
if (!NetEntity.TryParse(args[0], out var netEnt) || !EntityManager.TryGetEntity(netEnt, out var id))
{
shell.WriteLine($"{args[0]} is not a valid entity id.");
shell.WriteLine(Loc.GetString($"shell-invalid-entity-uid", ("uid", args[0])));
return;
}
if (!float.TryParse(args[1], out var percent))
{
shell.WriteLine($"{args[1]} is not a valid float (percentage).");
shell.WriteLine(Loc.GetString($"cmd-setbatterypercent-not-valid-percent", ("arg", args[1])));
return;
}
if (!_entManager.TryGetComponent<BatteryComponent>(id, out var battery))
if (!EntityManager.TryGetComponent<BatteryComponent>(id, out var battery))
{
shell.WriteLine($"No battery found with id {id}.");
shell.WriteLine(Loc.GetString($"cmd-setbatterypercent-battery-not-found", ("id", id)));
return;
}
var system = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<BatterySystem>();
system.SetCharge(id.Value, battery.MaxCharge * percent / 100, battery);
_batterySystem.SetCharge(id.Value, battery.MaxCharge * percent / 100, battery);
// Don't acknowledge b/c people WILL forall this
}
}

View File

@@ -89,19 +89,18 @@ public partial class RadiationSystem
/// Toggle visibility of radiation rays coming from rad sources.
/// </summary>
[AdminCommand(AdminFlags.Admin)]
public sealed class RadiationViewCommand : IConsoleCommand
public sealed class RadiationViewCommand : LocalizedEntityCommands
{
public string Command => "showradiation";
public string Description => Loc.GetString("radiation-command-description");
public string Help => Loc.GetString("radiation-command-help");
[Dependency] private readonly RadiationSystem _radiation = default!;
public void Execute(IConsoleShell shell, string argStr, string[] args)
public override string Command => "showradiation";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
var session = shell.Player;
if (session == null)
return;
var entityManager = IoCManager.Resolve<IEntityManager>();
entityManager.System<RadiationSystem>().ToggleDebugView(session);
_radiation.ToggleDebugView(session);
}
}

View File

@@ -10,53 +10,50 @@ using Robust.Shared.Prototypes;
namespace Content.Server.Roles
{
[AdminCommand(AdminFlags.Admin)]
public sealed class AddRoleCommand : IConsoleCommand
public sealed class AddRoleCommand : LocalizedEntityCommands
{
[Dependency] private readonly EntityManager _entityManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly JobSystem _jobSystem = default!;
public string Command => "addrole";
public override string Command => "addrole";
public string Description => "Adds a role to a player's mind.";
public string Help => "addrole <session ID> <role>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 2)
{
shell.WriteLine("Expected exactly 2 arguments.");
shell.WriteLine(Loc.GetString($"shell-wrong-arguments-number-need-specific",
("properAmount", 2),
("currentAmount", args.Length)));
return;
}
var mgr = IoCManager.Resolve<IPlayerManager>();
if (!mgr.TryGetPlayerDataByUsername(args[0], out var data))
if (!_playerManager.TryGetPlayerDataByUsername(args[0], out var data))
{
shell.WriteLine("Can't find that mind");
shell.WriteLine(Loc.GetString($"cmd-addrole-mind-not-found"));
return;
}
var mind = data.ContentData()?.Mind;
if (mind == null)
{
shell.WriteLine("Can't find that mind");
shell.WriteLine(Loc.GetString($"cmd-addrole-mind-not-found"));
return;
}
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
if (!prototypeManager.TryIndex<JobPrototype>(args[1], out var jobPrototype))
if (!_prototypeManager.TryIndex<JobPrototype>(args[1], out var jobPrototype))
{
shell.WriteLine("Can't find that role");
shell.WriteLine(Loc.GetString($"cmd-addrole-role-not-found"));
return;
}
var jobs = _entityManager.System<JobSystem>();
if (jobs.MindHasJobWithId(mind, jobPrototype.Name))
if (_jobSystem.MindHasJobWithId(mind, jobPrototype.Name))
{
shell.WriteLine("Mind already has that role");
shell.WriteLine(Loc.GetString($"cmd-addrole-mind-already-has-role"));
return;
}
jobs.MindAddJob(mind.Value, args[1]);
_jobSystem.MindAddJob(mind.Value, args[1]);
}
}
}

View File

@@ -7,24 +7,21 @@ using Robust.Shared.Prototypes;
namespace Content.Server.Roles
{
[AdminCommand(AdminFlags.Admin)]
public sealed class ListRolesCommand : IConsoleCommand
public sealed class ListRolesCommand : LocalizedCommands
{
public string Command => "listroles";
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public string Description => "Lists roles";
public override string Command => "listroles";
public string Help => "listroles";
public void Execute(IConsoleShell shell, string argStr, string[] args)
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 0)
{
shell.WriteLine("Expected no arguments.");
shell.WriteLine(Loc.GetString($"shell-need-exactly-zero-arguments"));
return;
}
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
foreach(var job in prototypeManager.EnumeratePrototypes<JobPrototype>())
foreach(var job in _prototypeManager.EnumeratePrototypes<JobPrototype>())
{
shell.WriteLine(job.ID);
}

View File

@@ -9,28 +9,27 @@ using Robust.Shared.Console;
namespace Content.Server.Roles
{
[AdminCommand(AdminFlags.Admin)]
public sealed class RemoveRoleCommand : IConsoleCommand
public sealed class RemoveRoleCommand : LocalizedEntityCommands
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly SharedJobSystem _jobs = default!;
[Dependency] private readonly SharedRoleSystem _roles = default!;
public string Command => "rmrole";
public override string Command => "rmrole";
public string Description => "Removes a role from a player's mind.";
public string Help => "rmrole <session ID> <Role Type>\nThat role type is the actual C# type name.";
public void Execute(IConsoleShell shell, string argStr, string[] args)
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 2)
{
shell.WriteLine("Expected exactly 2 arguments.");
shell.WriteLine(Loc.GetString($"shell-wrong-arguments-number-need-specific",
("properAmount", 2),
("currentAmount", args.Length)));
return;
}
var mgr = IoCManager.Resolve<IPlayerManager>();
if (!mgr.TryGetPlayerDataByUsername(args[0], out var data))
if (!_playerManager.TryGetPlayerDataByUsername(args[0], out var data))
{
shell.WriteLine("Can't find that mind");
shell.WriteLine(Loc.GetString($"cmd-addrole-mind-not-found"));
return;
}
@@ -38,14 +37,12 @@ namespace Content.Server.Roles
if (mind == null)
{
shell.WriteLine("Can't find that mind");
shell.WriteLine(Loc.GetString($"cmd-addrole-mind-not-found"));
return;
}
var roles = _entityManager.System<SharedRoleSystem>();
var jobs = _entityManager.System<SharedJobSystem>();
if (jobs.MindHasJobWithId(mind, args[1]))
roles.MindRemoveRole<JobRoleComponent>(mind.Value);
if (_jobs.MindHasJobWithId(mind, args[1]))
_roles.MindRemoveRole<JobRoleComponent>(mind.Value);
}
}
}

View File

@@ -12,57 +12,53 @@ using Robust.Shared.Console;
namespace Content.Server.Singularity
{
[AdminCommand(AdminFlags.Admin)]
public sealed class StartSingularityEngineCommand : IConsoleCommand
public sealed class StartSingularityEngineCommand : LocalizedEntityCommands
{
public string Command => "startsingularityengine";
public string Description => "Automatically turns on the particle accelerator and containment field emitters.";
public string Help => $"{Command}";
[Dependency] private readonly EmitterSystem _emitterSystem = default!;
[Dependency] private readonly MultipartMachineSystem _multipartSystem = default!;
[Dependency] private readonly ParticleAcceleratorSystem _paSystem = default!;
[Dependency] private readonly RadiationCollectorSystem _radCollectorSystem = default!;
public void Execute(IConsoleShell shell, string argStr, string[] args)
public override string Command => "startsingularityengine";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 0)
{
shell.WriteLine($"Invalid amount of arguments: {args.Length}.\n{Help}");
shell.WriteLine(Loc.GetString($"shell-need-exactly-zero-arguments"));
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
var entitySystemManager = IoCManager.Resolve<IEntitySystemManager>();
// Turn on emitters
var emitterQuery = entityManager.EntityQueryEnumerator<EmitterComponent>();
var emitterSystem = entitySystemManager.GetEntitySystem<EmitterSystem>();
var emitterQuery = EntityManager.EntityQueryEnumerator<EmitterComponent>();
while (emitterQuery.MoveNext(out var uid, out var emitterComponent))
{
//FIXME: This turns on ALL emitters, including APEs. It should only turn on the containment field emitters.
emitterSystem.SwitchOn(uid, emitterComponent);
_emitterSystem.SwitchOn(uid, emitterComponent);
}
// Turn on radiation collectors
var radiationCollectorQuery = entityManager.EntityQueryEnumerator<RadiationCollectorComponent>();
var radiationCollectorSystem = entitySystemManager.GetEntitySystem<RadiationCollectorSystem>();
var radiationCollectorQuery = EntityManager.EntityQueryEnumerator<RadiationCollectorComponent>();
while (radiationCollectorQuery.MoveNext(out var uid, out var radiationCollectorComponent))
{
radiationCollectorSystem.SetCollectorEnabled(uid, enabled: true, user: null, radiationCollectorComponent);
_radCollectorSystem.SetCollectorEnabled(uid, enabled: true, user: null, radiationCollectorComponent);
}
// Setup PA
var multipartMachineManager = entitySystemManager.GetEntitySystem<MultipartMachineSystem>();
var paSystem = entitySystemManager.GetEntitySystem<ParticleAcceleratorSystem>();
var paQuery = entityManager.EntityQueryEnumerator<ParticleAcceleratorControlBoxComponent>();
var paQuery = EntityManager.EntityQueryEnumerator<ParticleAcceleratorControlBoxComponent>();
while (paQuery.MoveNext(out var paId, out var paControl))
{
if (!entityManager.TryGetComponent<MultipartMachineComponent>(paId, out var machine))
if (!EntityManager.TryGetComponent<MultipartMachineComponent>(paId, out var machine))
continue;
if (!multipartMachineManager.Rescan((paId, machine)))
if (!_multipartSystem.Rescan((paId, machine)))
continue;
paSystem.SetStrength(paId, ParticleAcceleratorPowerState.Level0, comp: paControl);
paSystem.SwitchOn(paId, comp: paControl);
_paSystem.SetStrength(paId, ParticleAcceleratorPowerState.Level0, comp: paControl);
_paSystem.SwitchOn(paId, comp: paControl);
}
shell.WriteLine("Done!");
shell.WriteLine(Loc.GetString($"shell-command-success"));
}
}
}

View File

@@ -0,0 +1,10 @@
parse-bool-fail = Unable to parse {$arg} as a bool
parse-float-fail = Unable to parse {$arg} as a float
cmd-lockeyes-desc = Prevents eyes from being rotated any further.
cmd-lockeyes-help = Usage: lockeyes <true/false>
cmd-rotateeyes-desc = Rotates every player's current eye to the specified rotation
cmd-rotateeyes-help = rotateeyes <degrees (default 0)>
cmd-rotateeyes-command-count = Set {$count} eye rotations

View File

@@ -0,0 +1,2 @@
cmd-npc-desc = Opens the debug window for NPCs.
cmd-npc-help = Usage: npc

View File

@@ -0,0 +1,2 @@
cmd-showradiation-desc = Toggle visibility of radiation rays coming from rad sources
cmd-showradiation-help = Usage: showradiation

View File

@@ -0,0 +1,12 @@
cmd-addrole-desc = Adds a role to a player's mind.
cmd-addrole-help = Usage: addrole <session ID> <role>
cmd-addrole-mind-not-found = Can't find that mind.
cmd-addrole-role-not-found = Can't find that role.
cmd-addrole-mind-already-has-role = Mind already has that role.
cmd-listroles-desc = List all available roles.
cmd-listroles-help = Usage: listroles
cmd-rmrole-desc = Removes a role from a player's mind.
cmd-rmrole-help = Usage: rmrole <session ID> <Role Type>
The role type is the actual C# type name.

View File

@@ -0,0 +1,4 @@
cmd-setbatterypercent-desc = Drains or recharges a battery by entity uid and percentage, i.e.: forall with Battery do setbatterypercent $ID 0
cmd-setbatterypercent-help = Usage: setbatterypercent <id> <percent>
cmd-setbatterypercent-battery-not-found = No battery found with id {$id}.
cmd-setbatterypercent-not-valid-percent = {$arg} is not a valid float (percentage).

View File

@@ -0,0 +1,2 @@
cmd-startsingularityengine-desc = Automatically turns on the particle accelerator and containment field emitters.
cmd-startsingularityengine-help = Usage: startsingularityengine

View File

@@ -1,10 +0,0 @@
parse-bool-fail = Unable to parse {$arg} as a bool
parse-float-fail = Unable to parse {$arg} as a float
lockeyes-command-description = Prevents eyes from being rotated any further
lockeyes-command-help = lockeyes <true/false>
rotateeyes-command-description = Rotates every player's current eye to the specified rotation
rotateeyes-command-help = rotateeyes <degrees (default 0)>
rotateeyes-command-count = Set {$count} eye rotations

View File

@@ -1,2 +0,0 @@
radiation-command-description = Toggle visibility of radiation rays coming from rad sources
radiation-command-help = Usage: showradiation

View File

@@ -19,6 +19,7 @@ shell-wrong-arguments-number = Wrong number of arguments.
shell-need-between-arguments = Need {$lower} to {$upper} arguments!
shell-need-minimum-arguments = Need at least {$minimum} arguments!
shell-need-minimum-one-argument = Need at least one argument!
shell-need-exactly-zero-arguments = This command takes zero arguments.
shell-argument-uid = EntityUid