From 97dddde296b2e472b383c7e9335b186d5256921f Mon Sep 17 00:00:00 2001 From: wixoaGit Date: Sat, 25 Jan 2025 02:32:10 -0500 Subject: [PATCH] Separate overlay-resolves and load-callbacks into different passes --- OpenDreamClient/Rendering/ClientAppearanceSystem.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/OpenDreamClient/Rendering/ClientAppearanceSystem.cs b/OpenDreamClient/Rendering/ClientAppearanceSystem.cs index fd02bc198a..0786c1c4e8 100644 --- a/OpenDreamClient/Rendering/ClientAppearanceSystem.cs +++ b/OpenDreamClient/Rendering/ClientAppearanceSystem.cs @@ -45,9 +45,15 @@ public void SetAllAppearances(Dictionary appearances) //need to do this because all overlays can't be resolved until the whole appearance table is populated foreach(KeyValuePair pair in _appearances) { pair.Value.ResolveOverlays(this); - if (_appearanceLoadCallbacks.TryGetValue(pair.Key, out var callbacks)) { - foreach (var callback in callbacks) callback(pair.Value); - } + } + + // Callbacks called in another pass to ensure all appearances are initialized first + foreach (var callbackPair in _appearanceLoadCallbacks) { + if (!_appearances.TryGetValue(callbackPair.Key, out var appearance)) + continue; + + foreach (var callback in callbackPair.Value) + callback(appearance); } }