tModLoader v0.11.8.9
A mod to make and play Terraria mods
Terraria.ModLoader.ModSurfaceBgStyle Class Referenceabstract

Each background style determines in its own way how exactly the background is drawn. This class serves as a collection of functions for above-ground backgrounds. More...

Public Member Functions

virtual bool Autoload (ref string name)
 Allows you to automatically add a ModSurfaceBgStyle instead of using Mod.AddSurfaceBgStyle. Return true to allow autoloading; by default returns the mod's autoload property. Name is initialized to the overriding class name. Use this to either force or stop an autoload, or change the name that identifies this type of ModSurfaceBgStyle. More...
 
virtual bool ChooseBgStyle ()
 Whether or not the conditions have been met for this background style to draw its backgrounds. Returns false by default. More...
 
virtual int ChooseCloseTexture (ref float scale, ref double parallax, ref float a, ref float b)
 Allows you to determine which texture is drawn in the closest part of the background. This also lets you modify the scale and parallax (as well as two unfortunately-unknown parameters). More...
 
virtual int ChooseFarTexture ()
 Allows you to determine which texture is drawn in the very back of the background. Mod.GetBackgroundSlot may be useful here, as well as for the other texture-choosing hooks. More...
 
virtual int ChooseMiddleTexture ()
 Allows you to determine which texture is drawn in the middle of the background. More...
 
abstract void ModifyFarFades (float[] fades, float transitionSpeed)
 Allows you to modify the transparency of all background styles that exist. In general, you should move the index equal to this style's slot closer to 1, and all other indexes closer to 0. The transitionSpeed parameter is what you should add/subtract to each element of the fades parameter. See the ExampleMod for an example. More...
 
virtual bool PreDrawCloseBackground (SpriteBatch spriteBatch)
 Gives you complete freedom over how the closest part of the background is drawn. Return true for ChooseCloseTexture to have an effect; return false to disable tModLoader's own code for drawing the close background. More...
 

Properties

Mod mod [get, set]
 The mod that added this surface background style. More...
 
string Name [get, set]
 The internal name of this surface background style. More...
 
int Slot [get, set]
 The ID of this surface background style. More...
 

Detailed Description

Each background style determines in its own way how exactly the background is drawn. This class serves as a collection of functions for above-ground backgrounds.

Definition at line 57 of file ModBackgroundStyle.cs.

Member Function Documentation

◆ Autoload()

virtual bool Terraria.ModLoader.ModSurfaceBgStyle.Autoload ( ref string  name)
virtual

Allows you to automatically add a ModSurfaceBgStyle instead of using Mod.AddSurfaceBgStyle. Return true to allow autoloading; by default returns the mod's autoload property. Name is initialized to the overriding class name. Use this to either force or stop an autoload, or change the name that identifies this type of ModSurfaceBgStyle.

Definition at line 86 of file ModBackgroundStyle.cs.

86 {
87 return mod.Properties.Autoload;
88 }
ModProperties Properties
Definition: Mod.cs:52
Mod mod
The mod that added this surface background style.
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...

References Terraria.ModLoader.ModProperties.Autoload, Terraria.ModLoader.ModSurfaceBgStyle.mod, and Terraria.ModLoader.Mod.Properties.

Referenced by Terraria.ModLoader.Mod.AutoloadSurfaceBgStyle().

+ Here is the caller graph for this function:

◆ ChooseBgStyle()

virtual bool Terraria.ModLoader.ModSurfaceBgStyle.ChooseBgStyle ( )
virtual

Whether or not the conditions have been met for this background style to draw its backgrounds. Returns false by default.

Definition at line 93 of file ModBackgroundStyle.cs.

93 {
94 return false;
95 }

◆ ChooseCloseTexture()

virtual int Terraria.ModLoader.ModSurfaceBgStyle.ChooseCloseTexture ( ref float  scale,
ref double  parallax,
ref float  a,
ref float  b 
)
virtual

Allows you to determine which texture is drawn in the closest part of the background. This also lets you modify the scale and parallax (as well as two unfortunately-unknown parameters).

Parameters
scaleThe scale.
parallaxThe parallax value.
aa?
bb?
Returns

Definition at line 131 of file ModBackgroundStyle.cs.

131 {
132 return -1;
133 }

◆ ChooseFarTexture()

virtual int Terraria.ModLoader.ModSurfaceBgStyle.ChooseFarTexture ( )
virtual

Allows you to determine which texture is drawn in the very back of the background. Mod.GetBackgroundSlot may be useful here, as well as for the other texture-choosing hooks.

Definition at line 105 of file ModBackgroundStyle.cs.

105 {
106 return -1;
107 }

◆ ChooseMiddleTexture()

virtual int Terraria.ModLoader.ModSurfaceBgStyle.ChooseMiddleTexture ( )
virtual

Allows you to determine which texture is drawn in the middle of the background.

Definition at line 112 of file ModBackgroundStyle.cs.

112 {
113 return -1;
114 }

◆ ModifyFarFades()

abstract void Terraria.ModLoader.ModSurfaceBgStyle.ModifyFarFades ( float[]  fades,
float  transitionSpeed 
)
pure virtual

Allows you to modify the transparency of all background styles that exist. In general, you should move the index equal to this style's slot closer to 1, and all other indexes closer to 0. The transitionSpeed parameter is what you should add/subtract to each element of the fades parameter. See the ExampleMod for an example.

◆ PreDrawCloseBackground()

virtual bool Terraria.ModLoader.ModSurfaceBgStyle.PreDrawCloseBackground ( SpriteBatch  spriteBatch)
virtual

Gives you complete freedom over how the closest part of the background is drawn. Return true for ChooseCloseTexture to have an effect; return false to disable tModLoader's own code for drawing the close background.

Definition at line 119 of file ModBackgroundStyle.cs.

119 {
120 return true;
121 }

Property Documentation

◆ mod

Mod Terraria.ModLoader.ModSurfaceBgStyle.mod
getset

The mod that added this surface background style.

Definition at line 62 of file ModBackgroundStyle.cs.

62 {
63 get;
64 internal set;
65 }

Referenced by Terraria.ModLoader.ModSurfaceBgStyle.Autoload().

◆ Name

string Terraria.ModLoader.ModSurfaceBgStyle.Name
getset

The internal name of this surface background style.

Definition at line 70 of file ModBackgroundStyle.cs.

70 {
71 get;
72 internal set;
73 }

Referenced by Terraria.ModLoader.Mod.AutoloadSurfaceBgStyle().

◆ Slot

int Terraria.ModLoader.ModSurfaceBgStyle.Slot
getset

The ID of this surface background style.

Definition at line 78 of file ModBackgroundStyle.cs.

78 {
79 get;
80 internal set;
81 }