| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- 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.EntityEffects;
- using Robust.Shared.Prototypes;
- namespace Content.Server.GuideGenerator;
- public sealed class ReagentEntry
- {
- [JsonPropertyName("id")]
- public string Id { get; }
- [JsonPropertyName("name")]
- public string Name { get; }
- [JsonPropertyName("group")]
- public string Group { get; }
- [JsonPropertyName("desc")]
- public string Description { get; }
- [JsonPropertyName("physicalDesc")]
- public string PhysicalDescription { get; }
- [JsonPropertyName("color")]
- public string SubstanceColor { get; }
- [JsonPropertyName("recipes")]
- public List<string> Recipes { get; } = new();
- [JsonPropertyName("metabolisms")]
- public Dictionary<string, ReagentEffectsEntry>? Metabolisms { get; }
- public ReagentEntry(ReagentPrototype proto)
- {
- Id = proto.ID;
- Name = proto.LocalizedName;
- Group = proto.Group;
- Description = proto.LocalizedDescription;
- PhysicalDescription = proto.LocalizedPhysicalDescription;
- SubstanceColor = proto.SubstanceColor.ToHex();
- Metabolisms = proto.Metabolisms?.ToDictionary(x => x.Key.Id, x => x.Value);
- }
- }
- public sealed class ReactionEntry
- {
- [JsonPropertyName("id")]
- public string Id { get; }
- [JsonPropertyName("name")]
- public string Name { get; }
- [JsonPropertyName("reactants")]
- public Dictionary<string, ReactantEntry> Reactants { get; }
- [JsonPropertyName("products")]
- public Dictionary<string, float> Products { get; }
- [JsonPropertyName("effects")]
- public List<EntityEffect> Effects { get; }
- public ReactionEntry(ReactionPrototype proto)
- {
- Id = proto.ID;
- Name = proto.Name;
- Reactants =
- proto.Reactants
- .Select(x => KeyValuePair.Create(x.Key, new ReactantEntry(x.Value.Amount.Float(), x.Value.Catalyst)))
- .ToDictionary(x => x.Key, x => x.Value);
- Products =
- proto.Products
- .Select(x => KeyValuePair.Create(x.Key, x.Value.Float()))
- .ToDictionary(x => x.Key, x => x.Value);
- Effects = proto.Effects;
- }
- }
- public sealed class ReactantEntry
- {
- [JsonPropertyName("amount")]
- public float Amount { get; }
- [JsonPropertyName("catalyst")]
- public bool Catalyst { get; }
- public ReactantEntry(float amnt, bool cata)
- {
- Amount = amnt;
- Catalyst = cata;
- }
- }
|