]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Remove prototype caching from `TransformableContainerComponent` (#38988)
authorTayrtahn <tayrtahn@gmail.com>
Mon, 14 Jul 2025 21:03:41 +0000 (17:03 -0400)
committerGitHub <noreply@github.com>
Mon, 14 Jul 2025 21:03:41 +0000 (23:03 +0200)
Remove prototype caching from TransformableContainer

Content.Server/Chemistry/Components/TransformableContainerComponent.cs
Content.Server/Chemistry/EntitySystems/TransformableContainerSystem.cs

index db6c9c5397659de901c7cb42439895d21bd143b7..7dbf8e0d2a328c0e6277091be855668742036450 100644 (file)
@@ -1,6 +1,6 @@
-using Content.Server.Animals.Systems;
 using Content.Server.Chemistry.EntitySystems;
 using Content.Shared.Chemistry.Reagent;
+using Robust.Shared.Prototypes;
 
 namespace Content.Server.Chemistry.Components;
 
@@ -19,19 +19,19 @@ public sealed partial class TransformableContainerComponent : Component
     /// It will revert to this when emptied.
     ///     /// It defaults to the description of the parent entity unless overwritten.
     /// </summary>
-    [DataField("initialDescription")]
+    [DataField]
     public string? InitialDescription;
+
     /// <summary>
     /// This stores whatever primary reagent is currently in the container.
     /// It is used to help determine if a transformation is needed on solution update.
     /// </summary>
-    [DataField("currentReagent")]
-    public ReagentPrototype? CurrentReagent;
+    [DataField]
+    public ProtoId<ReagentPrototype>? CurrentReagent;
 
     /// <summary>
     /// This returns whether this container in a transformed or initial state.
     /// </summary>
-    ///
-    [DataField("transformed")]
+    [DataField]
     public bool Transformed;
 }
index 57875fc16a868f8c3161dccba286734cf6ddffc7..48d547d1e0c4d91af94b1d70f7eb107e72b1a727 100644 (file)
@@ -45,8 +45,8 @@ public sealed class TransformableContainerSystem : EntitySystem
         //the biggest reagent in the solution decides the appearance
         var reagentId = solution.GetPrimaryReagentId();
 
-        //If biggest reagent didn't changed - don't change anything at all
-        if (entity.Comp.CurrentReagent != null && entity.Comp.CurrentReagent.ID == reagentId?.Prototype)
+        //If biggest reagent didn't change - don't change anything at all
+        if (entity.Comp.CurrentReagent != null && entity.Comp.CurrentReagent == reagentId?.Prototype)
         {
             return;
         }
@@ -66,7 +66,7 @@ public sealed class TransformableContainerSystem : EntitySystem
 
     private void OnRefreshNameModifiers(Entity<TransformableContainerComponent> entity, ref RefreshNameModifiersEvent args)
     {
-        if (entity.Comp.CurrentReagent is { } currentReagent)
+        if (_prototypeManager.TryIndex(entity.Comp.CurrentReagent, out var currentReagent))
         {
             args.AddModifier("transformable-container-component-glass", priority: -1, ("reagent", currentReagent.LocalizedName));
         }