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

@@ -9,7 +9,9 @@ using Robust.Shared.ViewVariables;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
using Content.Shared.FixedPoint;
using Content.Shared.Converters;
namespace Content.Shared.Damage
{
@@ -21,17 +23,21 @@ namespace Content.Shared.Damage
/// functions to apply resistance sets and supports basic math operations to modify this dictionary.
/// </remarks>
[DataDefinition]
[JsonConverter(typeof(UniversalJsonConverter<DamageSpecifier>))]
public class DamageSpecifier
{
[JsonPropertyName("types")]
[DataField("types", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, DamageTypePrototype>))]
private readonly Dictionary<string,FixedPoint2>? _damageTypeDictionary;
[JsonPropertyName("groups")]
[DataField("groups", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, DamageGroupPrototype>))]
private readonly Dictionary<string, FixedPoint2>? _damageGroupDictionary;
/// <summary>
/// Main DamageSpecifier dictionary. Most DamageSpecifier functions exist to somehow modifying this.
/// </summary>
[JsonIgnore]
[ViewVariables(VVAccess.ReadWrite)]
public Dictionary<string, FixedPoint2> DamageDict
{
@@ -43,6 +49,7 @@ namespace Content.Shared.Damage
}
set => _damageDict = value;
}
[JsonIgnore]
private Dictionary<string, FixedPoint2>? _damageDict;
/// <summary>
@@ -53,11 +60,13 @@ namespace Content.Shared.Damage
/// in another. For this purpose, you should instead use <see cref="TrimZeros()"/> and then check the <see
/// cref="Empty"/> property.
/// </remarks>
[JsonIgnore]
public FixedPoint2 Total => DamageDict.Values.Sum();
/// <summary>
/// Whether this damage specifier has any entries.
/// </summary>
[JsonIgnore]
public bool Empty => DamageDict.Count == 0;
#region constructors