From 7df00c59cb54812a9c9e9d07104af207ede634fa Mon Sep 17 00:00:00 2001 From: +TEK Date: Fri, 22 Apr 2022 01:31:58 +0200 Subject: [PATCH] Fixed the GenerateSpriteCache function attempting to add sprites, backgrounddata and gameobjects without any textures --- UndertaleModTool/Editors/UndertaleRoomEditor.xaml.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/UndertaleModTool/Editors/UndertaleRoomEditor.xaml.cs b/UndertaleModTool/Editors/UndertaleRoomEditor.xaml.cs index 5f432e2c6..1bceb6329 100644 --- a/UndertaleModTool/Editors/UndertaleRoomEditor.xaml.cs +++ b/UndertaleModTool/Editors/UndertaleRoomEditor.xaml.cs @@ -1502,11 +1502,12 @@ public static void GenerateSpriteCache(UndertaleRoom room) else tiles.AddRange(layer.AssetsData.LegacyTiles); - allObjects.AddRange(layer.AssetsData.Sprites); + allObjects.AddRange(layer.AssetsData.Sprites.Where(s => s.Sprite?.Textures.Count > 0)); break; case LayerType.Background: - allObjects.Add(layer.BackgroundData); + if (layer.BackgroundData.Sprite?.Textures.Count > 0) + allObjects.Add(layer.BackgroundData); break; case LayerType.Instances: @@ -1520,7 +1521,7 @@ public static void GenerateSpriteCache(UndertaleRoom room) tiles = room.Tiles.ToList(); allObjects.AddRange(room.Backgrounds); - allObjects.AddRange(room.GameObjects); + allObjects.AddRange(room.GameObjects.Where(g => g.ObjectDefinition?.Sprite?.Textures.Count > 0)); } tileTextures = tiles?.AsParallel()