FIXED: Chemistry JSON dump tool and companion GitHub Action (#6222)

Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com>
This commit is contained in:
Sam Weaver
2022-01-18 16:44:22 -05:00
committed by GitHub
parent 9d73ff1e26
commit adddd2fac6
27 changed files with 602 additions and 43 deletions

View File

@@ -0,0 +1,96 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
using Content.Server.Body.Components;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Maths;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.GuideGenerator;
public class ReagentEntry
{
[JsonPropertyName("id")]
public string Id { get; }
[JsonPropertyName("name")]
public string Name { get; }
[JsonPropertyName("group")]
public string Group { get; }
[JsonPropertyName("desc")]
public string Description { get; }
[JsonPropertyName("physicalDesc")]
public string PhysicalDescription { get; }
[JsonPropertyName("color")]
public string SubstanceColor { get; }
[JsonPropertyName("recipes")]
public List<string> Recipes { get; } = new();
[JsonPropertyName("metabolisms")]
public Dictionary<string, ReagentEffectsEntry>? Metabolisms { get; }
public ReagentEntry(ReagentPrototype proto)
{
Id = proto.ID;
Name = proto.Name;
Group = proto.Group;
Description = proto.Description;
PhysicalDescription = proto.PhysicalDescription;
SubstanceColor = proto.SubstanceColor.ToHex();
Metabolisms = proto.Metabolisms;
}
}
public class ReactionEntry
{
[JsonPropertyName("id")]
public string Id { get; }
[JsonPropertyName("name")]
public string Name { get; }
[JsonPropertyName("reactants")]
public Dictionary<string, ReactantEntry> Reactants { get; }
[JsonPropertyName("products")]
public Dictionary<string, float> Products { get; }
[JsonPropertyName("effects")]
public List<ReagentEffect> Effects { get; }
public ReactionEntry(ReactionPrototype proto)
{
Id = proto.ID;
Name = proto.Name;
Reactants =
proto.Reactants
.Select(x => KeyValuePair.Create(x.Key, new ReactantEntry(x.Value.Amount.Float(), x.Value.Catalyst)))
.ToDictionary(x => x.Key, x => x.Value);
Products =
proto.Products
.Select(x => KeyValuePair.Create(x.Key, x.Value.Float()))
.ToDictionary(x => x.Key, x => x.Value);
Effects = proto.Effects;
}
}
public class ReactantEntry
{
[JsonPropertyName("amount")]
public float Amount { get; }
[JsonPropertyName("catalyst")]
public bool Catalyst { get; }
public ReactantEntry(float amnt, bool cata)
{
Amount = amnt;
Catalyst = cata;
}
}