mirror of
https://github.com/space-wizards/space-station-14.git
synced 2026-02-14 19:29:53 +01:00
Revert System.Text.Json and return to Newtonsoft.Json.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.FixedPoint;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects
|
||||
{
|
||||
@@ -17,7 +17,7 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
/// <summary>
|
||||
/// Damage to apply every metabolism cycle. Damage Ignores resistances.
|
||||
/// </summary>
|
||||
[JsonPropertyName("damage")]
|
||||
[JsonProperty("damage")]
|
||||
[DataField("damage", required: true)]
|
||||
public DamageSpecifier Damage = default!;
|
||||
|
||||
@@ -25,12 +25,12 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
/// Should this effect scale the damage by the amount of chemical in the solution?
|
||||
/// Useful for touch reactions, like styptic powder or acid.
|
||||
/// </summary>
|
||||
[JsonPropertyName("scaleByQuantity")]
|
||||
[JsonProperty("scaleByQuantity")]
|
||||
[DataField("scaleByQuantity")]
|
||||
public bool ScaleByQuantity = false;
|
||||
|
||||
[DataField("ignoreResistances")]
|
||||
[JsonPropertyName("ignoreResistances")]
|
||||
[JsonProperty("ignoreResistances")]
|
||||
public bool IgnoreResistances = true;
|
||||
|
||||
public override void Effect(ReagentEffectArgs args)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using Content.Server.Administration.Logs.Converters;
|
||||
using Content.Shared.Chemistry.Reaction;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Newtonsoft.Json;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -35,6 +35,6 @@ public class ChemistryJsonGenerator
|
||||
}
|
||||
}
|
||||
|
||||
file.Write(JsonSerializer.Serialize(prototypes, new JsonSerializerOptions { WriteIndented = true }));
|
||||
file.Write(JsonConvert.SerializeObject(prototypes, Formatting.Indented, new FixedPointJsonConverter()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using Content.Shared.Chemistry.Reaction;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Newtonsoft.Json;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ReactionJsonGenerator
|
||||
.Select(x => new ReactionEntry(x))
|
||||
.ToDictionary(x => x.Id, x => x);
|
||||
|
||||
file.Write(JsonSerializer.Serialize(reactions, new JsonSerializerOptions { WriteIndented = true, IncludeFields = true }));
|
||||
file.Write(JsonConvert.SerializeObject(reactions, Formatting.Indented, new FixedPointJsonConverter()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
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 Newtonsoft.Json;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
@@ -11,28 +11,28 @@ namespace Content.Server.GuideGenerator;
|
||||
|
||||
public class ReagentEntry
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; }
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; }
|
||||
|
||||
[JsonPropertyName("group")]
|
||||
[JsonProperty("group")]
|
||||
public string Group { get; }
|
||||
|
||||
[JsonPropertyName("desc")]
|
||||
[JsonProperty("desc")]
|
||||
public string Description { get; }
|
||||
|
||||
[JsonPropertyName("physicalDesc")]
|
||||
[JsonProperty("physicalDesc")]
|
||||
public string PhysicalDescription { get; }
|
||||
|
||||
[JsonPropertyName("color")]
|
||||
[JsonProperty("color")]
|
||||
public string SubstanceColor { get; }
|
||||
|
||||
[JsonPropertyName("recipes")]
|
||||
[JsonProperty("recipes")]
|
||||
public List<string> Recipes { get; } = new();
|
||||
|
||||
[JsonPropertyName("metabolisms")]
|
||||
[JsonProperty("metabolisms")]
|
||||
public Dictionary<string, ReagentEffectsEntry>? Metabolisms { get; }
|
||||
|
||||
public ReagentEntry(ReagentPrototype proto)
|
||||
@@ -49,19 +49,19 @@ public class ReagentEntry
|
||||
|
||||
public class ReactionEntry
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; }
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; }
|
||||
|
||||
[JsonPropertyName("reactants")]
|
||||
[JsonProperty("reactants")]
|
||||
public Dictionary<string, ReactantEntry> Reactants { get; }
|
||||
|
||||
[JsonPropertyName("products")]
|
||||
[JsonProperty("products")]
|
||||
public Dictionary<string, float> Products { get; }
|
||||
|
||||
[JsonPropertyName("effects")]
|
||||
[JsonProperty("effects")]
|
||||
public List<ReagentEffect> Effects { get; }
|
||||
|
||||
public ReactionEntry(ReactionPrototype proto)
|
||||
@@ -82,10 +82,10 @@ public class ReactionEntry
|
||||
|
||||
public class ReactantEntry
|
||||
{
|
||||
[JsonPropertyName("amount")]
|
||||
[JsonProperty("amount")]
|
||||
public float Amount { get; }
|
||||
|
||||
[JsonPropertyName("catalyst")]
|
||||
[JsonProperty("catalyst")]
|
||||
public bool Catalyst { get; }
|
||||
|
||||
public ReactantEntry(float amnt, bool cata)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
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.Database;
|
||||
using Content.Shared.FixedPoint;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Random;
|
||||
@@ -22,18 +22,18 @@ namespace Content.Shared.Chemistry.Reagent
|
||||
[MeansImplicitUse]
|
||||
public abstract class ReagentEffect
|
||||
{
|
||||
[JsonPropertyName("id")] public string _id => this.GetType().Name;
|
||||
[JsonProperty("id")] private string _id => this.GetType().Name;
|
||||
/// <summary>
|
||||
/// The list of conditions required for the effect to activate. Not required.
|
||||
/// </summary>
|
||||
[JsonPropertyName("conditions")]
|
||||
[JsonProperty("conditions")]
|
||||
[DataField("conditions")]
|
||||
public ReagentEffectCondition[]? Conditions;
|
||||
|
||||
/// <summary>
|
||||
/// What's the chance, from 0 to 1, that this effect will occur?
|
||||
/// </summary>
|
||||
[JsonPropertyName("probability")]
|
||||
[JsonProperty("probability")]
|
||||
[DataField("probability")]
|
||||
public float Probability = 1.0f;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Content.Shared.Chemistry.Reagent
|
||||
[MeansImplicitUse]
|
||||
public abstract class ReagentEffectCondition
|
||||
{
|
||||
[JsonPropertyName("id")] private string _id => this.GetType().Name;
|
||||
[JsonProperty("id")] private string _id => this.GetType().Name;
|
||||
|
||||
public abstract bool Condition(ReagentEffectArgs args);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
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.Database;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Newtonsoft.Json;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
@@ -148,14 +148,14 @@ namespace Content.Shared.Chemistry.Reagent
|
||||
/// <summary>
|
||||
/// Amount of reagent to metabolize, per metabolism cycle.
|
||||
/// </summary>
|
||||
[JsonPropertyName("rate")]
|
||||
[JsonProperty("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")]
|
||||
[JsonProperty("effects")]
|
||||
[DataField("effects", required: true)]
|
||||
public ReagentEffect[] Effects = default!;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ using Robust.Shared.ViewVariables;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Content.Shared.Damage
|
||||
{
|
||||
@@ -24,11 +24,11 @@ namespace Content.Shared.Damage
|
||||
[DataDefinition]
|
||||
public class DamageSpecifier
|
||||
{
|
||||
[JsonPropertyName("types")]
|
||||
[JsonProperty("types")]
|
||||
[DataField("types", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, DamageTypePrototype>))]
|
||||
private readonly Dictionary<string,FixedPoint2>? _damageTypeDictionary;
|
||||
|
||||
[JsonPropertyName("groups")]
|
||||
[JsonProperty("groups")]
|
||||
[DataField("groups", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, DamageGroupPrototype>))]
|
||||
private readonly Dictionary<string, FixedPoint2>? _damageGroupDictionary;
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.FixedPoint
|
||||
@@ -12,7 +11,6 @@ namespace Content.Shared.FixedPoint
|
||||
/// To enforce this level of precision, floats are shifted by 2 decimal points, rounded, and converted to an int.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[JsonConverter(typeof(FixedPointJsonConverter))]
|
||||
public struct FixedPoint2 : ISelfSerialize, IComparable<FixedPoint2>, IEquatable<FixedPoint2>, IFormattable
|
||||
{
|
||||
private int _value;
|
||||
@@ -297,16 +295,17 @@ namespace Content.Shared.FixedPoint
|
||||
|
||||
public class FixedPointJsonConverter : JsonConverter<FixedPoint2>
|
||||
{
|
||||
public override void Write(Utf8JsonWriter writer, FixedPoint2 value, JsonSerializerOptions options)
|
||||
public override void WriteJson(JsonWriter writer, FixedPoint2 value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WriteNumberValue(value.Float());
|
||||
writer.WriteValue(value.Float());
|
||||
}
|
||||
|
||||
public override FixedPoint2 Read(ref Utf8JsonReader reader, Type objectType, JsonSerializerOptions options)
|
||||
public override FixedPoint2 ReadJson(JsonReader reader, Type objectType, FixedPoint2 existingValue, bool hasExistingValue,
|
||||
JsonSerializer serializer)
|
||||
{
|
||||
// Throwing a NotSupportedException here allows the error
|
||||
// message to provide path information.
|
||||
throw new NotSupportedException();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override bool CanRead => false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user