diff --git a/Content.Server/GuideGenerator/ReagentEntry.cs b/Content.Server/GuideGenerator/ReagentEntry.cs index 2e6b64797cd..0029df1de8e 100644 --- a/Content.Server/GuideGenerator/ReagentEntry.cs +++ b/Content.Server/GuideGenerator/ReagentEntry.cs @@ -1,9 +1,8 @@ using System.Linq; using System.Text.Json.Serialization; -using Content.Server.Body.Components; -using Content.Shared.Body.Prototypes; using Content.Shared.Chemistry.Reaction; using Content.Shared.Chemistry.Reagent; +using Content.Shared.FixedPoint; using Robust.Shared.Prototypes; namespace Content.Server.GuideGenerator; @@ -35,7 +34,7 @@ public sealed class ReagentEntry public List Recipes { get; } = new(); [JsonPropertyName("metabolisms")] - public Dictionary>? Metabolisms { get; } + public Dictionary? Metabolisms { get; } public ReagentEntry(ReagentPrototype proto) { @@ -53,7 +52,7 @@ public ReagentEntry(ReagentPrototype proto) ? Color.Black : Color.White).ToHex(); - Metabolisms = proto.Metabolisms?.ToDictionary(x => x.Key.Id, x => x.Value.Effects.Select(x => new ReagentEffectEntry(x)).ToList()); + Metabolisms = proto.Metabolisms?.ToDictionary(x => x.Key.Id, x => new ReagentEffectsEntry(x.Value)); } } @@ -66,7 +65,7 @@ public sealed class ReactionEntry public string Name { get; } [JsonPropertyName("reactants")] - public Dictionary Reactants { get; } + public Dictionary Reactants { get; } = new(); [JsonPropertyName("products")] public Dictionary Products { get; } @@ -84,15 +83,13 @@ public sealed class ReactionEntry public bool HasMax { get; } [JsonPropertyName("effects")] - public List ExportEffects { get; } + public List ExportEffects { get; } = new(); [JsonIgnore] public List Effects { get; } public ReactionEntry(ReactionPrototype proto) { - var protoMan = IoCManager.Resolve(); - Id = proto.ID; Name = TextTools.TextTools.CapitalizeString(proto.Name); // Corvax-Wiki Reactants = @@ -126,7 +123,6 @@ public ReactantEntry(float amnt, bool cata) Catalyst = cata; } } - public sealed class MixingCategoryEntry { [JsonPropertyName("name")] @@ -141,7 +137,21 @@ public MixingCategoryEntry(MixingCategoryPrototype proto) Id = proto.ID; } } +public sealed class ReagentEffectsEntry +{ + [JsonPropertyName("rate")] + public FixedPoint2 MetabolismRate { get; } = FixedPoint2.New(0.5f); + + [JsonPropertyName("effects")] + public List Effects { get; } = new(); + + public ReagentEffectsEntry(Content.Shared.Chemistry.Reagent.ReagentEffectsEntry proto) + { + MetabolismRate = proto.MetabolismRate; + Effects = proto.Effects.Select(x => new ReagentEffectEntry(x)).ToList(); + } +} public sealed class ReagentEffectEntry { [JsonPropertyName("id")] @@ -156,6 +166,24 @@ public ReagentEffectEntry(ReagentEffect proto) var entSys = IoCManager.Resolve(); Id = proto.GetType().Name; - Description = proto.GuidebookEffectDescription(prototype, entSys) ?? ""; + Description = GuidebookEffectDescriptionToWeb(proto.GuidebookEffectDescription(prototype, entSys) ?? ""); + } + + private string GuidebookEffectDescriptionToWeb(string guideBookText) + { + guideBookText = guideBookText.Replace("[", "<"); + guideBookText = guideBookText.Replace("]", ">"); + guideBookText = guideBookText.Replace("color", "span"); + + while (guideBookText.IndexOf("", first); + var replacementString = guideBookText.Substring(first, last - first); + var color = replacementString.Substring(1); + guideBookText = guideBookText.Replace(replacementString, String.Format(" style=\"color: {0};\"", color)); + } + + return guideBookText; } }