Terraria ModLoader  0.11.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 14 of file BuffLoader.cs.

Constructor & Destructor Documentation

static Terraria.ModLoader.BuffLoader.BuffLoader ( )
staticprivate

Definition at line 34 of file BuffLoader.cs.

References Terraria.ModLoader.ModNet.AllowVanillaClients.

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[] vanillaCanBeCleared
Definition: BuffLoader.cs:21
static readonly bool[] vanillaLongerExpertDebuff
Definition: BuffLoader.cs:20

Member Function Documentation

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 readonly bool[] vanillaCanBeCleared
Definition: BuffLoader.cs:21
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: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
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
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 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
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.

References Terraria.ModLoader.ModLoader.Mods.

Referenced by Terraria.ModLoader.ModContent.MusicExists().

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

+ Here is the caller graph for this function:

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
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:77
static readonly bool[] vanillaLongerExpertDebuff
Definition: BuffLoader.cs:20
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  }
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:77
static DelegateModifyBuffTip[] HookModifyBuffTip
Definition: BuffLoader.cs:30
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  }
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:77
static Func< int, Player, int, int, bool >[] HookReApplyPlayer
Definition: BuffLoader.cs:27
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  }
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:28
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:77
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
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:77
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
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:77

Member Data Documentation

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

Definition at line 72 of file BuffLoader.cs.

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

Definition at line 31 of file BuffLoader.cs.

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

Definition at line 32 of file BuffLoader.cs.

DelegateModifyBuffTip [] Terraria.ModLoader.BuffLoader.HookModifyBuffTip
staticprivate

Definition at line 30 of file BuffLoader.cs.

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

Definition at line 28 of file BuffLoader.cs.

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

Definition at line 27 of file BuffLoader.cs.

DelegateUpdateNPC [] Terraria.ModLoader.BuffLoader.HookUpdateNPC
staticprivate

Definition at line 26 of file BuffLoader.cs.

DelegateUpdatePlayer [] Terraria.ModLoader.BuffLoader.HookUpdatePlayer
staticprivate

Definition at line 24 of file BuffLoader.cs.

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

Definition at line 17 of file BuffLoader.cs.

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

Definition at line 21 of file BuffLoader.cs.

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

Definition at line 20 of file BuffLoader.cs.