1using Microsoft.Xna.Framework;
2using Microsoft.Xna.Framework.Graphics;
4using System.Collections.Generic;
5using Terraria.GameContent;
16 internal static readonly IList<ModDust> dusts =
new List<ModDust>();
52 internal static int DustCount =>
nextDust;
58 return type >= DustID.Count && type < DustCount ? dusts[type - DustID.Count] :
null;
61 internal static int ReserveDustID() {
67 internal static void ResizeArrays() {
68 Array.Resize(ref ChildSafety.SafeDust,
nextDust);
69 for (
int k = DustID.Count; k <
nextDust; k++) {
70 ChildSafety.SafeDust[k] =
true;
74 internal static void Unload() {
79 internal static void SetupDust(Dust dust) {
80 ModDust modDust =
GetDust(dust.type);
81 if (modDust !=
null) {
84 modDust.OnSpawn(dust);
88 internal static void SetupUpdateType(Dust dust) {
89 ModDust modDust =
GetDust(dust.type);
90 if (modDust !=
null && modDust.updateType >= 0) {
91 dust.realType = dust.type;
92 dust.type = modDust.updateType;
96 internal static void TakeDownUpdateType(Dust dust) {
97 if (dust.realType >= 0) {
98 dust.type = dust.realType;
105 internal void Draw(Dust dust, Color alpha,
float scale) {
106 Main.spriteBatch.Draw(
Texture, dust.position - Main.screenPosition,
new Microsoft.Xna.Framework.Rectangle?(dust.frame), alpha, dust.rotation,
new Vector2(4f, 4f), scale, SpriteEffects.None, 0f);
107 if (dust.color !=
default(Microsoft.Xna.Framework.Color)) {
108 Main.spriteBatch.Draw(
Texture, dust.position - Main.screenPosition,
new Microsoft.Xna.Framework.Rectangle?(dust.frame), dust.GetColor(alpha), dust.rotation,
new Vector2(4f, 4f), scale, SpriteEffects.None, 0f);
110 if (alpha == Microsoft.Xna.Framework.Color.Black) {
118 public virtual bool Autoload(ref
string name, ref
string texture) {
164 public virtual Color?
GetAlpha(Dust dust, Color lightColor) {
This class represents a type of dust that is added by a mod. Only one instance of this class will eve...
int updateType
Allows you to choose a type of dust for this type of dust to copy the behavior of....
Mod mod
The mod that added this type of dust.
Texture2D Texture
The sprite sheet that this type of dust uses. Normally a sprite sheet will consist of a vertical alig...
virtual bool MidUpdate(Dust dust)
Allows you to add behavior to this dust on top of the default dust behavior. Return true if you're ap...
virtual bool Update(Dust dust)
Allows you to customize how you want this type of dust to behave. Return true to allow for vanilla du...
virtual void OnSpawn(Dust dust)
Allows you to modify a dust's fields when it is created.
virtual ? Color GetAlpha(Dust dust, Color lightColor)
Allows you to override the color this dust will draw in. Return null to draw it in the normal light c...
string Name
The internal name of this type of dust.
int Type
The ID of this type of dust.
virtual bool Autoload(ref string name, ref string texture)
Allows you to automatically add a type of dust without having to use Mod.AddDust. By default returns ...
virtual void SetDefaults()
Allows you to set this ModDust's updateType field and modify the Terraria.GameContent....
static ModDust GetDust(int type)
Gets the ModDust instance with the given type. Returns null if no ModDust with the given type exists.
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...