Files
tbd-station-14/Content.Server/AI/Commands/AddAiCommand.cs
metalgearsloth b9e876ca92 The real movement refactor (#9645)
* The real movement refactor

* ref events

* Jetpack cleanup

* a

* Vehicles partially working

* Balance tweaks

* Restore some shitcode

* AAAAAAAA

* Even more prediction

* ECS compstate trying to fix this

* yml

* vehicles kill me

* Don't lock keys

* a

* Fix problem

* Fix sounds

* shuttle inputs

* Shuttle controls

* space brakes

* Keybinds

* Fix merge

* Handle shutdown

* Fix keys

* Bump friction

* fix buckle offset

* Fix relay and friction

* Fix jetpack turning

* contexts amirite
2022-07-16 13:51:52 +10:00

58 lines
2.0 KiB
C#

using Content.Server.Administration;
using Content.Server.AI.Components;
using Content.Server.AI.Utility;
using Content.Server.AI.Utility.AiLogic;
using Content.Shared.Administration;
using Content.Shared.Movement.Components;
using Robust.Shared.Console;
namespace Content.Server.AI.Commands
{
[AdminCommand(AdminFlags.Fun)]
public sealed class AddAiCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entities = default!;
public string Command => "addai";
public string Description => "Add an ai component with a given processor to an entity.";
public string Help => "Usage: addai <entityId> <behaviorSet1> <behaviorSet2>..."
+ "\n entityID: Uid of entity to add the AiControllerComponent to. Open its VV menu to find this."
+ "\n behaviorSet: Name of a behaviorset to add to the component on initialize.";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if(args.Length < 1)
{
shell.WriteLine("Wrong number of args.");
return;
}
var entId = new EntityUid(int.Parse(args[0]));
if (!_entities.EntityExists(entId))
{
shell.WriteLine($"Unable to find entity with uid {entId}");
return;
}
if (_entities.HasComponent<AiControllerComponent>(entId))
{
shell.WriteLine("Entity already has an AI component.");
return;
}
var comp = _entities.AddComponent<UtilityAi>(entId);
var behaviorManager = IoCManager.Resolve<INpcBehaviorManager>();
for (var i = 1; i < args.Length; i++)
{
var bSet = args[i];
behaviorManager.AddBehaviorSet(comp, bSet, false);
}
behaviorManager.RebuildActions(comp);
shell.WriteLine("AI component added.");
}
}
}