Files
tbd-station-14/Content.Server/GuideGenerator/ReactionJsonGenerator.cs
Sam Weaver 40e2e78e0f Chemistry JSON dump tool and companion GitHub Action (#6134)
* fuck

* oh boy

* Sorted every chem into guide groups

* WHY ARE YOU NOT ABSTRACT

* removes the target thing in favor of simply generating everything.

* eee

* Add group for med

* Update wiki JSON generation to use System.Text.Json

* Fix error on shutdown during wiki JSON generation

* First pass at automatic wiki workflow

* Add a temporary workaround while the build is continuing to give errors

* Update workflow to reference correct API url, track dependency.

* Compile wiki actions into one job rather than two

* Update page name to reference editable page

* Add other JSON file and parameterize root page path

* A few steps closer to using `System.Text.Json` to serialize properly

* Revert System.Text.Json and return to Newtonsoft.Json.

* Revert the revert. Return to System.Text.Json.

This reverts commit a5ea98dfdcfab3f605ac4d82d3b110f099324308.

* Add and register UniversalJsonConverter class.

* Narrow triggers for update-wiki GitHub action.

Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com>
2022-01-17 13:50:02 -06:00

27 lines
743 B
C#

using System.IO;
using System.Linq;
using System.Text.Json;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.FixedPoint;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Server.GuideGenerator;
public class ReactionJsonGenerator
{
public static void PublishJson(StreamWriter file)
{
var prototype = IoCManager.Resolve<IPrototypeManager>();
var reactions =
prototype
.EnumeratePrototypes<ReactionPrototype>()
.Select(x => new ReactionEntry(x))
.ToDictionary(x => x.Id, x => x);
file.Write(JsonSerializer.Serialize(reactions, new JsonSerializerOptions { WriteIndented = true, IncludeFields = true }));
}
}