1using Microsoft.Xna.Framework;
 
    2using Microsoft.Xna.Framework.Graphics;
 
    5using System.Collections.Generic;
 
    7using Terraria.Localization;
 
   16        internal static int extraPlayerBuffCount;
 
   18        internal static readonly IList<ModBuff> buffs = 
new List<ModBuff>();
 
   19        internal static readonly IList<GlobalBuff> globalBuffs = 
new List<GlobalBuff>();
 
   35            for (
int k = 0; k < BuffID.Count; k++) {
 
   64        internal static int ReserveBuffID() {
 
   78            return type >= BuffID.Count && type < 
BuffCount ? buffs[type - BuffID.Count] : 
null;
 
   81        internal static void ResizeArrays() {
 
   82            Array.Resize(ref Main.pvpBuff, 
nextBuff);
 
   83            Array.Resize(ref Main.persistentBuff, 
nextBuff);
 
   84            Array.Resize(ref Main.vanityPet, 
nextBuff);
 
   85            Array.Resize(ref Main.lightPet, 
nextBuff);
 
   86            Array.Resize(ref Main.meleeBuff, 
nextBuff);
 
   87            Array.Resize(ref Main.debuff, 
nextBuff);
 
   88            Array.Resize(ref Main.buffNoSave, 
nextBuff);
 
   89            Array.Resize(ref Main.buffNoTimeDisplay, 
nextBuff);
 
   90            Array.Resize(ref Main.buffDoubleApply, 
nextBuff);
 
   91            Array.Resize(ref Main.buffAlpha, 
nextBuff);
 
   92            Array.Resize(ref Main.buffTexture, 
nextBuff);
 
   93            Array.Resize(ref Lang._buffNameCache, 
nextBuff);
 
   94            Array.Resize(ref Lang._buffDescriptionCache, 
nextBuff);
 
   95            for (
int k = BuffID.Count; k < 
nextBuff; k++) {
 
   96                Lang._buffNameCache[k] = LocalizedText.Empty;
 
   97                Lang._buffDescriptionCache[k] = LocalizedText.Empty;
 
   99            extraPlayerBuffCount = ModLoader.Mods.Any() ? ModLoader.Mods.Max(m => (
int)m.ExtraPlayerBuffSlots) : 0;
 
  101            ModLoader.BuildGlobalHook(ref 
HookUpdatePlayer, globalBuffs, g => g.Update);
 
  102            ModLoader.BuildGlobalHook(ref 
HookUpdateNPC, globalBuffs, g => g.Update);
 
  104            ModLoader.BuildGlobalHook(ref 
HookReApplyNPC, globalBuffs, g => g.ReApply);
 
  105            ModLoader.BuildGlobalHook(ref 
HookModifyBuffTip, globalBuffs, g => g.ModifyBuffTip);
 
  110        internal static void Unload() {
 
  116        internal static bool IsModBuff(
int type) {
 
  117            return type >= BuffID.Count;
 
  120        public static void Update(
int buff, Player player, ref 
int buffIndex) {
 
  121            int originalIndex = buffIndex;
 
  122            if (IsModBuff(buff)) {
 
  126                if (buffIndex != originalIndex) {
 
  129                hook(buff, player, ref buffIndex);
 
  133        public static void Update(
int buff, NPC npc, ref 
int buffIndex) {
 
  134            if (IsModBuff(buff)) {
 
  138                hook(buff, npc, ref buffIndex);
 
  142        public static bool ReApply(
int buff, Player player, 
int time, 
int buffIndex) {
 
  144                if (hook(buff, player, time, buffIndex)) {
 
  148            if (IsModBuff(buff)) {
 
  154        public static bool ReApply(
int buff, NPC npc, 
int time, 
int buffIndex) {
 
  156                if (hook(buff, npc, time, buffIndex)) {
 
  160            if (IsModBuff(buff)) {
 
  175            if (IsModBuff(buff)) {
 
  179                hook(buff, ref tip, ref rare);
 
  185                hook(buffTip, sizes);
 
  189        public static void DrawCustomBuffTip(
string buffTip, SpriteBatch spriteBatch, 
int originX, 
int originY) {
 
  191                hook(buffTip, spriteBatch, originX, originY);
 
This serves as the central class from which buff-related functions are supported and carried out.
 
static Func< int, Player, int, int, bool >[] HookReApplyPlayer
 
static DelegateModifyBuffTip[] HookModifyBuffTip
 
static bool ReApply(int buff, NPC npc, int time, int buffIndex)
 
static Func< int, NPC, int, int, bool >[] HookReApplyNPC
 
static bool ReApply(int buff, Player player, int time, int buffIndex)
 
static Action< string, SpriteBatch, int, int >[] HookDrawCustomBuffTip
 
static Action< string, List< Vector2 > >[] HookCustomBuffTipSize
 
static void CustomBuffTipSize(string buffTip, List< Vector2 > sizes)
 
static ModBuff GetBuff(int type)
Gets the ModBuff instance with the given type. If no ModBuff with the given type exists,...
 
static void ModifyBuffTip(int buff, ref string tip, ref int rare)
 
delegate void DelegateUpdateNPC(int type, NPC npc, ref int buffIndex)
 
static readonly bool[] vanillaLongerExpertDebuff
 
static void DrawCustomBuffTip(string buffTip, SpriteBatch spriteBatch, int originX, int originY)
 
static void Update(int buff, Player player, ref int buffIndex)
 
static readonly bool[] vanillaCanBeCleared
 
delegate void DelegateUpdatePlayer(int type, Player player, ref int buffIndex)
 
static void Update(int buff, NPC npc, ref int buffIndex)
 
static bool CanBeCleared(int buff)
 
static DelegateUpdateNPC[] HookUpdateNPC
 
delegate void DelegateModifyBuffTip(int type, ref string tip, ref int rare)
 
static DelegateUpdatePlayer[] HookUpdatePlayer
 
static bool LongerExpertDebuff(int buff)
 
This class serves as a place for you to define a new buff and how that buff behaves.
 
bool canBeCleared
Whether or not it is always safe to call Player.DelBuff on this buff. Setting this to false will prev...
 
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,...
 
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...
 
bool longerExpertDebuff
If this buff is a debuff, setting this to true will make this buff last twice as long on players in e...
 
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...
 
static bool AllowVanillaClients