2 using System.Collections.Generic;
12 public const int vanillaBackgroundTextureCount = Main.maxBackgrounds;
13 private static int nextBackground = vanillaBackgroundTextureCount;
14 internal static IDictionary<string, int> backgrounds =
new Dictionary<string, int>();
16 internal static int ReserveBackgroundSlot() {
17 int reserve = nextBackground;
25 public static int GetBackgroundSlot(
string texture) => backgrounds.TryGetValue(texture, out
int slot) ? slot : -1;
27 internal static void ResizeAndFillArrays() {
28 Array.Resize(ref Main.backgroundTexture, nextBackground);
29 Array.Resize(ref Main.backgroundHeight, nextBackground);
30 Array.Resize(ref Main.backgroundWidth, nextBackground);
31 Array.Resize(ref Main.backgroundLoaded, nextBackground);
32 foreach (
string texture
in backgrounds.Keys) {
33 int slot = backgrounds[texture];
35 Main.backgroundWidth[slot] = Main.backgroundTexture[slot].Width;
36 Main.backgroundHeight[slot] = Main.backgroundTexture[slot].Height;
37 Main.backgroundLoaded[slot] =
true;
41 internal static void Unload() {
42 nextBackground = vanillaBackgroundTextureCount;
This is the class that keeps track of all modded background textures and their slots/IDs.
static Texture2D GetTexture(string name)
Gets the texture with the specified name. The name is in the format of "ModFolder/OtherFolders/FileNa...
Manages content added by mods. Liasons between mod content and Terraria's arrays and oversees the Loa...