DumpReagentGuideText.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using Content.Server.Administration;
  2. using Content.Shared.Administration;
  3. using Content.Shared.Chemistry.Reagent;
  4. using Robust.Shared.Console;
  5. using Robust.Shared.Prototypes;
  6. namespace Content.Server.Chemistry.Commands;
  7. [AdminCommand(AdminFlags.Debug)]
  8. public sealed class DumpReagentGuideText : IConsoleCommand
  9. {
  10. [Dependency] private readonly IPrototypeManager _prototype = default!;
  11. [Dependency] private readonly IEntitySystemManager _entSys = default!;
  12. public string Command => "dumpreagentguidetext";
  13. public string Description => "Dumps the guidebook text for a reagent to the console";
  14. public string Help => "dumpreagentguidetext <reagent>";
  15. public void Execute(IConsoleShell shell, string argStr, string[] args)
  16. {
  17. if (args.Length != 1)
  18. {
  19. shell.WriteError("Must have only 1 argument");
  20. return;
  21. }
  22. if (!_prototype.TryIndex<ReagentPrototype>(args[0], out var reagent))
  23. {
  24. shell.WriteError($"Invalid prototype: {args[0]}");
  25. return;
  26. }
  27. if (reagent.Metabolisms is null)
  28. {
  29. shell.WriteLine("Nothing to dump.");
  30. return;
  31. }
  32. foreach (var entry in reagent.Metabolisms.Values)
  33. {
  34. foreach (var effect in entry.Effects)
  35. {
  36. shell.WriteLine(effect.GuidebookEffectDescription(_prototype, _entSys) ?? $"[skipped effect of type {effect.GetType()}]");
  37. }
  38. }
  39. }
  40. }