Files
OldThink/Content.Server/GuideGenerator/ReactionJsonGenerator.cs
Valtos a5cddf1223 json generator alternator and vibrator (#718)
* json generator alternator and vibrator

* каким хуем ты не закоммитился уебан
2024-09-29 01:15:33 +03:00

38 lines
1.1 KiB
C#

using System.IO;
using System.Linq;
using System.Text.Json;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Prototypes;
namespace Content.Server.GuideGenerator;
public sealed partial 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);
if (reactions is not null) AddMixingCategories(reactions, prototype);
var serializeOptions = new JsonSerializerOptions
{
WriteIndented = true,
Converters =
{
new UniversalJsonConverter<ReagentEffect>(),
},
NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals
};
file.Write(JsonSerializer.Serialize(reactions, serializeOptions));
}
}