public void UpdateLifeRegen()
{
bool flag = false;
if (this.shinyStone && (double)Math.Abs(this.velocity.X) < 0.05 && ((double)Math.Abs(this.velocity.Y) < 0.05 && this.itemAnimation == 0))
flag = true;
if (this.poisoned)
{
if (this.lifeRegen > 0)
this.lifeRegen = 0;
this.lifeRegenTime = 0;
this.lifeRegen -= 4;
}
if (this.venom)
{
if (this.lifeRegen > 0)
this.lifeRegen = 0;
this.lifeRegenTime = 0;
this.lifeRegen -= 12;
}
if (this.onFire)
{
if (this.lifeRegen > 0)
this.lifeRegen = 0;
this.lifeRegenTime = 0;
this.lifeRegen -= 8;
}
if (this.onFrostBurn)
{
if (this.lifeRegen > 0)
this.lifeRegen = 0;
this.lifeRegenTime = 0;
this.lifeRegen -= 12;
}
if (this.onFire2)
{
if (this.lifeRegen > 0)
this.lifeRegen = 0;
this.lifeRegenTime = 0;
this.lifeRegen -= 12;
}
if (this.burned)
{
if (this.lifeRegen > 0)
this.lifeRegen = 0;
this.lifeRegenTime = 0;
this.lifeRegen -= 60;
this.moveSpeed *= 0.5f;
}
if (this.suffocating)
{
if (this.lifeRegen > 0)
this.lifeRegen = 0;
this.lifeRegenTime = 0;
this.lifeRegen -= 40;
}
if (this.electrified)
{
if (this.lifeRegen > 0)
this.lifeRegen = 0;
this.lifeRegenTime = 0;
this.lifeRegen -= 8;
if (this.controlLeft || this.controlRight)
this.lifeRegen -= 32;
}
if (this.tongued && Main.expertMode)
{
if (this.lifeRegen > 0)
this.lifeRegen = 0;
this.lifeRegenTime = 0;
this.lifeRegen -= 100;
}
if (this.honey && this.lifeRegen < 0)
{
this.lifeRegen += 4;
if (this.lifeRegen > 0)
this.lifeRegen = 0;
}
if (this.lifeRegen < 0 && this.nebulaLevelLife > 0)
this.lifeRegen = 0;
if (flag && this.lifeRegen < 0)
this.lifeRegen /= 2;
++this.lifeRegenTime;
if (this.crimsonRegen)
++this.lifeRegenTime;
if (this.soulDrain > 0)
this.lifeRegenTime += 2;
if (flag)
{
if (this.lifeRegenTime > 90 && this.lifeRegenTime < 1800)
this.lifeRegenTime = 1800;
this.lifeRegenTime += 4;
this.lifeRegen += 4;
}
if (this.honey)
{
this.lifeRegenTime += 2;
this.lifeRegen += 2;
}
if (this.soulDrain > 0)
{
int num = (5 + this.soulDrain) / 2;
this.lifeRegenTime += num;
this.lifeRegen += num;
}
if (this.whoAmI == Main.myPlayer && Main.campfire)
++this.lifeRegen;
if (this.whoAmI == Main.myPlayer && Main.heartLantern)
this.lifeRegen += 2;
if (this.bleed)
this.lifeRegenTime = 0;
float num1 = 0.0f;
if (this.lifeRegenTime >= 300)
++num1;
if (this.lifeRegenTime >= 600)
++num1;
if (this.lifeRegenTime >= 900)
++num1;
if (this.lifeRegenTime >= 1200)
++num1;
if (this.lifeRegenTime >= 1500)
++num1;
if (this.lifeRegenTime >= 1800)
++num1;
if (this.lifeRegenTime >= 2400)
++num1;
if (this.lifeRegenTime >= 3000)
++num1;
if (flag)
{
float num2 = (float)(this.lifeRegenTime - 3000) / 300f;
if ((double)num2 > 0.0)
{
if ((double)num2 > 30.0)
num2 = 30f;
num1 += num2;
}
}
else if (this.lifeRegenTime >= 3600)
{
++num1;
this.lifeRegenTime = 3600;
}
float num3 = (double)this.velocity.X == 0.0 || this.grappling[0] > 0 ? num1 * 1.25f : num1 * 0.5f;
if (this.crimsonRegen)
num3 *= 1.5f;
if (this.shinyStone)
num3 *= 1.1f;
if (this.whoAmI == Main.myPlayer && Main.campfire)
num3 *= 1.1f;
if (Main.expertMode && !this.wellFed)
{
if (this.shinyStone)
num3 *= 0.75f;
else
num3 /= 2f;
}
if (this.rabid)
{
if (this.shinyStone)
num3 *= 0.75f;
else
num3 /= 2f;
}
float num4 = (float)((double)this.statLifeMax2 / 400.0 * 0.850000023841858 + 0.150000005960464);
this.lifeRegen += (int)Math.Round((double)(num3 * num4));
this.lifeRegenCount += this.lifeRegen;
if (this.palladiumRegen)
this.lifeRegenCount += 6;
if (flag && this.lifeRegen > 0 && this.statLife < this.statLifeMax2)
{
++this.lifeRegenCount;
if (flag && (Main.rand.Next(30000) < this.lifeRegenTime || Main.rand.Next(30) == 0))
{
int index = Dust.NewDust(this.position, this.width, this.height, 55, 0.0f, 0.0f, 200, new Color(), 0.5f);
Main.dust[index].noGravity = true;
Main.dust[index].velocity *= 0.75f;
Main.dust[index].fadeIn = 1.3f;
Vector2 vector2_1 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101));
vector2_1.Normalize();
Vector2 vector2_2 = vector2_1 * ((float)Main.rand.Next(50, 100) * 0.04f);
Main.dust[index].velocity = vector2_2;
vector2_2.Normalize();
Vector2 vector2_3 = vector2_2 * 34f;
Main.dust[index].position = this.Center - vector2_3;
}
}
while (this.lifeRegenCount >= 120)
{
this.lifeRegenCount -= 120;
if (this.statLife < this.statLifeMax2)
{
++this.statLife;
if (this.crimsonRegen)
{
for (int index1 = 0; index1 < 10; ++index1)
{
int index2 = Dust.NewDust(this.position, this.width, this.height, 5, 0.0f, 0.0f, 175, new Color(), 1.75f);
Main.dust[index2].noGravity = true;
Main.dust[index2].velocity *= 0.75f;
int num2 = Main.rand.Next(-40, 41);
int num5 = Main.rand.Next(-40, 41);
Main.dust[index2].position.X += (float)num2;
Main.dust[index2].position.Y += (float)num5;
Main.dust[index2].velocity.X = (float)-num2 * 0.075f;
Main.dust[index2].velocity.Y = (float)-num5 * 0.075f;
}
}
}
if (this.statLife > this.statLifeMax2)
this.statLife = this.statLifeMax2;
}
if (this.burned || this.suffocating || this.tongued && Main.expertMode)
{
while (this.lifeRegenCount <= -600)
{
this.lifeRegenCount += 600;
this.statLife -= 5;
CombatText.NewText(new Microsoft.Xna.Framework.Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height), CombatText.LifeRegen, string.Concat((object)5), false, true);
if (this.statLife <= 0 && this.whoAmI == Main.myPlayer)
{
if (this.suffocating)
this.KillMe(10.0, 0, false, " " + Lang.dt[2]);
else
this.KillMe(10.0, 0, false, " " + Lang.dt[1]);
}
}
}
else
{
while (this.lifeRegenCount <= -120)
{
if (this.lifeRegenCount <= -480)
{
this.lifeRegenCount += 480;
this.statLife -= 4;
CombatText.NewText(new Microsoft.Xna.Framework.Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height), CombatText.LifeRegen, string.Concat((object)4), false, true);
}
else if (this.lifeRegenCount <= -360)
{
this.lifeRegenCount += 360;
this.statLife -= 3;
CombatText.NewText(new Microsoft.Xna.Framework.Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height), CombatText.LifeRegen, string.Concat((object)3), false, true);
}
else if (this.lifeRegenCount <= -240)
{
this.lifeRegenCount += 240;
this.statLife -= 2;
CombatText.NewText(new Microsoft.Xna.Framework.Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height), CombatText.LifeRegen, string.Concat((object)2), false, true);
}
else
{
this.lifeRegenCount += 120;
--this.statLife;
CombatText.NewText(new Microsoft.Xna.Framework.Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height), CombatText.LifeRegen, string.Concat((object)1), false, true);
}
if (this.statLife <= 0 && this.whoAmI == Main.myPlayer)
{
if (this.poisoned || this.venom)
this.KillMe(10.0, 0, false, " " + Lang.dt[0]);
else if (this.electrified)
this.KillMe(10.0, 0, false, " " + Lang.dt[3]);
else
this.KillMe(10.0, 0, false, " " + Lang.dt[1]);
}
}
}
}