From fdfe0949ab45e0b326f12c6532d1330d8f57b92d Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Wed, 21 Dec 2022 16:28:31 +1100 Subject: [PATCH] Hotfix generic visualizers (#3602) --- .../EntitySystems/GenericVisualizerSystem.cs | 4 +++- .../GameObjects/Systems/SharedAppearanceSystem.cs | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Robust.Client/GameObjects/EntitySystems/GenericVisualizerSystem.cs b/Robust.Client/GameObjects/EntitySystems/GenericVisualizerSystem.cs index d4182c1b1..3e7dbaac5 100644 --- a/Robust.Client/GameObjects/EntitySystems/GenericVisualizerSystem.cs +++ b/Robust.Client/GameObjects/EntitySystems/GenericVisualizerSystem.cs @@ -1,3 +1,4 @@ +using System; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Reflection; @@ -19,9 +20,10 @@ public sealed class GenericVisualizerSystem : VisualizerSystem(uid, appearanceKey, out var appearanceValue, args.Component)) + if (!_appearanceSys.TryGetData(uid, appearanceKey, out object? obj, args.Component)) continue; + var appearanceValue = obj.ToString(); if (string.IsNullOrEmpty(appearanceValue)) continue; diff --git a/Robust.Shared/GameObjects/Systems/SharedAppearanceSystem.cs b/Robust.Shared/GameObjects/Systems/SharedAppearanceSystem.cs index e61da98ac..42a9b425d 100644 --- a/Robust.Shared/GameObjects/Systems/SharedAppearanceSystem.cs +++ b/Robust.Shared/GameObjects/Systems/SharedAppearanceSystem.cs @@ -65,6 +65,17 @@ public abstract class SharedAppearanceSystem : EntitySystem value = default!; return false; } + + public bool TryGetData(EntityUid uid, Enum key, [NotNullWhen(true)] out object? value, AppearanceComponent? component = null) + { + if (!Resolve(uid, ref component)) + { + value = null; + return false; + } + + return component.AppearanceData.TryGetValue(key, out value); + } } [Serializable, NetSerializable]