public void UpdateFrame(Player mountedPlayer, int state, Vector2 velocity)
{
if (this._frameState != state)
{
this._frameState = state;
this._frameCounter = 0.0f;
}
if (state != 0)
this._idleTime = 0;
if (this._data.emitsLight)
{
Point point = Utils.ToTileCoordinates(mountedPlayer.Center);
Lighting.AddLight(point.X, point.Y, this._data.lightColor.X, this._data.lightColor.Y, this._data.lightColor.Z);
}
switch (this._type)
{
case 5:
if (state != 2)
{
this._frameExtra = 0;
this._frameExtraCounter = 0.0f;
break;
}
break;
case 7:
state = 2;
break;
case 8:
if (state == 0 || state == 1)
{
Vector2 position;
position.X = mountedPlayer.position.X;
position.Y = mountedPlayer.position.Y + (float)mountedPlayer.height;
int num1 = (int)((double)position.X / 16.0);
double num2 = (double)position.Y / 16.0;
float num3 = 0.0f;
float num4 = (float)mountedPlayer.width;
while ((double)num4 > 0.0)
{
float num5 = (float)((num1 + 1) * 16) - position.X;
if ((double)num5 > (double)num4)
num5 = num4;
num3 += Collision.GetTileRotation(position) * num5;
num4 -= num5;
position.X += num5;
++num1;
}
float num6 = num3 / (float)mountedPlayer.width - mountedPlayer.fullRotation;
float num7 = 0.0f;
float num8 = 0.1570796f;
if ((double)num6 < 0.0)
num7 = (double)num6 <= -(double)num8 ? -num8 : num6;
else if ((double)num6 > 0.0)
num7 = (double)num6 >= (double)num8 ? num8 : num6;
if ((double)num7 != 0.0)
{
mountedPlayer.fullRotation += num7;
if ((double)mountedPlayer.fullRotation > 0.785398185253143)
mountedPlayer.fullRotation = 0.7853982f;
if ((double)mountedPlayer.fullRotation < -0.785398185253143)
{
mountedPlayer.fullRotation = -0.7853982f;
break;
}
break;
}
break;
}
break;
case 9:
if (!this._aiming)
{
++this._frameExtraCounter;
if ((double)this._frameExtraCounter >= 12.0)
{
this._frameExtraCounter = 0.0f;
++this._frameExtra;
if (this._frameExtra >= 6)
{
this._frameExtra = 0;
break;
}
break;
}
break;
}
break;
case 10:
bool flag1 = (double)Math.Abs(velocity.X) > (double)this.DashSpeed - (double)this.RunSpeed / 2.0;
if (state == 1)
{
bool flag2 = false;
if (flag1)
{
state = 5;
if (this._frameExtra < 6)
flag2 = true;
++this._frameExtra;
}
else
this._frameExtra = 0;
if (flag2)
{
Vector2 Position = mountedPlayer.Center + new Vector2((float)(mountedPlayer.width * mountedPlayer.direction), 0.0f);
Vector2 vector2_1 = new Vector2(40f, 30f);
float num1 = 6.283185f * Utils.NextFloat(Main.rand);
for (float num2 = 0.0f; (double)num2 < 14.0; ++num2)
{
Dust dust = Main.dust[Dust.NewDust(Position, 0, 0, Utils.SelectRandom<int>(Main.rand, 176, 177, 179), 0.0f, 0.0f, 0, new Color(), 1f)];
Vector2 vector2_2 = Utils.RotatedBy(Vector2.UnitY, (double)num2 * 6.28318548202515 / 14.0 + (double)num1, new Vector2()) * (0.2f * (float)this._frameExtra);
dust.position = Position + vector2_2 * vector2_1;
dust.velocity = vector2_2 + new Vector2(this.RunSpeed - (float)(Math.Sign(velocity.X) * this._frameExtra * 2), 0.0f);
dust.noGravity = true;
dust.scale = (float)(1.0 + (double)Utils.NextFloat(Main.rand) * 0.800000011920929);
dust.fadeIn = Utils.NextFloat(Main.rand) * 2f;
dust.shader = GameShaders.Armor.GetSecondaryShader(mountedPlayer.cMount, mountedPlayer);
}
}
}
if (flag1)
{
Dust dust = Main.dust[Dust.NewDust(mountedPlayer.position, mountedPlayer.width, mountedPlayer.height, Utils.SelectRandom<int>(Main.rand, 176, 177, 179), 0.0f, 0.0f, 0, new Color(), 1f)];
dust.velocity = Vector2.Zero;
dust.noGravity = true;
dust.scale = (float)(0.5 + (double)Utils.NextFloat(Main.rand) * 0.800000011920929);
dust.fadeIn = (float)(1.0 + (double)Utils.NextFloat(Main.rand) * 2.0);
dust.shader = GameShaders.Armor.GetSecondaryShader(mountedPlayer.cMount, mountedPlayer);
break;
}
break;
}
switch (state)
{
case 0:
if (this._data.idleFrameCount != 0)
{
if (this._type == 5)
{
if ((double)this._fatigue != 0.0)
{
if (this._idleTime == 0)
this._idleTimeNext = this._idleTime + 1;
}
else
{
this._idleTime = 0;
this._idleTimeNext = 2;
}
}
else if (this._idleTime == 0)
this._idleTimeNext = Main.rand.Next(900, 1500);
++this._idleTime;
}
++this._frameCounter;
if (this._data.idleFrameCount != 0 && this._idleTime >= this._idleTimeNext)
{
float num1 = (float)this._data.idleFrameDelay;
if (this._type == 5)
num1 *= (float)(2.0 - 1.0 * (double)this._fatigue / (double)this._fatigueMax);
int num2 = (int)((double)(this._idleTime - this._idleTimeNext) / (double)num1);
if (num2 >= this._data.idleFrameCount)
{
if (this._data.idleFrameLoop)
{
this._idleTime = this._idleTimeNext;
this._frame = this._data.idleFrameStart;
}
else
{
this._frameCounter = 0.0f;
this._frame = this._data.standingFrameStart;
this._idleTime = 0;
}
}
else
this._frame = this._data.idleFrameStart + num2;
if (this._type != 5)
break;
this._frameExtra = this._frame;
break;
}
if ((double)this._frameCounter > (double)this._data.standingFrameDelay)
{
this._frameCounter -= (float)this._data.standingFrameDelay;
++this._frame;
}
if (this._frame >= this._data.standingFrameStart && this._frame < this._data.standingFrameStart + this._data.standingFrameCount)
break;
this._frame = this._data.standingFrameStart;
break;
case 1:
float num9;
switch (this._type)
{
case 6:
num9 = this._flipDraw ? velocity.X : -velocity.X;
break;
case 9:
num9 = !this._flipDraw ? Math.Abs(velocity.X) : -Math.Abs(velocity.X);
break;
case 13:
num9 = this._flipDraw ? velocity.X : -velocity.X;
break;
default:
num9 = Math.Abs(velocity.X);
break;
}
this._frameCounter += num9;
if ((double)num9 >= 0.0)
{
if ((double)this._frameCounter > (double)this._data.runningFrameDelay)
{
this._frameCounter -= (float)this._data.runningFrameDelay;
++this._frame;
}
if (this._frame >= this._data.runningFrameStart && this._frame < this._data.runningFrameStart + this._data.runningFrameCount)
break;
this._frame = this._data.runningFrameStart;
break;
}
if ((double)this._frameCounter < 0.0)
{
this._frameCounter += (float)this._data.runningFrameDelay;
--this._frame;
}
if (this._frame >= this._data.runningFrameStart && this._frame < this._data.runningFrameStart + this._data.runningFrameCount)
break;
this._frame = this._data.runningFrameStart + this._data.runningFrameCount - 1;
break;
case 2:
++this._frameCounter;
if ((double)this._frameCounter > (double)this._data.inAirFrameDelay)
{
this._frameCounter -= (float)this._data.inAirFrameDelay;
++this._frame;
}
if (this._frame < this._data.inAirFrameStart || this._frame >= this._data.inAirFrameStart + this._data.inAirFrameCount)
this._frame = this._data.inAirFrameStart;
if (this._type == 4)
{
if ((double)velocity.Y < 0.0)
{
this._frame = 3;
break;
}
this._frame = 6;
break;
}
if (this._type != 5)
break;
this._frameExtraCounter += (float)(6.0 - 4.0 * (double)(this._fatigue / this._fatigueMax));
if ((double)this._frameExtraCounter > (double)this._data.flyingFrameDelay)
{
++this._frameExtra;
this._frameExtraCounter -= (float)this._data.flyingFrameDelay;
}
if (this._frameExtra >= this._data.flyingFrameStart && this._frameExtra < this._data.flyingFrameStart + this._data.flyingFrameCount)
break;
this._frameExtra = this._data.flyingFrameStart;
break;
case 3:
++this._frameCounter;
if ((double)this._frameCounter > (double)this._data.flyingFrameDelay)
{
this._frameCounter -= (float)this._data.flyingFrameDelay;
++this._frame;
}
if (this._frame >= this._data.flyingFrameStart && this._frame < this._data.flyingFrameStart + this._data.flyingFrameCount)
break;
this._frame = this._data.flyingFrameStart;
break;
case 4:
this._frameCounter += (float)(int)(((double)Math.Abs(velocity.X) + (double)Math.Abs(velocity.Y)) / 2.0);
if ((double)this._frameCounter > (double)this._data.swimFrameDelay)
{
this._frameCounter -= (float)this._data.swimFrameDelay;
++this._frame;
}
if (this._frame >= this._data.swimFrameStart && this._frame < this._data.swimFrameStart + this._data.swimFrameCount)
break;
this._frame = this._data.swimFrameStart;
break;
case 5:
float num10;
switch (this._type)
{
case 6:
num10 = this._flipDraw ? velocity.X : -velocity.X;
break;
case 9:
num10 = !this._flipDraw ? Math.Abs(velocity.X) : -Math.Abs(velocity.X);
break;
case 13:
num10 = this._flipDraw ? velocity.X : -velocity.X;
break;
default:
num10 = Math.Abs(velocity.X);
break;
}
this._frameCounter += num10;
if ((double)num10 >= 0.0)
{
if ((double)this._frameCounter > (double)this._data.dashingFrameDelay)
{
this._frameCounter -= (float)this._data.dashingFrameDelay;
++this._frame;
}
if (this._frame >= this._data.dashingFrameStart && this._frame < this._data.dashingFrameStart + this._data.dashingFrameCount)
break;
this._frame = this._data.dashingFrameStart;
break;
}
if ((double)this._frameCounter < 0.0)
{
this._frameCounter += (float)this._data.dashingFrameDelay;
--this._frame;
}
if (this._frame >= this._data.dashingFrameStart && this._frame < this._data.dashingFrameStart + this._data.dashingFrameCount)
break;
this._frame = this._data.dashingFrameStart + this._data.dashingFrameCount - 1;
break;
}
}