Files
wwdpublic/Content.Server/StationGoal/StationGoalCommand.cs
VMSolidus a9335dbbc9 Port Station Goals (#465)
# Description

https://github.com/Simple-Station/Parkstation-Friendly-Chainsaw/pull/10

This adds a feature whereby a random goal for the shift is faxed to the
station's Captain at the start of every shift.
It is up to the Captain to decide if and how this goal is to be
completed.
Goals are randomly generated every shift, and are meant to help
encourage station activity and RP.
Admins are also able to send station goals via `sendstationgoal`.

---

<details><summary><h1>Media</h1></summary>
<p>


![stationgoals](https://github.com/Simple-Station/Einstein-Engines/assets/16548818/4a2b5533-dfee-4388-bfbc-043ee71b2647)

---

</p>
</details> 

# Changelog

🆑 VMSolidus
- add: Added station goals that get sent to the Command fax machine at
the start of every shift

---------

Signed-off-by: VMSolidus <evilexecutive@gmail.com>
Co-authored-by: Danger Revolution! <142105406+DangerRevolution@users.noreply.github.com>
Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com>
2024-06-17 17:42:12 -04:00

56 lines
2.0 KiB
C#

using System.Linq;
using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.Prototypes;
namespace Content.Server.StationGoal
{
[AdminCommand(AdminFlags.Fun)]
public sealed class StationGoalCommand : IConsoleCommand
{
public string Command => "sendstationgoal";
public string Description => Loc.GetString("send-station-goal-command-description");
public string Help => Loc.GetString("send-station-goal-command-help-text", ("command", Command));
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
shell.WriteError(Loc.GetString("shell-need-exactly-one-argument"));
return;
}
var protoId = args[0];
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
if (!prototypeManager.TryIndex<StationGoalPrototype>(protoId, out var proto))
{
shell.WriteError(Loc.GetString("send-station-goal-command-error-no-goal-proto", ("id", protoId)));
return;
}
var stationGoalPaper = IoCManager.Resolve<IEntityManager>().System<StationGoalPaperSystem>();
if (!stationGoalPaper.SendStationGoal(proto))
{
shell.WriteError(Loc.GetString("send-station-goal-command-error-couldnt-fax"));
return;
}
}
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length == 1)
{
var options = IoCManager.Resolve<IPrototypeManager>()
.EnumeratePrototypes<StationGoalPrototype>()
.OrderBy(p => p.ID)
.Select(p => new CompletionOption(p.ID));
return CompletionResult.FromHintOptions(options, Loc.GetString("send-station-goal-command-arg-id"));
}
return CompletionResult.Empty;
}
}
}