Re-organize all projects (#4166)
This commit is contained in:
64
Content.Server/AI/Commands/AddAiCommand.cs
Normal file
64
Content.Server/AI/Commands/AddAiCommand.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
#nullable enable
|
||||
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;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.AI.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
public class AddAiCommand : IConsoleCommand
|
||||
{
|
||||
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 (!IoCManager.Resolve<IEntityManager>().TryGetEntity(entId, out var ent))
|
||||
{
|
||||
shell.WriteLine($"Unable to find entity with uid {entId}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ent.HasComponent<AiControllerComponent>())
|
||||
{
|
||||
shell.WriteLine("Entity already has an AI component.");
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: IMover refffaaccctttooorrr
|
||||
if (ent.HasComponent<IMoverComponent>())
|
||||
{
|
||||
ent.RemoveComponent<IMoverComponent>();
|
||||
}
|
||||
|
||||
var comp = ent.AddComponent<UtilityAi>();
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
95
Content.Server/AI/Commands/FactionCommand.cs
Normal file
95
Content.Server/AI/Commands/FactionCommand.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.AI.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
namespace Content.Server.AI.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
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, string argStr, 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.WriteLine(result.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length < 2)
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("Need more args"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Enum.TryParse(args[0], true, out Faction faction))
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("Invalid faction"));
|
||||
return;
|
||||
}
|
||||
|
||||
Faction targetFaction;
|
||||
|
||||
switch (args[1])
|
||||
{
|
||||
case "friendly":
|
||||
if (args.Length < 3)
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("Need to supply a target faction"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Enum.TryParse(args[2], true, out targetFaction))
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("Invalid target faction"));
|
||||
return;
|
||||
}
|
||||
|
||||
EntitySystem.Get<AiFactionTagSystem>().MakeFriendly(faction, targetFaction);
|
||||
shell.WriteLine(Loc.GetString("Command successful"));
|
||||
break;
|
||||
case "hostile":
|
||||
if (args.Length < 3)
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("Need to supply a target faction"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Enum.TryParse(args[2], true, out targetFaction))
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("Invalid target faction"));
|
||||
return;
|
||||
}
|
||||
|
||||
EntitySystem.Get<AiFactionTagSystem>().MakeHostile(faction, targetFaction);
|
||||
shell.WriteLine(Loc.GetString("Command successful"));
|
||||
break;
|
||||
case "list":
|
||||
shell.WriteLine(EntitySystem.Get<AiFactionTagSystem>().GetHostileFactions(faction).ToString());
|
||||
break;
|
||||
default:
|
||||
shell.WriteLine(Loc.GetString("Unknown faction arg"));
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user