tModLoader v2024.03
A mod to make and play Terraria mods
Dust Class Reference

Dust are particles effects used to add visual elements to weapons and other effects. Dust are completely visual and should never be used as a gameplay element. Dust count limits are imposed by the game to keep performance consistent, so Dust are not guaranteed to spawn when code attempts to spawn them.Vanilla Dust are enumerated in the DustID class.New Dust can be implemented using the ModDust class.The Basic Dust Guideteaches the basics on using Dust. In addition, the guide has resources teaching how to discover and use vanilla Dust. More...

Public Member Functions

Color GetAlpha (Color newColor)
 
Color GetColor (Color newColor)
 
float GetVisualRotation ()
 
float GetVisualScale ()
 

Static Public Member Functions

static Dust CloneDust (Dust rf)
 
static Dust CloneDust (int dustIndex)
 
static void DrawDebugBox (Rectangle itemRectangle)
 
static int dustWater ()
 
static int NewDust (Vector2 Position, int Width, int Height, int Type, float SpeedX=0f, float SpeedY=0f, int Alpha=0, Color newColor=default(Color), float Scale=1f)
 Attempts to spawn a single Dust into the game world. The Position, Width, and Height parameters dictate a rectangle, the dust will be spawned randomly within that rectangle. SpeedX and SpeedY dictate the initial velocity, they will be slightly randomized as well. More...
 
static Dust NewDustDirect (Vector2 Position, int Width, int Height, int Type, float SpeedX=0f, float SpeedY=0f, int Alpha=0, Color newColor=default(Color), float Scale=1f)
 Unlike Dust.NewDust(Vector2, int, int, int, float, float, int, Color, float), this method returns a Dust instance directly. More...
 
static Dust NewDustPerfect (Vector2 Position, int Type, Vector2? Velocity=null, int Alpha=0, Color newColor=default(Color), float Scale=1f)
 Attempts to spawn a single Dust into the game world. Position indicates the spawn position and Velocity indicates the initial velocity. Unlike NewDust(Vector2, int, int, int, float, float, int, Color, float), position and velocity will not be slightly randomized, making this method suitable for visual effects that need exact positioning. More...
 
static void QuickBox (Vector2 topLeft, Vector2 bottomRight, int divisions, Color color, Action< Dust > manipulator)
 
static Dust QuickDust (int x, int y, Color color)
 
static Dust QuickDust (Point tileCoords, Color color)
 
static Dust QuickDust (Vector2 pos, Color color)
 Spawns dust 267 tinted to the provided color at the specified position with no velocity or gravity. Used solely for debugging purposes. More...
 
static void QuickDustLine (Vector2 start, Vector2 end, float splits, Color color)
 
static Dust QuickDustSmall (Vector2 pos, Color color, bool floorPositionValues=false)
 
static void UpdateDust ()
 

Public Attributes

bool active
 
int alpha
 How transparent to draw this dust. 0 to 255. 255 is completely transparent. Used to fade dust out and sometimes to determine if a dust should despawn.
 
Color color
 A tinting to the color this dust is drawn. Works best with sprites with low saturation, such as greyscale sprites. Not as effective with colored sprites.
 
object customData
 Can be used to store any custom data. Typically used to store a Player, NPC, or Projectile instance that the dust will attempt to follow. ExampleAdvancedDust.csshowcases how customData can be used for advanced movement behavior.
 
int dustIndex
 
float fadeIn
 Used by some dust AI to control logic pertaining to the dust fading in. The specific behavior depends on the dust type. Defaults to 0f.
 
bool firstFrame
 
Rectangle frame
 The portion of the sprite sheet that this dust will be drawn using. Typical vanilla dust spawn with a randomly chosen 8x8 frame from a set of 3 options, but modded dust can use whatever dimensions are desired.
 
bool noGravity
 Indicates if a dust should be affected by gravity or not. Not all vanilla dust have logic checking this value and modded dust with custom ModDust.Update(Dust) code would need to implement this into the logic for it to have effect. Defaults to false.
 
bool noLight
 If true, the dust will not emit light. The specific behavior depends on the dust type, as many dust might not emit light or honor noLight. Defaults to false.
 
bool noLightEmittence
 
Vector2 position
 Current position of this dust.
 
float rotation
 Current rotation of this dust.
 
float scale
 The draw scale of the dust. Many dust rely on scale to determine when it should despawn. The Scale parameter of NewDust(Vector2, int, int, int, float, float, int, Color, float) will be slightly randomized (multiplied by a number between 80% to 120%) and then assigned to scale.
 
ArmorShaderData shader
 The shader that will be applied to this dust when drawing. Typically assigned based on the dye attached to the accessory or equipment spawning the dust. This is done using code similar to dust.shader = GameShaders.Armor.GetSecondaryShader(player.cPet, player);
 
int type
 The Dust ID of this dust. The Dust ID will be equal to either a DustID entry or ModContent.DustType<T>.
 
Vector2 velocity
 Current velocity of this dust.
 

Static Public Attributes

static float dCount
 
static int lavaBubbles
 
static int SandStormCount
 

Detailed Description

Dust are particles effects used to add visual elements to weapons and other effects. Dust are completely visual and should never be used as a gameplay element. Dust count limits are imposed by the game to keep performance consistent, so Dust are not guaranteed to spawn when code attempts to spawn them.

Vanilla Dust are enumerated in the DustID class.

New Dust can be implemented using the ModDust class.

The Basic Dust Guide

teaches the basics on using Dust. In addition, the guide has resources teaching how to discover and use vanilla Dust.

Member Function Documentation

◆ NewDust()

static int Dust.NewDust ( Vector2  Position,
int  Width,
int  Height,
int  Type,
float  SpeedX = 0f,
float  SpeedY = 0f,
int  Alpha = 0,
Color  newColor = default(Color),
float  Scale = 1f 
)
static

Attempts to spawn a single Dust into the game world. The Position, Width, and Height parameters dictate a rectangle, the dust will be spawned randomly within that rectangle. SpeedX and SpeedY dictate the initial velocity, they will be slightly randomized as well.

Parameters
Position
Width
Height
TypeEither an DustID entry or ModContent.DustType<T>
SpeedX
SpeedY
Alpha
newColor
Scale
Returns
The index of the dust within Main.dust

◆ NewDustDirect()

static Dust Dust.NewDustDirect ( Vector2  Position,
int  Width,
int  Height,
int  Type,
float  SpeedX = 0f,
float  SpeedY = 0f,
int  Alpha = 0,
Color  newColor = default(Color),
float  Scale = 1f 
)
static

Unlike Dust.NewDust(Vector2, int, int, int, float, float, int, Color, float), this method returns a Dust instance directly.

Parameters
Position
Width
Height
Type
SpeedX
SpeedY
Alpha
newColor
Scale
Returns
The Dust instance spawned

◆ NewDustPerfect()

static Dust Dust.NewDustPerfect ( Vector2  Position,
int  Type,
Vector2?  Velocity = null,
int  Alpha = 0,
Color  newColor = default(Color),
float  Scale = 1f 
)
static

Attempts to spawn a single Dust into the game world. Position indicates the spawn position and Velocity indicates the initial velocity. Unlike NewDust(Vector2, int, int, int, float, float, int, Color, float), position and velocity will not be slightly randomized, making this method suitable for visual effects that need exact positioning.

Parameters
Position
Type
Velocity
Alpha
newColor
Scale
Returns
The Dust instance spawned

◆ QuickDust()

static Dust Dust.QuickDust ( Vector2  pos,
Color  color 
)
static

Spawns dust 267 tinted to the provided color at the specified position with no velocity or gravity. Used solely for debugging purposes.

Parameters
pos
color
Returns