public void AddBuff(int type, int time1, bool quiet = true)
{
if (this.buffImmune[type])
return;
int num = time1;
if (Main.expertMode && this.whoAmI == Main.myPlayer && (type == 20 || type == 22 || (type == 23 || type == 24) || (type == 30 || type == 31 || (type == 32 || type == 33)) || (type == 35 || type == 36 || (type == 39 || type == 44) || (type == 46 || type == 47 || (type == 69 || type == 70))) || type == 80))
num = (int)((double)Main.expertDebuffTime * (double)num);
if (!quiet && Main.netMode == 1)
{
bool flag = true;
for (int index = 0; index < 22; ++index)
{
if (this.buffType[index] == type)
{
flag = false;
break;
}
}
if (flag)
NetMessage.SendData(55, -1, -1, "", this.whoAmI, (float)type, (float)num, 0.0f, 0, 0, 0);
}
int index1 = -1;
for (int index2 = 0; index2 < 22; ++index2)
{
if (this.buffType[index2] == type)
{
if (type == 94)
{
this.buffTime[index2] += num;
if (this.buffTime[index2] <= Player.manaSickTimeMax)
return;
this.buffTime[index2] = Player.manaSickTimeMax;
return;
}
if (this.buffTime[index2] >= num)
return;
this.buffTime[index2] = num;
return;
}
}
if (Main.vanityPet[type] || Main.lightPet[type])
{
for (int b = 0; b < 22; ++b)
{
if (Main.vanityPet[type] && Main.vanityPet[this.buffType[b]])
this.DelBuff(b);
if (Main.lightPet[type] && Main.lightPet[this.buffType[b]])
this.DelBuff(b);
}
}
while (index1 == -1)
{
int b = -1;
for (int index2 = 0; index2 < 22; ++index2)
{
if (!Main.debuff[this.buffType[index2]])
{
b = index2;
break;
}
}
if (b == -1)
return;
for (int index2 = b; index2 < 22; ++index2)
{
if (this.buffType[index2] == 0)
{
index1 = index2;
break;
}
}
if (index1 == -1)
this.DelBuff(b);
}
this.buffType[index1] = type;
this.buffTime[index1] = num;
if (!Main.meleeBuff[type])
return;
for (int b = 0; b < 22; ++b)
{
if (b != index1 && Main.meleeBuff[this.buffType[b]])
this.DelBuff(b);
}
}