tModLoader v0.11.8.9
A mod to make and play Terraria mods
Terraria.ModLoader.BuffLoader Class Reference

This serves as the central class from which buff-related functions are supported and carried out. More...

+ Collaboration diagram for Terraria.ModLoader.BuffLoader:

Static Public Member Functions

static bool CanBeCleared (int buff)
 
static void CustomBuffTipSize (string buffTip, List< Vector2 > sizes)
 
static void DrawCustomBuffTip (string buffTip, SpriteBatch spriteBatch, int originX, int originY)
 
static ModBuff GetBuff (int type)
 Gets the ModBuff instance with the given type. If no ModBuff with the given type exists, returns null. More...
 
static bool LongerExpertDebuff (int buff)
 
static void ModifyBuffTip (int buff, ref string tip, ref int rare)
 
static bool ReApply (int buff, NPC npc, int time, int buffIndex)
 
static bool ReApply (int buff, Player player, int time, int buffIndex)
 
static void Update (int buff, NPC npc, ref int buffIndex)
 
static void Update (int buff, Player player, ref int buffIndex)
 

Properties

static int BuffCount [get]
 

Private Member Functions

delegate void DelegateModifyBuffTip (int type, ref string tip, ref int rare)
 
delegate void DelegateUpdateNPC (int type, NPC npc, ref int buffIndex)
 
delegate void DelegateUpdatePlayer (int type, Player player, ref int buffIndex)
 

Static Private Member Functions

static BuffLoader ()
 

Static Private Attributes

static Action< string, List< Vector2 > >[] HookCustomBuffTipSize
 
static Action< string, SpriteBatch, int, int >[] HookDrawCustomBuffTip
 
static DelegateModifyBuffTip[] HookModifyBuffTip
 
static Func< int, NPC, int, int, bool >[] HookReApplyNPC
 
static Func< int, Player, int, int, bool >[] HookReApplyPlayer
 
static DelegateUpdateNPC[] HookUpdateNPC
 
static DelegateUpdatePlayer[] HookUpdatePlayer
 
static int nextBuff = BuffID.Count
 
static readonly bool[] vanillaCanBeCleared = new bool[BuffID.Count]
 
static readonly bool[] vanillaLongerExpertDebuff = new bool[BuffID.Count]
 

Detailed Description

This serves as the central class from which buff-related functions are supported and carried out.

Definition at line 14 of file BuffLoader.cs.

Constructor & Destructor Documentation

◆ BuffLoader()

static Terraria.ModLoader.BuffLoader.BuffLoader ( )
staticprivate

Definition at line 34 of file BuffLoader.cs.

34 {
35 for (int k = 0; k < BuffID.Count; k++) {
36 vanillaCanBeCleared[k] = true;
37 }
38 vanillaLongerExpertDebuff[BuffID.Poisoned] = true;
39 vanillaLongerExpertDebuff[BuffID.Darkness] = true;
40 vanillaLongerExpertDebuff[BuffID.Cursed] = true;
41 vanillaLongerExpertDebuff[BuffID.OnFire] = true;
42 vanillaLongerExpertDebuff[BuffID.Bleeding] = true;
43 vanillaLongerExpertDebuff[BuffID.Confused] = true;
44 vanillaLongerExpertDebuff[BuffID.Slow] = true;
45 vanillaLongerExpertDebuff[BuffID.Weak] = true;
46 vanillaLongerExpertDebuff[BuffID.Silenced] = true;
47 vanillaLongerExpertDebuff[BuffID.BrokenArmor] = true;
48 vanillaLongerExpertDebuff[BuffID.CursedInferno] = true;
49 vanillaLongerExpertDebuff[BuffID.Frostburn] = true;
50 vanillaLongerExpertDebuff[BuffID.Chilled] = true;
51 vanillaLongerExpertDebuff[BuffID.Frozen] = true;
52 vanillaLongerExpertDebuff[BuffID.Ichor] = true;
53 vanillaLongerExpertDebuff[BuffID.Venom] = true;
54 vanillaLongerExpertDebuff[BuffID.Blackout] = true;
55 vanillaCanBeCleared[BuffID.PotionSickness] = false;
56 vanillaCanBeCleared[BuffID.Werewolf] = false;
57 vanillaCanBeCleared[BuffID.Merfolk] = false;
58 vanillaCanBeCleared[BuffID.WaterCandle] = false;
59 vanillaCanBeCleared[BuffID.Campfire] = false;
60 vanillaCanBeCleared[BuffID.HeartLamp] = false;
61 vanillaCanBeCleared[BuffID.NoBuilding] = false;
62 }
static readonly bool[] vanillaLongerExpertDebuff
Definition: BuffLoader.cs:20
static readonly bool[] vanillaCanBeCleared
Definition: BuffLoader.cs:21

References Terraria.ModLoader.BuffLoader.vanillaCanBeCleared, and Terraria.ModLoader.BuffLoader.vanillaLongerExpertDebuff.

Member Function Documentation

◆ CanBeCleared()

static bool Terraria.ModLoader.BuffLoader.CanBeCleared ( int  buff)
static

Definition at line 170 of file BuffLoader.cs.

170 {
171 return GetBuff(buff)?.canBeCleared ?? vanillaCanBeCleared[buff];
172 }
static ModBuff GetBuff(int type)
Gets the ModBuff instance with the given type. If no ModBuff with the given type exists,...
Definition: BuffLoader.cs:77
bool canBeCleared
Whether or not it is always safe to call Player.DelBuff on this buff. Setting this to false will prev...
Definition: ModBuff.cs:52

References Terraria.ModLoader.ModBuff.canBeCleared, Terraria.ModLoader.BuffLoader.GetBuff(), and Terraria.ModLoader.BuffLoader.vanillaCanBeCleared.

+ Here is the call graph for this function:

◆ CustomBuffTipSize()

static void Terraria.ModLoader.BuffLoader.CustomBuffTipSize ( string  buffTip,
List< Vector2 >  sizes 
)
static

Definition at line 183 of file BuffLoader.cs.

183 {
184 foreach (var hook in HookCustomBuffTipSize) {
185 hook(buffTip, sizes);
186 }
187 }
static Action< string, List< Vector2 > >[] HookCustomBuffTipSize
Definition: BuffLoader.cs:31

References Terraria.ModLoader.BuffLoader.HookCustomBuffTipSize.

◆ DelegateModifyBuffTip()

delegate void Terraria.ModLoader.BuffLoader.DelegateModifyBuffTip ( int  type,
ref string  tip,
ref int  rare 
)
private

◆ DelegateUpdateNPC()

delegate void Terraria.ModLoader.BuffLoader.DelegateUpdateNPC ( int  type,
NPC  npc,
ref int  buffIndex 
)
private

◆ DelegateUpdatePlayer()

delegate void Terraria.ModLoader.BuffLoader.DelegateUpdatePlayer ( int  type,
Player  player,
ref int  buffIndex 
)
private

◆ DrawCustomBuffTip()

static void Terraria.ModLoader.BuffLoader.DrawCustomBuffTip ( string  buffTip,
SpriteBatch  spriteBatch,
int  originX,
int  originY 
)
static

Definition at line 189 of file BuffLoader.cs.

189 {
190 foreach (var hook in HookDrawCustomBuffTip) {
191 hook(buffTip, spriteBatch, originX, originY);
192 }
193 }
static Action< string, SpriteBatch, int, int >[] HookDrawCustomBuffTip
Definition: BuffLoader.cs:32

References Terraria.ModLoader.BuffLoader.HookDrawCustomBuffTip.

◆ GetBuff()

static ModBuff Terraria.ModLoader.BuffLoader.GetBuff ( int  type)
static

Gets the ModBuff instance with the given type. If no ModBuff with the given type exists, returns null.

Definition at line 77 of file BuffLoader.cs.

77 {
78 return type >= BuffID.Count && type < BuffCount ? buffs[type - BuffID.Count] : null;
79 }

References Terraria.ModLoader.BuffLoader.BuffCount.

Referenced by Terraria.ModLoader.BuffLoader.CanBeCleared(), Terraria.ModLoader.BuffLoader.LongerExpertDebuff(), Terraria.ModLoader.BuffLoader.ModifyBuffTip(), Terraria.ModLoader.BuffLoader.ReApply(), and Terraria.ModLoader.BuffLoader.Update().

+ Here is the caller graph for this function:

◆ LongerExpertDebuff()

static bool Terraria.ModLoader.BuffLoader.LongerExpertDebuff ( int  buff)
static

Definition at line 166 of file BuffLoader.cs.

166 {
168 }
bool longerExpertDebuff
If this buff is a debuff, setting this to true will make this buff last twice as long on players in e...
Definition: ModBuff.cs:50

References Terraria.ModLoader.BuffLoader.GetBuff(), Terraria.ModLoader.ModBuff.longerExpertDebuff, and Terraria.ModLoader.BuffLoader.vanillaLongerExpertDebuff.

+ Here is the call graph for this function:

◆ ModifyBuffTip()

static void Terraria.ModLoader.BuffLoader.ModifyBuffTip ( int  buff,
ref string  tip,
ref int  rare 
)
static

Definition at line 174 of file BuffLoader.cs.

174 {
175 if (IsModBuff(buff)) {
176 GetBuff(buff).ModifyBuffTip(ref tip, ref rare);
177 }
178 foreach (var hook in HookModifyBuffTip) {
179 hook(buff, ref tip, ref rare);
180 }
181 }
static DelegateModifyBuffTip[] HookModifyBuffTip
Definition: BuffLoader.cs:30
virtual void ModifyBuffTip(ref string tip, ref int rare)
Allows you to modify the tooltip that displays when the mouse hovers over the buff icon,...
Definition: ModBuff.cs:104

References Terraria.ModLoader.BuffLoader.GetBuff(), Terraria.ModLoader.BuffLoader.HookModifyBuffTip, and Terraria.ModLoader.ModBuff.ModifyBuffTip().

+ Here is the call graph for this function:

◆ ReApply() [1/2]

static bool Terraria.ModLoader.BuffLoader.ReApply ( int  buff,
NPC  npc,
int  time,
int  buffIndex 
)
static

Definition at line 154 of file BuffLoader.cs.

154 {
155 foreach (var hook in HookReApplyNPC) {
156 if (hook(buff, npc, time, buffIndex)) {
157 return true;
158 }
159 }
160 if (IsModBuff(buff)) {
161 return GetBuff(buff).ReApply(npc, time, buffIndex);
162 }
163 return false;
164 }
static Func< int, NPC, int, int, bool >[] HookReApplyNPC
Definition: BuffLoader.cs:28
virtual bool ReApply(Player player, int time, int buffIndex)
Allows to you make special things happen when adding this buff to a player when the player already ha...
Definition: ModBuff.cs:90

References Terraria.ModLoader.BuffLoader.GetBuff(), Terraria.ModLoader.BuffLoader.HookReApplyNPC, and Terraria.ModLoader.ModBuff.ReApply().

+ Here is the call graph for this function:

◆ ReApply() [2/2]

static bool Terraria.ModLoader.BuffLoader.ReApply ( int  buff,
Player  player,
int  time,
int  buffIndex 
)
static

Definition at line 142 of file BuffLoader.cs.

142 {
143 foreach (var hook in HookReApplyPlayer) {
144 if (hook(buff, player, time, buffIndex)) {
145 return true;
146 }
147 }
148 if (IsModBuff(buff)) {
149 return GetBuff(buff).ReApply(player, time, buffIndex);
150 }
151 return false;
152 }
static Func< int, Player, int, int, bool >[] HookReApplyPlayer
Definition: BuffLoader.cs:27

References Terraria.ModLoader.BuffLoader.GetBuff(), Terraria.ModLoader.BuffLoader.HookReApplyPlayer, and Terraria.ModLoader.ModBuff.ReApply().

+ Here is the call graph for this function:

◆ Update() [1/2]

static void Terraria.ModLoader.BuffLoader.Update ( int  buff,
NPC  npc,
ref int  buffIndex 
)
static

Definition at line 133 of file BuffLoader.cs.

133 {
134 if (IsModBuff(buff)) {
135 GetBuff(buff).Update(npc, ref buffIndex);
136 }
137 foreach (var hook in HookUpdateNPC) {
138 hook(buff, npc, ref buffIndex);
139 }
140 }
static DelegateUpdateNPC[] HookUpdateNPC
Definition: BuffLoader.cs:26
virtual void Update(Player player, ref int buffIndex)
Allows you to make this buff give certain effects to the given player. If you remove the buff from th...
Definition: ModBuff.cs:78

References Terraria.ModLoader.BuffLoader.GetBuff(), Terraria.ModLoader.BuffLoader.HookUpdateNPC, and Terraria.ModLoader.ModBuff.Update().

+ Here is the call graph for this function:

◆ Update() [2/2]

static void Terraria.ModLoader.BuffLoader.Update ( int  buff,
Player  player,
ref int  buffIndex 
)
static

Definition at line 120 of file BuffLoader.cs.

120 {
121 int originalIndex = buffIndex;
122 if (IsModBuff(buff)) {
123 GetBuff(buff).Update(player, ref buffIndex);
124 }
125 foreach (var hook in HookUpdatePlayer) {
126 if (buffIndex != originalIndex) {
127 break;
128 }
129 hook(buff, player, ref buffIndex);
130 }
131 }
static DelegateUpdatePlayer[] HookUpdatePlayer
Definition: BuffLoader.cs:24

References Terraria.ModLoader.BuffLoader.GetBuff(), Terraria.ModLoader.BuffLoader.HookUpdatePlayer, and Terraria.ModLoader.ModBuff.Update().

+ Here is the call graph for this function:

Member Data Documentation

◆ HookCustomBuffTipSize

Action<string, List<Vector2> > [] Terraria.ModLoader.BuffLoader.HookCustomBuffTipSize
staticprivate

Definition at line 31 of file BuffLoader.cs.

Referenced by Terraria.ModLoader.BuffLoader.CustomBuffTipSize().

◆ HookDrawCustomBuffTip

Action<string, SpriteBatch, int, int> [] Terraria.ModLoader.BuffLoader.HookDrawCustomBuffTip
staticprivate

Definition at line 32 of file BuffLoader.cs.

Referenced by Terraria.ModLoader.BuffLoader.DrawCustomBuffTip().

◆ HookModifyBuffTip

DelegateModifyBuffTip [] Terraria.ModLoader.BuffLoader.HookModifyBuffTip
staticprivate

Definition at line 30 of file BuffLoader.cs.

Referenced by Terraria.ModLoader.BuffLoader.ModifyBuffTip().

◆ HookReApplyNPC

Func<int, NPC, int, int, bool> [] Terraria.ModLoader.BuffLoader.HookReApplyNPC
staticprivate

Definition at line 28 of file BuffLoader.cs.

Referenced by Terraria.ModLoader.BuffLoader.ReApply().

◆ HookReApplyPlayer

Func<int, Player, int, int, bool> [] Terraria.ModLoader.BuffLoader.HookReApplyPlayer
staticprivate

Definition at line 27 of file BuffLoader.cs.

Referenced by Terraria.ModLoader.BuffLoader.ReApply().

◆ HookUpdateNPC

DelegateUpdateNPC [] Terraria.ModLoader.BuffLoader.HookUpdateNPC
staticprivate

Definition at line 26 of file BuffLoader.cs.

Referenced by Terraria.ModLoader.BuffLoader.Update().

◆ HookUpdatePlayer

DelegateUpdatePlayer [] Terraria.ModLoader.BuffLoader.HookUpdatePlayer
staticprivate

Definition at line 24 of file BuffLoader.cs.

Referenced by Terraria.ModLoader.BuffLoader.Update().

◆ nextBuff

int Terraria.ModLoader.BuffLoader.nextBuff = BuffID.Count
staticprivate

Definition at line 17 of file BuffLoader.cs.

◆ vanillaCanBeCleared

readonly bool [] Terraria.ModLoader.BuffLoader.vanillaCanBeCleared = new bool[BuffID.Count]
staticprivate

◆ vanillaLongerExpertDebuff

readonly bool [] Terraria.ModLoader.BuffLoader.vanillaLongerExpertDebuff = new bool[BuffID.Count]
staticprivate

Property Documentation

◆ BuffCount

int Terraria.ModLoader.BuffLoader.BuffCount
staticget

Definition at line 72 of file BuffLoader.cs.

Referenced by Terraria.ModLoader.BuffLoader.GetBuff().