Make some prototypes use frozen collections (#22576)
* Make some prototypes use frozen collections * poke tests * Remove frozen dictionary enumeration (cherry picked from commit 8587c3778abdf94041a491b1ff6330fbe6746c03)
This commit is contained in:
parent
9a8b0a2d61
commit
3b8a4316fa
|
|
@ -156,10 +156,9 @@ namespace Content.Server.Body.Systems
|
|||
|
||||
foreach (var group in meta.MetabolismGroups)
|
||||
{
|
||||
if (!proto.Metabolisms.ContainsKey(group.Id))
|
||||
if (!proto.Metabolisms.TryGetValue(group.Id, out var entry))
|
||||
continue;
|
||||
|
||||
var entry = proto.Metabolisms[group.Id];
|
||||
var rate = entry.MetabolismRate * group.MetabolismRateModifier;
|
||||
|
||||
// Remove $rate, as long as there's enough reagent there to actually remove that much
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public sealed class DumpReagentGuideText : IConsoleCommand
|
|||
return;
|
||||
}
|
||||
|
||||
foreach (var (_, entry) in reagent.Metabolisms)
|
||||
foreach (var entry in reagent.Metabolisms.Values)
|
||||
{
|
||||
foreach (var effect in entry.Effects)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public sealed class ReagentEntry
|
|||
public List<string> Recipes { get; } = new();
|
||||
|
||||
[JsonPropertyName("metabolisms")]
|
||||
public Dictionary<ProtoId<MetabolismGroupPrototype>, ReagentEffectsEntry>? Metabolisms { get; }
|
||||
public Dictionary<string, ReagentEffectsEntry>? Metabolisms { get; }
|
||||
|
||||
public ReagentEntry(ReagentPrototype proto)
|
||||
{
|
||||
|
|
@ -42,7 +42,7 @@ public sealed class ReagentEntry
|
|||
Description = proto.LocalizedDescription;
|
||||
PhysicalDescription = proto.LocalizedPhysicalDescription;
|
||||
SubstanceColor = proto.SubstanceColor.ToHex();
|
||||
Metabolisms = proto.Metabolisms;
|
||||
Metabolisms = proto.Metabolisms?.ToDictionary(x => x.Key.Id, x => x.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public sealed class DrinkSystem : EntitySystem
|
|||
if (reagent.Metabolisms == null)
|
||||
continue;
|
||||
|
||||
foreach ((var _, var entry) in reagent.Metabolisms)
|
||||
foreach (var entry in reagent.Metabolisms.Values)
|
||||
{
|
||||
foreach (var effect in entry.Effects)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Linq;
|
||||
using System.Collections.Frozen;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Body.Prototypes;
|
||||
|
|
@ -14,7 +15,6 @@ using Robust.Shared.Random;
|
|||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Chemistry.Reagent
|
||||
|
|
@ -103,7 +103,7 @@ namespace Content.Shared.Chemistry.Reagent
|
|||
public float Viscosity;
|
||||
|
||||
[DataField(serverOnly: true)]
|
||||
public Dictionary<ProtoId<MetabolismGroupPrototype>, ReagentEffectsEntry>? Metabolisms;
|
||||
public FrozenDictionary<ProtoId<MetabolismGroupPrototype>, ReagentEffectsEntry>? Metabolisms;
|
||||
|
||||
[DataField(serverOnly: true)]
|
||||
public Dictionary<ProtoId<ReactiveGroupPrototype>, ReactiveReagentEffectEntry>? ReactiveEffects;
|
||||
|
|
|
|||
Loading…
Reference in New Issue