2021-07-17 02:37:09 +02:00
|
|
|
|
using Content.Server.Administration;
|
2020-12-03 03:40:47 +01:00
|
|
|
|
using Content.Server.Players;
|
|
|
|
|
|
using Content.Shared.Administration;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Server.Player;
|
2021-02-01 16:49:43 -08:00
|
|
|
|
using Robust.Shared.Console;
|
2020-12-03 03:40:47 +01:00
|
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Server.Objectives.Commands
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
|
|
|
|
|
[AdminCommand(AdminFlags.Admin)]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class AddObjectiveCommand : IConsoleCommand
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
|
|
|
|
|
public string Command => "addobjective";
|
|
|
|
|
|
public string Description => "Adds an objective to the player's mind.";
|
|
|
|
|
|
public string Help => "addobjective <username> <objectiveID>";
|
2021-02-01 16:49:43 -08:00
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
|
|
|
|
|
if (args.Length != 2)
|
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine("Expected exactly 2 arguments.");
|
2020-12-03 03:40:47 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var mgr = IoCManager.Resolve<IPlayerManager>();
|
|
|
|
|
|
if (!mgr.TryGetPlayerDataByUsername(args[0], out var data))
|
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine("Can't find the playerdata.");
|
2020-12-03 03:40:47 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var mind = data.ContentData()?.Mind;
|
|
|
|
|
|
if (mind == null)
|
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine("Can't find the mind.");
|
2020-12-03 03:40:47 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!IoCManager.Resolve<IPrototypeManager>()
|
|
|
|
|
|
.TryIndex<ObjectivePrototype>(args[1], out var objectivePrototype))
|
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine($"Can't find matching ObjectivePrototype {objectivePrototype}");
|
2020-12-03 03:40:47 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!mind.TryAddObjective(objectivePrototype))
|
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine("Objective requirements dont allow that objective to be added.");
|
2020-12-03 03:40:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|