Reorganize commands into the Commands folder (#2679)

* Reorganize commands into the Commands folder

* RIDER
This commit is contained in:
DrSmugleaf
2020-12-03 03:40:47 +01:00
committed by GitHub
parent 7905d93564
commit 87f9a6e167
69 changed files with 2817 additions and 2293 deletions

View File

@@ -1,14 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using Content.Server.Administration;
using Content.Server.GameObjects.Components.AI;
using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Localization;
namespace Content.Server.GameObjects.EntitySystems.AI
{
@@ -91,88 +84,4 @@ namespace Content.Server.GameObjects.EntitySystems.AI
_hostileFactions[source] = hostileFactions;
}
}
[AdminCommand(AdminFlags.Fun)]
public sealed class FactionCommand : IClientCommand
{
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)
{
if (args.Length == 0)
{
var result = new StringBuilder();
foreach (Faction value in Enum.GetValues(typeof(Faction)))
{
if (value == Faction.None)
continue;
result.Append(value + "\n");
}
shell.SendText(player, result.ToString());
return;
}
if (args.Length < 2)
{
shell.SendText(player, Loc.GetString("Need more args"));
return;
}
if (!Enum.TryParse(args[0], true, out Faction faction))
{
shell.SendText(player, Loc.GetString("Invalid faction"));
return;
}
Faction targetFaction;
switch (args[1])
{
case "friendly":
if (args.Length < 3)
{
shell.SendText(player, 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"));
return;
}
EntitySystem.Get<AiFactionTagSystem>().MakeFriendly(faction, targetFaction);
shell.SendText(player, Loc.GetString("Command successful"));
break;
case "hostile":
if (args.Length < 3)
{
shell.SendText(player, 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"));
return;
}
EntitySystem.Get<AiFactionTagSystem>().MakeHostile(faction, targetFaction);
shell.SendText(player, Loc.GetString("Command successful"));
break;
case "list":
shell.SendText(player, EntitySystem.Get<AiFactionTagSystem>().GetHostileFactions(faction).ToString());
break;
default:
shell.SendText(player, Loc.GetString("Unknown faction arg"));
break;
}
return;
}
}
}

View File

@@ -144,50 +144,5 @@ namespace Content.Server.GameObjects.EntitySystems.AI
}
public bool ProcessorTypeExists(string name) => _processorTypes.ContainsKey(name);
[AdminCommand(AdminFlags.Fun)]
private class AddAiCommand : IClientCommand
{
public string Command => "addai";
public string Description => "Add an ai component with a given processor to an entity.";
public string Help => "Usage: addai <processorId> <entityId>"
+ "\n processorId: Class that inherits AiLogicProcessor and has an AiLogicProcessor attribute."
+ "\n entityID: Uid of entity to add the AiControllerComponent to. Open its VV menu to find this.";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
{
if(args.Length != 2)
{
shell.SendText(player, "Wrong number of args.");
return;
}
var processorId = args[0];
var entId = new EntityUid(int.Parse(args[1]));
var ent = IoCManager.Resolve<IEntityManager>().GetEntity(entId);
var aiSystem = Get<AiSystem>();
if (!aiSystem.ProcessorTypeExists(processorId))
{
shell.SendText(player, "Invalid processor type. Processor must inherit AiLogicProcessor and have an AiLogicProcessor attribute.");
return;
}
if (ent.HasComponent<AiControllerComponent>())
{
shell.SendText(player, "Entity already has an AI component.");
return;
}
if (ent.HasComponent<IMoverComponent>())
{
ent.RemoveComponent<IMoverComponent>();
}
var comp = ent.AddComponent<AiControllerComponent>();
comp.LogicName = processorId;
shell.SendText(player, "AI component added.");
}
}
}
}

View File

@@ -1,16 +1,10 @@
using System.Collections.Generic;
using Content.Server.Administration;
using Content.Server.GameObjects.Components.MachineLinking;
using Content.Server.GameObjects.EntitySystems.Click;
using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Input;
using Robust.Shared.Input.Binding;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Players;
@@ -99,43 +93,4 @@ namespace Content.Server.GameObjects.EntitySystems
}
}
[AdminCommand(AdminFlags.Debug)]
public class SignalLinkerCommand : IClientCommand
{
public string Command => "signallink";
public string Description => "Turns on signal linker mode. Click a transmitter to tune that signal and then click on each receiver to tune them to the transmitter signal.";
public string Help => "signallink (on/off)";
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
{
bool? enable = null;
if (args.Length > 0)
{
if (args[0] == "on")
enable = true;
else if (args[0] == "off")
enable = false;
else if (bool.TryParse(args[0], out var boolean))
enable = boolean;
else if (int.TryParse(args[0], out var num))
{
if (num == 1)
enable = true;
else if (num == 0)
enable = false;
}
}
if (!IoCManager.Resolve<IEntitySystemManager>().TryGetEntitySystem<SignalLinkerSystem>(out var system))
{
return;
}
var ret = system.SignalLinkerKeybind(player.UserId, enable);
shell.SendText(player, ret ? "Enabled" : "Disabled");
}
}
}