diff --git a/OpenRA.Mods.Common/Traits/Modifiers/FrozenUnderFog.cs b/OpenRA.Mods.Common/Traits/Modifiers/FrozenUnderFog.cs index c211285bf9..adc068fb4f 100644 --- a/OpenRA.Mods.Common/Traits/Modifiers/FrozenUnderFog.cs +++ b/OpenRA.Mods.Common/Traits/Modifiers/FrozenUnderFog.cs @@ -35,11 +35,10 @@ namespace OpenRA.Mods.Common.Traits readonly bool startsRevealed; readonly PPos[] footprint; - readonly Lazy tooltip; - readonly Lazy health; - readonly Dictionary stateByPlayer = new Dictionary(); + ITooltip tooltip; + Health health; bool initialized; class FrozenState @@ -62,8 +61,6 @@ namespace OpenRA.Mods.Common.Traits startsRevealed = info.StartsRevealed && !init.Contains(); var footprintCells = FootprintUtils.Tiles(init.Self).ToList(); footprint = footprintCells.SelectMany(c => map.ProjectedCellsCovering(c.ToMPos(map))).ToArray(); - tooltip = Exts.Lazy(() => init.Self.TraitsImplementing().FirstOrDefault()); - health = Exts.Lazy(() => init.Self.TraitOrDefault()); } bool IsVisibleInner(Actor self, Player byPlayer) @@ -90,6 +87,13 @@ namespace OpenRA.Mods.Common.Traits return; VisibilityHash = 0; + + if (!initialized) + { + tooltip = self.TraitsImplementing().FirstOrDefault(); + health = self.TraitOrDefault(); + } + foreach (var player in self.World.Players) { FrozenActor frozenActor; @@ -116,16 +120,16 @@ namespace OpenRA.Mods.Common.Traits frozenActor.Owner = self.Owner; - if (health.Value != null) + if (health != null) { - frozenActor.HP = health.Value.HP; - frozenActor.DamageState = health.Value.DamageState; + frozenActor.HP = health.HP; + frozenActor.DamageState = health.DamageState; } - if (tooltip.Value != null) + if (tooltip != null) { - frozenActor.TooltipInfo = tooltip.Value.TooltipInfo; - frozenActor.TooltipOwner = tooltip.Value.Owner; + frozenActor.TooltipInfo = tooltip.TooltipInfo; + frozenActor.TooltipOwner = tooltip.Owner; } }