* Adds uses before delay so actions can be used multiple times before cooldown * adds methods to get remaining charges, to set uses before delay, and to set use delay * adds method to change action name * moves set usedelay * action upgrade ECS * adds method to reset remaining uses * adds upgrade events * refactors action upgrade event and adds logic to parse it * fix serialization issue * adds level up draft method * adds action commands and a command to upgrade an action * more warning lines to help * Gets action to upgrade properly * Removes unneeded fields from the action upgrade component and now properly raises the level of the new action * Cleans up dead code and comments * Fixes punctuation in actions-commands and adds a TryUpgradeAction method. * removes TODO comment * robust fix * removes RT * readds RT * update RT to 190 * removes change name method * removes remaining uses & related fields and adds that functionality to charges * Adds Charges to action tooltips that require it
82 lines
2.5 KiB
C#
82 lines
2.5 KiB
C#
using Content.Server.Administration;
|
|
using Content.Shared.Actions;
|
|
using Content.Shared.Administration;
|
|
using Robust.Shared.Console;
|
|
|
|
namespace Content.Server.Commands;
|
|
|
|
[AdminCommand(AdminFlags.Fun)]
|
|
internal sealed class UpgradeActionCommand : IConsoleCommand
|
|
{
|
|
[Dependency] private readonly IEntityManager _entMan = default!;
|
|
|
|
public string Command => "upgradeaction";
|
|
public string Description => Loc.GetString("upgradeaction-command-description");
|
|
public string Help => Loc.GetString("upgradeaction-command-help");
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
if (args.Length < 1)
|
|
{
|
|
shell.WriteLine(Loc.GetString("upgradeaction-command-need-one-argument"));
|
|
return;
|
|
}
|
|
|
|
if (args.Length > 2)
|
|
{
|
|
shell.WriteLine(Loc.GetString("upgradeaction-command-max-two-arguments"));
|
|
return;
|
|
}
|
|
|
|
var actionUpgrade = _entMan.EntitySysManager.GetEntitySystem<ActionUpgradeSystem>();
|
|
var id = args[0];
|
|
|
|
if (!EntityUid.TryParse(id, out var uid))
|
|
{
|
|
shell.WriteLine(Loc.GetString("upgradeaction-command-incorrect-entityuid-format"));
|
|
return;
|
|
}
|
|
|
|
if (!_entMan.EntityExists(uid))
|
|
{
|
|
shell.WriteLine(Loc.GetString("upgradeaction-command-entity-does-not-exist"));
|
|
return;
|
|
}
|
|
|
|
if (!_entMan.TryGetComponent<ActionUpgradeComponent>(uid, out var actionUpgradeComponent))
|
|
{
|
|
shell.WriteLine(Loc.GetString("upgradeaction-command-entity-is-not-action"));
|
|
return;
|
|
}
|
|
|
|
if (args.Length == 1)
|
|
{
|
|
if (!actionUpgrade.TryUpgradeAction(uid, actionUpgradeComponent))
|
|
{
|
|
shell.WriteLine(Loc.GetString("upgradeaction-command-cannot-level-up"));
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (args.Length == 2)
|
|
{
|
|
var levelArg = args[1];
|
|
|
|
if (!int.TryParse(levelArg, out var level))
|
|
{
|
|
shell.WriteLine(Loc.GetString("upgradeaction-command-second-argument-not-number"));
|
|
return;
|
|
}
|
|
|
|
if (level <= 0)
|
|
{
|
|
shell.WriteLine(Loc.GetString("upgradeaction-command-less-than-required-level"));
|
|
return;
|
|
}
|
|
|
|
if (!actionUpgrade.TryUpgradeAction(uid, actionUpgradeComponent, level))
|
|
shell.WriteLine(Loc.GetString("upgradeaction-command-cannot-level-up"));
|
|
}
|
|
}
|
|
}
|