Remove prototype caching from TransformableContainerComponent (#38988)

Remove prototype caching from TransformableContainer
This commit is contained in:
Tayrtahn
2025-07-14 17:03:41 -04:00
committed by GitHub
parent dac2537f9c
commit 2e6549a308
2 changed files with 9 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
using Content.Server.Animals.Systems;
using Content.Server.Chemistry.EntitySystems; using Content.Server.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reagent; using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Prototypes;
namespace Content.Server.Chemistry.Components; namespace Content.Server.Chemistry.Components;
@@ -19,19 +19,19 @@ public sealed partial class TransformableContainerComponent : Component
/// It will revert to this when emptied. /// It will revert to this when emptied.
/// /// It defaults to the description of the parent entity unless overwritten. /// /// It defaults to the description of the parent entity unless overwritten.
/// </summary> /// </summary>
[DataField("initialDescription")] [DataField]
public string? InitialDescription; public string? InitialDescription;
/// <summary> /// <summary>
/// This stores whatever primary reagent is currently in the container. /// This stores whatever primary reagent is currently in the container.
/// It is used to help determine if a transformation is needed on solution update. /// It is used to help determine if a transformation is needed on solution update.
/// </summary> /// </summary>
[DataField("currentReagent")] [DataField]
public ReagentPrototype? CurrentReagent; public ProtoId<ReagentPrototype>? CurrentReagent;
/// <summary> /// <summary>
/// This returns whether this container in a transformed or initial state. /// This returns whether this container in a transformed or initial state.
/// </summary> /// </summary>
/// [DataField]
[DataField("transformed")]
public bool Transformed; public bool Transformed;
} }

View File

@@ -45,8 +45,8 @@ public sealed class TransformableContainerSystem : EntitySystem
//the biggest reagent in the solution decides the appearance //the biggest reagent in the solution decides the appearance
var reagentId = solution.GetPrimaryReagentId(); var reagentId = solution.GetPrimaryReagentId();
//If biggest reagent didn't changed - don't change anything at all //If biggest reagent didn't change - don't change anything at all
if (entity.Comp.CurrentReagent != null && entity.Comp.CurrentReagent.ID == reagentId?.Prototype) if (entity.Comp.CurrentReagent != null && entity.Comp.CurrentReagent == reagentId?.Prototype)
{ {
return; return;
} }
@@ -66,7 +66,7 @@ public sealed class TransformableContainerSystem : EntitySystem
private void OnRefreshNameModifiers(Entity<TransformableContainerComponent> entity, ref RefreshNameModifiersEvent args) 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)); args.AddModifier("transformable-container-component-glass", priority: -1, ("reagent", currentReagent.LocalizedName));
} }