json generator alternator and vibrator (#718)
* json generator alternator and vibrator * каким хуем ты не закоммитился уебан
This commit is contained in:
@@ -7,7 +7,7 @@ using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.GuideGenerator;
|
||||
|
||||
public sealed class ReactionJsonGenerator
|
||||
public sealed partial class ReactionJsonGenerator
|
||||
{
|
||||
public static void PublishJson(StreamWriter file)
|
||||
{
|
||||
@@ -19,13 +19,16 @@ public sealed class ReactionJsonGenerator
|
||||
.Select(x => new ReactionEntry(x))
|
||||
.ToDictionary(x => x.Id, x => x);
|
||||
|
||||
if (reactions is not null) AddMixingCategories(reactions, prototype);
|
||||
|
||||
var serializeOptions = new JsonSerializerOptions
|
||||
{
|
||||
WriteIndented = true,
|
||||
Converters =
|
||||
{
|
||||
new UniversalJsonConverter<ReagentEffect>(),
|
||||
}
|
||||
},
|
||||
NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals
|
||||
};
|
||||
|
||||
file.Write(JsonSerializer.Serialize(reactions, serializeOptions));
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Shared.Body.Prototypes;
|
||||
using Content.Server._White.GuideGenerator;
|
||||
using Content.Shared.Chemistry.Reaction;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.GuideGenerator;
|
||||
|
||||
@@ -31,8 +29,11 @@ public sealed class ReagentEntry
|
||||
[JsonPropertyName("recipes")]
|
||||
public List<string> Recipes { get; } = new();
|
||||
|
||||
[JsonPropertyName("textColor")]
|
||||
public string TextColor { get; }
|
||||
|
||||
[JsonPropertyName("metabolisms")]
|
||||
public Dictionary<string, ReagentEffectsEntry>? Metabolisms { get; }
|
||||
public Dictionary<string, _White.GuideGenerator.ReagentEffectsEntry>? Metabolisms { get; }
|
||||
|
||||
public ReagentEntry(ReagentPrototype proto)
|
||||
{
|
||||
@@ -42,7 +43,13 @@ public sealed class ReagentEntry
|
||||
Description = proto.LocalizedDescription;
|
||||
PhysicalDescription = proto.LocalizedPhysicalDescription;
|
||||
SubstanceColor = proto.SubstanceColor.ToHex();
|
||||
Metabolisms = proto.Metabolisms?.ToDictionary(x => x.Key.Id, x => x.Value);
|
||||
var r = proto.SubstanceColor.R;
|
||||
var g = proto.SubstanceColor.G;
|
||||
var b = proto.SubstanceColor.B;
|
||||
TextColor = (0.2126f * r + 0.7152f * g + 0.0722f * b > 0.5
|
||||
? Color.Black
|
||||
: Color.White).ToHex();
|
||||
Metabolisms = proto.Metabolisms?.ToDictionary(x => x.Key.Id, x => new _White.GuideGenerator.ReagentEffectsEntry(x.Value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +67,18 @@ public sealed class ReactionEntry
|
||||
[JsonPropertyName("products")]
|
||||
public Dictionary<string, float> Products { get; }
|
||||
|
||||
[JsonPropertyName("mixingCategories")]
|
||||
public List<MixingCategoryEntry> MixingCategories { get; } = new();
|
||||
[JsonPropertyName("minTemp")]
|
||||
public float MinTemp { get; }
|
||||
[JsonPropertyName("maxTemp")]
|
||||
public float MaxTemp { get; }
|
||||
[JsonPropertyName("hasMax")]
|
||||
public bool HasMax { get; }
|
||||
|
||||
[JsonPropertyName("effects")]
|
||||
public List<ReagentEffectEntry> ExportEffects { get; } = new();
|
||||
[JsonIgnore]
|
||||
public List<ReagentEffect> Effects { get; }
|
||||
|
||||
public ReactionEntry(ReactionPrototype proto)
|
||||
@@ -76,6 +94,11 @@ public sealed class ReactionEntry
|
||||
.Select(x => KeyValuePair.Create(x.Key, x.Value.Float()))
|
||||
.ToDictionary(x => x.Key, x => x.Value);
|
||||
Effects = proto.Effects;
|
||||
|
||||
ExportEffects = proto.Effects.Select(x => new ReagentEffectEntry(x)).ToList();
|
||||
MinTemp = proto.MinimumTemperature;
|
||||
MaxTemp = proto.MaximumTemperature;
|
||||
HasMax = !float.IsPositiveInfinity(MaxTemp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user