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>
This commit is contained in:
Sam Weaver
2022-01-17 14:50:02 -05:00
committed by GitHub
parent 5f3e83e493
commit 40e2e78e0f
27 changed files with 591 additions and 44 deletions

View File

@@ -1,7 +1,10 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Content.Shared.Administration.Logs;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Converters;
using Content.Shared.Database;
using Content.Shared.FixedPoint;
using JetBrains.Annotations;
@@ -18,26 +21,32 @@ namespace Content.Shared.Chemistry.Reagent
/// </summary>
[ImplicitDataDefinitionForInheritors]
[MeansImplicitUse]
[JsonConverter(typeof(UniversalJsonConverter<ReagentEffect>))]
public abstract class ReagentEffect
{
[JsonPropertyName("id")] private protected string _id => this.GetType().Name;
/// <summary>
/// The list of conditions required for the effect to activate. Not required.
/// </summary>
[JsonPropertyName("conditions")]
[DataField("conditions")]
public ReagentEffectCondition[]? Conditions;
/// <summary>
/// What's the chance, from 0 to 1, that this effect will occur?
/// </summary>
[JsonPropertyName("probability")]
[DataField("probability")]
public float Probability = 1.0f;
[JsonIgnore]
[DataField("logImpact")]
public virtual LogImpact LogImpact { get; } = LogImpact.Low;
/// <summary>
/// Should this reagent effect log at all?
/// </summary>
[JsonIgnore]
[DataField("shouldLog")]
public virtual bool ShouldLog { get; } = false;

View File

@@ -1,4 +1,5 @@
using Content.Shared.Chemistry.Components;
using System.Text.Json.Serialization;
using Content.Shared.Converters;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -7,8 +8,11 @@ namespace Content.Shared.Chemistry.Reagent
{
[ImplicitDataDefinitionForInheritors]
[MeansImplicitUse]
[JsonConverter(typeof(UniversalJsonConverter<ReagentEffectCondition>))]
public abstract class ReagentEffectCondition
{
[JsonPropertyName("id")] private protected string _id => this.GetType().Name;
public abstract bool Condition(ReagentEffectArgs args);
}
}

View File

@@ -1,9 +1,11 @@
using System;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Content.Shared.Administration.Logs;
using Content.Shared.Body.Prototypes;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Converters;
using Content.Shared.Database;
using Content.Shared.FixedPoint;
using Robust.Shared.GameObjects;
@@ -30,6 +32,9 @@ namespace Content.Shared.Chemistry.Reagent
[DataField("name")]
public string Name { get; } = string.Empty;
[DataField("group")]
public string Group { get; } = "Unknown";
[DataField("parent", customTypeSerializer:typeof(PrototypeIdSerializer<ReagentPrototype>))]
public string? Parent { get; private set; }
@@ -139,17 +144,20 @@ namespace Content.Shared.Chemistry.Reagent
}
[DataDefinition]
[JsonConverter(typeof(UniversalJsonConverter<ReagentEffectsEntry>))]
public class ReagentEffectsEntry
{
/// <summary>
/// Amount of reagent to metabolize, per metabolism cycle.
/// </summary>
[JsonPropertyName("rate")]
[DataField("metabolismRate")]
public FixedPoint2 MetabolismRate = FixedPoint2.New(0.5f);
/// <summary>
/// A list of effects to apply when these reagents are metabolized.
/// </summary>
[JsonPropertyName("effects")]
[DataField("effects", required: true)]
public ReagentEffect[] Effects = default!;
}