Console Unify API Changes (#3059)
* Remove unused IChatCommand. * Lots of refactoring into a shared context. * Removed ICommonSession from server concmd Execute. * Added argStr parameter to concmd execute. * The execute function of client concmds now returns void, use the new shell.RemoteExecuteCommand function to forward commands. * Finally move shells and commands into shared. * Console commands can now be registered directly without a class in a shared context. * Engine API Changes. * Repair rebase damage. * Update Submodule.
This commit is contained in:
@@ -4,22 +4,22 @@ using Content.Server.Administration;
|
||||
using Content.Server.GameObjects.Components.AI;
|
||||
using Content.Server.GameObjects.EntitySystems.AI;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Interfaces.Console;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
namespace Content.Server.Commands.AI
|
||||
{
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
public sealed class FactionCommand : IClientCommand
|
||||
public sealed class FactionCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "factions";
|
||||
public string Description => "Update / list factional relationships for NPCs.";
|
||||
public string Help => "faction <source> <friendly/hostile> target\n" +
|
||||
"faction <source> list: hostile factions";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length == 0)
|
||||
{
|
||||
@@ -31,19 +31,19 @@ namespace Content.Server.Commands.AI
|
||||
result.Append(value + "\n");
|
||||
}
|
||||
|
||||
shell.SendText(player, result.ToString());
|
||||
shell.WriteLine(result.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length < 2)
|
||||
{
|
||||
shell.SendText(player, Loc.GetString("Need more args"));
|
||||
shell.WriteLine(Loc.GetString("Need more args"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Enum.TryParse(args[0], true, out Faction faction))
|
||||
{
|
||||
shell.SendText(player, Loc.GetString("Invalid faction"));
|
||||
shell.WriteLine(Loc.GetString("Invalid faction"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -54,40 +54,40 @@ namespace Content.Server.Commands.AI
|
||||
case "friendly":
|
||||
if (args.Length < 3)
|
||||
{
|
||||
shell.SendText(player, Loc.GetString("Need to supply a target faction"));
|
||||
shell.WriteLine(Loc.GetString("Need to supply a target faction"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Enum.TryParse(args[2], true, out targetFaction))
|
||||
{
|
||||
shell.SendText(player, Loc.GetString("Invalid target faction"));
|
||||
shell.WriteLine(Loc.GetString("Invalid target faction"));
|
||||
return;
|
||||
}
|
||||
|
||||
EntitySystem.Get<AiFactionTagSystem>().MakeFriendly(faction, targetFaction);
|
||||
shell.SendText(player, Loc.GetString("Command successful"));
|
||||
shell.WriteLine(Loc.GetString("Command successful"));
|
||||
break;
|
||||
case "hostile":
|
||||
if (args.Length < 3)
|
||||
{
|
||||
shell.SendText(player, Loc.GetString("Need to supply a target faction"));
|
||||
shell.WriteLine(Loc.GetString("Need to supply a target faction"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Enum.TryParse(args[2], true, out targetFaction))
|
||||
{
|
||||
shell.SendText(player, Loc.GetString("Invalid target faction"));
|
||||
shell.WriteLine(Loc.GetString("Invalid target faction"));
|
||||
return;
|
||||
}
|
||||
|
||||
EntitySystem.Get<AiFactionTagSystem>().MakeHostile(faction, targetFaction);
|
||||
shell.SendText(player, Loc.GetString("Command successful"));
|
||||
shell.WriteLine(Loc.GetString("Command successful"));
|
||||
break;
|
||||
case "list":
|
||||
shell.SendText(player, EntitySystem.Get<AiFactionTagSystem>().GetHostileFactions(faction).ToString());
|
||||
shell.WriteLine(EntitySystem.Get<AiFactionTagSystem>().GetHostileFactions(faction).ToString());
|
||||
break;
|
||||
default:
|
||||
shell.SendText(player, Loc.GetString("Unknown faction arg"));
|
||||
shell.WriteLine(Loc.GetString("Unknown faction arg"));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user