From 5cc32cdca45975863f759243bf48ce3fd4eac188 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Sun, 1 Sep 2024 00:32:05 +0900 Subject: [PATCH] Cache the BG Texture ID --- Backgrounds/AstralUndergroundBGStyle.cs | 36 +++++++++++++++++++++++-- Backgrounds/SunkenSeaBGStyle.cs | 25 +++++++++++++---- 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/Backgrounds/AstralUndergroundBGStyle.cs b/Backgrounds/AstralUndergroundBGStyle.cs index f3c9455798..20cc1d0d5b 100644 --- a/Backgrounds/AstralUndergroundBGStyle.cs +++ b/Backgrounds/AstralUndergroundBGStyle.cs @@ -5,10 +5,42 @@ namespace CalamityMod.Backgrounds { public class AstralUndergroundBGStyle : ModUndergroundBackgroundStyle { + private int AUBG0; + private int AUBG1; + private int AUBG2; + private int AUBG3; + + private int AUBG4_0; + private int AUBG4_1; + private int AUBG4_2; + + public override void SetStaticDefaults() + { + if (Main.dedServ) + return; + + AUBG0 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralUG0"); + AUBG1 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralUG1"); + AUBG2 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralUG2"); + AUBG3 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralUG3"); + + AUBG4_0 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralUG4_0"); + AUBG4_1 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralUG4_1"); + AUBG4_2 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralUG4_2"); + } + public override void FillTextureArray(int[] textureSlots) { - for (int i = 0; i <= 4; i++) - textureSlots[i] = BackgroundTextureLoader.GetBackgroundSlot(i == 4 ? "CalamityMod/Backgrounds/AstralUG" + i.ToString() + "_" + Main.hellBackStyle : "CalamityMod/Backgrounds/AstralUG" + i.ToString()); + textureSlots[0] = AUBG0; + textureSlots[1] = AUBG1; + textureSlots[2] = AUBG2; + textureSlots[3] = AUBG3; + textureSlots[4] = Main.hellBackStyle switch + { + 0 => AUBG4_0, + 1 => AUBG4_1, + _ => AUBG4_2 + }; } } } diff --git a/Backgrounds/SunkenSeaBGStyle.cs b/Backgrounds/SunkenSeaBGStyle.cs index cfd743dd4f..11b86c7d67 100644 --- a/Backgrounds/SunkenSeaBGStyle.cs +++ b/Backgrounds/SunkenSeaBGStyle.cs @@ -5,13 +5,28 @@ namespace CalamityMod.Backgrounds { public class SunkenSeaBGStyle : ModUndergroundBackgroundStyle { + private int SSBG0; + private int SSBG1; + private int SSBG2; + private int SSBG3; + + public override void SetStaticDefaults() + { + if (Main.dedServ) + return; + + SSBG0 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/SunkenSeaBG0"); + SSBG1 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/SunkenSeaBG1"); + SSBG2 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/SunkenSeaBG2"); + SSBG3 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/SunkenSeaBG3"); + } + public override void FillTextureArray(int[] textureSlots) { - for (int i = 0; i <= 3; i++) - { - textureSlots[i] = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); - //textureSlots[i] = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/SunkenSeaBG" + i.ToString()); - } + textureSlots[0] = SSBG0; + textureSlots[1] = SSBG1; + textureSlots[2] = SSBG2; + textureSlots[3] = SSBG3; } } }