tModLoader v0.11.8.9
A mod to make and play Terraria mods
Terraria.ModLoader.SurfaceBgStyleLoader Class Reference
+ Collaboration diagram for Terraria.ModLoader.SurfaceBgStyleLoader:

Static Public Member Functions

static void ChooseStyle (ref int style)
 
static void DrawCloseBackground (int style)
 
static void DrawFarTexture ()
 
static void DrawMiddleTexture ()
 
static ModSurfaceBgStyle GetSurfaceBgStyle (int style)
 Returns the ModSurfaceBgStyle object with the given ID. More...
 
static void ModifyFarFades (int style, float[] fades, float transitionSpeed)
 

Static Public Attributes

const int vanillaSurfaceBgStyleCount = 10
 

Static Private Attributes

static int nextSurfaceBgStyle = vanillaSurfaceBgStyleCount
 

Detailed Description

Definition at line 69 of file BackgroundStyleLoaders.cs.

Member Function Documentation

◆ ChooseStyle()

static void Terraria.ModLoader.SurfaceBgStyleLoader.ChooseStyle ( ref int  style)
static

Definition at line 101 of file BackgroundStyleLoaders.cs.

101 {
102 if (!GlobalBgStyleLoader.loaded) {
103 return;
104 }
105 foreach (var surfaceBgStyle in surfaceBgStyles) {
106 if (surfaceBgStyle.ChooseBgStyle()) {
107 style = surfaceBgStyle.Slot;
108 }
109 }
110 foreach (var hook in GlobalBgStyleLoader.HookChooseSurfaceBgStyle) {
111 hook(ref style);
112 }
113 }

◆ DrawCloseBackground()

static void Terraria.ModLoader.SurfaceBgStyleLoader.DrawCloseBackground ( int  style)
static

Definition at line 181 of file BackgroundStyleLoaders.cs.

181 {
182 if (!GlobalBgStyleLoader.loaded) {
183 return;
184 }
185 if (Main.bgAlpha[style] <= 0f) {
186 return;
187 }
188 var surfaceBgStyle = GetSurfaceBgStyle(style);
189 if (surfaceBgStyle != null && surfaceBgStyle.PreDrawCloseBackground(Main.spriteBatch)) {
190 Main.bgScale = 1.25f;
191 Main.instance.bgParallax = 0.37;
192 float a = 1800.0f;
193 float b = 1750.0f;
194 int textureSlot = surfaceBgStyle.ChooseCloseTexture(ref Main.bgScale, ref Main.instance.bgParallax, ref a, ref b);
195 if (textureSlot >= 0 && textureSlot < Main.backgroundTexture.Length) {
196 //Custom: bgScale, textureslot, patallaz, these 2 numbers...., Top and Start?
197 Main.instance.LoadBackground(textureSlot);
198 Main.bgScale *= 2f;
199 Main.bgW = (int)((float)Main.backgroundWidth[textureSlot] * Main.bgScale);
200 SkyManager.Instance.DrawToDepth(Main.spriteBatch, 1f / (float)Main.instance.bgParallax);
201 Main.instance.bgStart = (int)(-Math.IEEERemainder(Main.screenPosition.X * Main.instance.bgParallax, Main.bgW) - (Main.bgW / 2));
202 Main.instance.bgTop = (int)((-Main.screenPosition.Y + Main.instance.screenOff / 2f) / (Main.worldSurface * 16.0) * a + b) + (int)Main.instance.scAdj;
203 if (Main.gameMenu) {
204 Main.instance.bgTop = 320;
205 }
206 Main.instance.bgLoops = Main.screenWidth / Main.bgW + 2;
207 if ((double)Main.screenPosition.Y < Main.worldSurface * 16.0 + 16.0) {
208 for (int k = 0; k < Main.instance.bgLoops; k++) {
209 Main.spriteBatch.Draw(Main.backgroundTexture[textureSlot],
210 new Vector2((Main.instance.bgStart + Main.bgW * k), Main.instance.bgTop),
211 new Rectangle(0, 0, Main.backgroundWidth[textureSlot], Main.backgroundHeight[textureSlot]),
212 Main.backColor, 0f, default(Vector2), Main.bgScale, SpriteEffects.None, 0f);
213 }
214 }
215 }
216 }
217 }
static ModSurfaceBgStyle GetSurfaceBgStyle(int style)
Returns the ModSurfaceBgStyle object with the given ID.

References Terraria.ModLoader.SurfaceBgStyleLoader.GetSurfaceBgStyle().

+ Here is the call graph for this function:

◆ DrawFarTexture()

static void Terraria.ModLoader.SurfaceBgStyleLoader.DrawFarTexture ( )
static

Definition at line 128 of file BackgroundStyleLoaders.cs.

128 {
129 if (!GlobalBgStyleLoader.loaded) {
130 return;
131 }
132 // TODO: Causes background to flicker during load because Main.bgAlpha2 is resized after surfaceBgStyles is added to in AutoLoad.
133 foreach (var style in surfaceBgStyles) {
134 int slot = style.Slot;
135 Main.backColor = Main.trueBackColor;
136 Main.backColor.R = (byte)(Main.backColor.R * Main.bgAlpha2[slot]);
137 Main.backColor.G = (byte)(Main.backColor.G * Main.bgAlpha2[slot]);
138 Main.backColor.B = (byte)(Main.backColor.B * Main.bgAlpha2[slot]);
139 Main.backColor.A = (byte)(Main.backColor.A * Main.bgAlpha2[slot]);
140 if (Main.bgAlpha2[slot] > 0f) {
141 int textureSlot = style.ChooseFarTexture();
142 if (textureSlot >= 0 && textureSlot < Main.backgroundTexture.Length) {
143 Main.instance.LoadBackground(textureSlot);
144 for (int k = 0; k < Main.instance.bgLoops; k++) {
145 Main.spriteBatch.Draw(Main.backgroundTexture[textureSlot],
146 new Vector2(Main.instance.bgStart + Main.bgW * k, Main.instance.bgTop),
147 new Rectangle(0, 0, Main.backgroundWidth[textureSlot], Main.backgroundHeight[textureSlot]),
148 Main.backColor, 0f, default(Vector2), Main.bgScale, SpriteEffects.None, 0f);
149 }
150 }
151 }
152 }
153 }

◆ DrawMiddleTexture()

static void Terraria.ModLoader.SurfaceBgStyleLoader.DrawMiddleTexture ( )
static

Definition at line 155 of file BackgroundStyleLoaders.cs.

155 {
156 if (!GlobalBgStyleLoader.loaded) {
157 return;
158 }
159 foreach (var style in surfaceBgStyles) {
160 int slot = style.Slot;
161 Main.backColor = Main.trueBackColor;
162 Main.backColor.R = (byte)(Main.backColor.R * Main.bgAlpha2[slot]);
163 Main.backColor.G = (byte)(Main.backColor.G * Main.bgAlpha2[slot]);
164 Main.backColor.B = (byte)(Main.backColor.B * Main.bgAlpha2[slot]);
165 Main.backColor.A = (byte)(Main.backColor.A * Main.bgAlpha2[slot]);
166 if (Main.bgAlpha2[slot] > 0f) {
167 int textureSlot = style.ChooseMiddleTexture();
168 if (textureSlot >= 0 && textureSlot < Main.backgroundTexture.Length) {
169 Main.instance.LoadBackground(textureSlot);
170 for (int k = 0; k < Main.instance.bgLoops; k++) {
171 Main.spriteBatch.Draw(Main.backgroundTexture[textureSlot],
172 new Vector2(Main.instance.bgStart + Main.bgW * k, Main.instance.bgTop),
173 new Rectangle(0, 0, Main.backgroundWidth[textureSlot], Main.backgroundHeight[textureSlot]),
174 Main.backColor, 0f, default(Vector2), Main.bgScale, SpriteEffects.None, 0f);
175 }
176 }
177 }
178 }
179 }

◆ GetSurfaceBgStyle()

static ModSurfaceBgStyle Terraria.ModLoader.SurfaceBgStyleLoader.GetSurfaceBgStyle ( int  style)
static

◆ ModifyFarFades()

static void Terraria.ModLoader.SurfaceBgStyleLoader.ModifyFarFades ( int  style,
float[]  fades,
float  transitionSpeed 
)
static

Definition at line 115 of file BackgroundStyleLoaders.cs.

115 {
116 if (!GlobalBgStyleLoader.loaded) {
117 return;
118 }
119 var surfaceBgStyle = GetSurfaceBgStyle(style);
120 if (surfaceBgStyle != null) {
121 surfaceBgStyle.ModifyFarFades(fades, transitionSpeed);
122 }
123 foreach (var hook in GlobalBgStyleLoader.HookModifyFarSurfaceFades) {
124 hook(style, fades, transitionSpeed);
125 }
126 }

References Terraria.ModLoader.SurfaceBgStyleLoader.GetSurfaceBgStyle().

+ Here is the call graph for this function:

Member Data Documentation

◆ nextSurfaceBgStyle

int Terraria.ModLoader.SurfaceBgStyleLoader.nextSurfaceBgStyle = vanillaSurfaceBgStyleCount
staticprivate

◆ vanillaSurfaceBgStyleCount

const int Terraria.ModLoader.SurfaceBgStyleLoader.vanillaSurfaceBgStyleCount = 10
static