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:
@@ -626,5 +626,12 @@ namespace Content.Shared.CCVar
|
||||
/// </summary>
|
||||
public static readonly CVarDef<float> RulesWaitTime =
|
||||
CVarDef.Create("rules.time", 45f, CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/*
|
||||
* Autogeneration
|
||||
*/
|
||||
|
||||
public static readonly CVarDef<string> DestinationFile =
|
||||
CVarDef.Create("autogen.destination_file", "", CVar.SERVER | CVar.SERVERONLY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
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;
|
||||
@@ -20,24 +22,29 @@ namespace Content.Shared.Chemistry.Reagent
|
||||
[MeansImplicitUse]
|
||||
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;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using System.Text.Json.Serialization;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
@@ -9,6 +9,8 @@ namespace Content.Shared.Chemistry.Reagent
|
||||
[MeansImplicitUse]
|
||||
public abstract class ReagentEffectCondition
|
||||
{
|
||||
[JsonPropertyName("id")] private protected string _id => this.GetType().Name;
|
||||
|
||||
public abstract bool Condition(ReagentEffectArgs args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -30,7 +31,10 @@ namespace Content.Shared.Chemistry.Reagent
|
||||
[DataField("name")]
|
||||
public string Name { get; } = string.Empty;
|
||||
|
||||
[DataField("parent", customTypeSerializer:typeof(PrototypeIdSerializer<ReagentPrototype>))]
|
||||
[DataField("group")]
|
||||
public string Group { get; } = "Unknown";
|
||||
|
||||
[DataField("parent", customTypeSerializer: typeof(PrototypeIdSerializer<ReagentPrototype>))]
|
||||
public string? Parent { get; private set; }
|
||||
|
||||
[NeverPushInheritance]
|
||||
@@ -65,7 +69,7 @@ namespace Content.Shared.Chemistry.Reagent
|
||||
[DataField("metabolisms", serverOnly: true, customTypeSerializer: typeof(PrototypeIdDictionarySerializer<ReagentEffectsEntry, MetabolismGroupPrototype>))]
|
||||
public Dictionary<string, ReagentEffectsEntry>? Metabolisms = null;
|
||||
|
||||
[DataField("reactiveEffects", serverOnly: true, customTypeSerializer:typeof(PrototypeIdDictionarySerializer<ReactiveReagentEffectEntry, ReactiveGroupPrototype>))]
|
||||
[DataField("reactiveEffects", serverOnly: true, customTypeSerializer: typeof(PrototypeIdDictionarySerializer<ReactiveReagentEffectEntry, ReactiveGroupPrototype>))]
|
||||
public Dictionary<string, ReactiveReagentEffectEntry>? ReactiveEffects = null;
|
||||
|
||||
[DataField("tileReactions", serverOnly: true)]
|
||||
@@ -144,12 +148,14 @@ namespace Content.Shared.Chemistry.Reagent
|
||||
/// <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!;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ using Robust.Shared.ViewVariables;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using Content.Shared.FixedPoint;
|
||||
|
||||
namespace Content.Shared.Damage
|
||||
@@ -23,15 +24,18 @@ namespace Content.Shared.Damage
|
||||
[DataDefinition]
|
||||
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 +47,7 @@ namespace Content.Shared.Damage
|
||||
}
|
||||
set => _damageDict = value;
|
||||
}
|
||||
[JsonIgnore]
|
||||
private Dictionary<string, FixedPoint2>? _damageDict;
|
||||
|
||||
/// <summary>
|
||||
@@ -53,11 +58,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
|
||||
|
||||
@@ -264,11 +264,11 @@ namespace Content.Shared.FixedPoint
|
||||
|
||||
public readonly int CompareTo(FixedPoint2 other)
|
||||
{
|
||||
if(other._value > _value)
|
||||
if (other._value > _value)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if(other._value < _value)
|
||||
if (other._value < _value)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user