Terraria ModLoader  0.10.1.5
A framework for 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, Player player, int time, int buffIndex)
 
static bool ReApply (int buff, NPC npc, int time, int buffIndex)
 
static void Update (int buff, Player player, ref int buffIndex)
 
static void Update (int buff, NPC npc, ref int buffIndex)
 

Static Public Attributes

static int BuffCount => nextBuff
 

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 13 of file BuffLoader.cs.

Constructor & Destructor Documentation

static Terraria.ModLoader.BuffLoader.BuffLoader ( )
staticprivate

Definition at line 32 of file BuffLoader.cs.

References Terraria.ModLoader.ModNet.AllowVanillaClients.

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

Member Function Documentation

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

Definition at line 167 of file BuffLoader.cs.

167  {
168  return GetBuff(buff)?.canBeCleared ?? vanillaCanBeCleared[buff];
169  }
static readonly bool[] vanillaCanBeCleared
Definition: BuffLoader.cs:19
static ModBuff GetBuff(int type)
Gets the ModBuff instance with the given type. If no ModBuff with the given type exists, returns null.
Definition: BuffLoader.cs:75
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
static void Terraria.ModLoader.BuffLoader.CustomBuffTipSize ( string  buffTip,
List< Vector2 >  sizes 
)
static

Definition at line 180 of file BuffLoader.cs.

180  {
181  foreach (var hook in HookCustomBuffTipSize) {
182  hook(buffTip, sizes);
183  }
184  }
static Action< string, List< Vector2 > >[] HookCustomBuffTipSize
Definition: BuffLoader.cs:29
delegate void Terraria.ModLoader.BuffLoader.DelegateModifyBuffTip ( int  type,
ref string  tip,
ref int  rare 
)
private
delegate void Terraria.ModLoader.BuffLoader.DelegateUpdateNPC ( int  type,
NPC  npc,
ref int  buffIndex 
)
private
delegate void Terraria.ModLoader.BuffLoader.DelegateUpdatePlayer ( int  type,
Player  player,
ref int  buffIndex 
)
private
static void Terraria.ModLoader.BuffLoader.DrawCustomBuffTip ( string  buffTip,
SpriteBatch  spriteBatch,
int  originX,
int  originY 
)
static

Definition at line 186 of file BuffLoader.cs.

186  {
187  foreach (var hook in HookDrawCustomBuffTip) {
188  hook(buffTip, spriteBatch, originX, originY);
189  }
190  }
static Action< string, SpriteBatch, int, int >[] HookDrawCustomBuffTip
Definition: BuffLoader.cs:30
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 75 of file BuffLoader.cs.

75  {
76  return type >= BuffID.Count && type < BuffCount ? buffs[type - BuffID.Count] : null;
77  }
static bool Terraria.ModLoader.BuffLoader.LongerExpertDebuff ( int  buff)
static

Definition at line 163 of file BuffLoader.cs.

163  {
165  }
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
static ModBuff GetBuff(int type)
Gets the ModBuff instance with the given type. If no ModBuff with the given type exists, returns null.
Definition: BuffLoader.cs:75
static readonly bool[] vanillaLongerExpertDebuff
Definition: BuffLoader.cs:18
static void Terraria.ModLoader.BuffLoader.ModifyBuffTip ( int  buff,
ref string  tip,
ref int  rare 
)
static

Definition at line 171 of file BuffLoader.cs.

171  {
172  if (IsModBuff(buff)) {
173  GetBuff(buff).ModifyBuffTip(ref tip, ref rare);
174  }
175  foreach (var hook in HookModifyBuffTip) {
176  hook(buff, ref tip, ref rare);
177  }
178  }
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
static ModBuff GetBuff(int type)
Gets the ModBuff instance with the given type. If no ModBuff with the given type exists, returns null.
Definition: BuffLoader.cs:75
static DelegateModifyBuffTip[] HookModifyBuffTip
Definition: BuffLoader.cs:28
static bool Terraria.ModLoader.BuffLoader.ReApply ( int  buff,
Player  player,
int  time,
int  buffIndex 
)
static

Definition at line 139 of file BuffLoader.cs.

139  {
140  foreach (var hook in HookReApplyPlayer) {
141  if (hook(buff, player, time, buffIndex)) {
142  return true;
143  }
144  }
145  if (IsModBuff(buff)) {
146  return GetBuff(buff).ReApply(player, time, buffIndex);
147  }
148  return false;
149  }
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
static ModBuff GetBuff(int type)
Gets the ModBuff instance with the given type. If no ModBuff with the given type exists, returns null.
Definition: BuffLoader.cs:75
static Func< int, Player, int, int, bool >[] HookReApplyPlayer
Definition: BuffLoader.cs:25
static bool Terraria.ModLoader.BuffLoader.ReApply ( int  buff,
NPC  npc,
int  time,
int  buffIndex 
)
static

Definition at line 151 of file BuffLoader.cs.

151  {
152  foreach (var hook in HookReApplyNPC) {
153  if (hook(buff, npc, time, buffIndex)) {
154  return true;
155  }
156  }
157  if (IsModBuff(buff)) {
158  return GetBuff(buff).ReApply(npc, time, buffIndex);
159  }
160  return false;
161  }
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
static Func< int, NPC, int, int, bool >[] HookReApplyNPC
Definition: BuffLoader.cs:26
static ModBuff GetBuff(int type)
Gets the ModBuff instance with the given type. If no ModBuff with the given type exists, returns null.
Definition: BuffLoader.cs:75
static void Terraria.ModLoader.BuffLoader.Update ( int  buff,
Player  player,
ref int  buffIndex 
)
static

Definition at line 117 of file BuffLoader.cs.

117  {
118  int originalIndex = buffIndex;
119  if (IsModBuff(buff)) {
120  GetBuff(buff).Update(player, ref buffIndex);
121  }
122  foreach (var hook in HookUpdatePlayer) {
123  if (buffIndex != originalIndex) {
124  break;
125  }
126  hook(buff, player, ref buffIndex);
127  }
128  }
static DelegateUpdatePlayer[] HookUpdatePlayer
Definition: BuffLoader.cs:22
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
static ModBuff GetBuff(int type)
Gets the ModBuff instance with the given type. If no ModBuff with the given type exists, returns null.
Definition: BuffLoader.cs:75
static void Terraria.ModLoader.BuffLoader.Update ( int  buff,
NPC  npc,
ref int  buffIndex 
)
static

Definition at line 130 of file BuffLoader.cs.

130  {
131  if (IsModBuff(buff)) {
132  GetBuff(buff).Update(npc, ref buffIndex);
133  }
134  foreach (var hook in HookUpdateNPC) {
135  hook(buff, npc, ref buffIndex);
136  }
137  }
static DelegateUpdateNPC[] HookUpdateNPC
Definition: BuffLoader.cs:24
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
static ModBuff GetBuff(int type)
Gets the ModBuff instance with the given type. If no ModBuff with the given type exists, returns null.
Definition: BuffLoader.cs:75

Member Data Documentation

int Terraria.ModLoader.BuffLoader.BuffCount => nextBuff
static

Definition at line 70 of file BuffLoader.cs.

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

Definition at line 29 of file BuffLoader.cs.

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

Definition at line 30 of file BuffLoader.cs.

DelegateModifyBuffTip [] Terraria.ModLoader.BuffLoader.HookModifyBuffTip
staticprivate

Definition at line 28 of file BuffLoader.cs.

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

Definition at line 26 of file BuffLoader.cs.

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

Definition at line 25 of file BuffLoader.cs.

DelegateUpdateNPC [] Terraria.ModLoader.BuffLoader.HookUpdateNPC
staticprivate

Definition at line 24 of file BuffLoader.cs.

DelegateUpdatePlayer [] Terraria.ModLoader.BuffLoader.HookUpdatePlayer
staticprivate

Definition at line 22 of file BuffLoader.cs.

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

Definition at line 15 of file BuffLoader.cs.

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

Definition at line 19 of file BuffLoader.cs.

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

Definition at line 18 of file BuffLoader.cs.