public override void OnUpdate()
 {
     if (this.bDesummoned)
     {
         return;
     }
     base.CheckFade();
     bool bChillOutMan = Program.game.xCutsceneMaster.bInCutscene || (this.xPetOwner as PlayerEntity).iFramesWithoutInput > 1800;
     this.iCounter++;
     this.iNextHardUpdate--;
     if (this.bGonnaDie)
     {
         this.MoveInDeath();
         if (this.fDeathSpeed == 0f && CAS.GameMode != StateMaster.GameModes.RogueLike)
         {
             float fMaxDistance = 20f;
             if (this.xResurrectAid.xCurrentResurrector != null)
             {
                 PlayerView xPlayer = this.xResurrectAid.xCurrentResurrector;
                 if (xPlayer.xViewStats.bIsDead || (!Utility.IsWithinRange((int)xPlayer.xEntity.xRenderComponent.iActiveAnimation, 0, 3) && !Utility.IsWithinRange((int)xPlayer.xEntity.xRenderComponent.iActiveAnimation, 512, 515)) || Vector2.Distance(this.xOwner.xTransform.v2Pos, xPlayer.xEntity.xTransform.v2Pos) > fMaxDistance)
                 {
                     if (!xPlayer.xViewStats.bIsDead)
                     {
                         xPlayer.xEntity.xRenderComponent.SwitchAnimation((ushort)(516 + (int)xPlayer.xEntity.byAnimationDirection), Animation.CancelOptions.IgnoreIfPlaying);
                     }
                     this.xResurrectAid.iCounter = 0;
                     this.xResurrectAid.xCurrentResurrector = null;
                     return;
                 }
                 this.xResurrectAid.iCounter++;
                 xPlayer.xEntity.xRenderComponent.SwitchAnimation((ushort)(512 + (int)xPlayer.xEntity.byAnimationDirection), Animation.CancelOptions.IgnoreIfPlaying);
                 if (this.xResurrectAid.iCounter > this.xResurrectAid.iResurrectTick && Program.game.xNetworkInfo.enCurrentRole != NetworkHelperInterface.NetworkRole.Client)
                 {
                     this.Revive();
                     xPlayer.xEntity.xRenderComponent.SwitchAnimation((ushort)(508 + (int)xPlayer.xEntity.byAnimationDirection), Animation.CancelOptions.IgnoreIfPlaying);
                     xPlayer.xEntity.xRenderComponent.fPassedTicks = 12f;
                     Effect_CrossFadeFlash xEfLol = new Effect_CrossFadeFlash(Program.GetTheGame().Content.Load<Texture2D>("GUI/HUD/castbar_filled"), Program.GetTheGame().Content.Load<Texture2D>("GUI/HUD/castbar_flash"), Vector2.Zero, 15, 20, 35);
                     xEfLol.rcFirstTexture.v2OffsetRenderPos = new Vector2(1f, -37f);
                     xEfLol.rcSecondTexture.v2OffsetRenderPos = new Vector2(1f, -37f);
                     Program.game._EffectMaster_AddEffect(xEfLol);
                     return;
                 }
             }
             else if (this.xPetOwner is PlayerEntity)
             {
                 bool bLegit = true;
                 PlayerView xPlayer2 = (this.xPetOwner as PlayerEntity).Owner;
                 if (xPlayer2.xViewStats.bIsDead)
                 {
                     bLegit = false;
                 }
                 if (!Utility.IsWithinRange((int)xPlayer2.xEntity.xRenderComponent.iActiveAnimation, 0, 3) && !Utility.IsWithinRange((int)xPlayer2.xEntity.xRenderComponent.iActiveAnimation, 512, 515))
                 {
                     bLegit = false;
                 }
                 if (Vector2.Distance(this.xOwner.xTransform.v2Pos, xPlayer2.xEntity.xTransform.v2Pos) > fMaxDistance)
                 {
                     bLegit = false;
                 }
                 if (bLegit)
                 {
                     this.xResurrectAid.xCurrentResurrector = xPlayer2;
                     xPlayer2.xGUIStuff.xPetResurrect = this.xResurrectAid;
                     return;
                 }
                 xPlayer2.xGUIStuff.xPetResurrect = null;
             }
         }
         return;
     }
     if (this.xOwner.xRenderComponent.iActiveAnimation == 100)
     {
         return;
     }
     if (this.iCounter > this.iCounterAtLastAttack + 300)
     {
         base.SendClientInstruction(5, new float[0]);
         if (this.iCounter % 3 == 0 && this.xOwner.xBaseStats.iHP < this.xOwner.xBaseStats.iMaxHP)
         {
             this.xOwner.xBaseStats.iHP++;
         }
     }
     float fDistanceFromPlayer = Vector2.Distance(this.xOwner.xTransform.v2Pos, this.xPetOwner.xTransform.v2Pos);
     if (fDistanceFromPlayer > 250f)
     {
         this.enCurrentAction = FrostyFriendLevelOneAI.FrostyFriendAction.GoToPlayer;
         this.ChangeSpeed(1);
         if (fDistanceFromPlayer < 500f)
         {
             if (this.xPlayerLockedOnto != null && this.xPlayerLockedOnto != this.xPetOwner)
             {
                 SortedAnimated x = Program.game._EffectMaster_AddEffect(new SortedAnimated(Vector2.Zero, SortedAnimated.SortedAnimatedEffects._GUIEffects_Emote_Exclamation)) as SortedAnimated;
                 x.xRenderComponent.xTransform = this.xOwner.xTransform;
                 x.xRenderComponent.v2OffsetRenderPos = new Vector2(8f, -13f);
                 x.xRenderComponent.fVirtualHeight = this.xOwner.xRenderComponent.fVirtualHeight;
             }
             this.xPlayerLockedOnto = this.xPetOwner;
         }
         else
         {
             base.TeleportToOwner();
         }
     }
     else if (this.xPlayerLockedOnto != null && (this.xPlayerLockedOnto.xBaseStats.iHP <= 0 || this.xPlayerLockedOnto.xBaseStats.bUntargetable))
     {
         this.xPlayerLockedOnto = null;
     }
     if (this.enCurrentAction != FrostyFriendLevelOneAI.FrostyFriendAction.PostAttackChill && (this.enCurrentAction != FrostyFriendLevelOneAI.FrostyFriendAction.GoToPlayer || fDistanceFromPlayer < 115f) && this.iNextHardUpdate <= 0)
     {
         WorldActor xClosestTarget = Program.GetTheGame()._Enemies_GetClosestEnemyByDistanceToHitbox(this.xOwner.xTransform.v2Pos, 200f, this.xOwner.xCollisionComponent.xMovementCollider);
         if (xClosestTarget != null)
         {
             float fPlayerDistanceToTarget = Vector2.Distance(xClosestTarget.xTransform.v2Pos, this.xPetOwner.xTransform.v2Pos);
             if (fPlayerDistanceToTarget > 300f || (xClosestTarget as Enemy).enType == EnemyCodex.EnemyTypes.Chicken)
             {
                 xClosestTarget = null;
             }
         }
         if (xClosestTarget != null)
         {
             this.enCurrentAction = FrostyFriendLevelOneAI.FrostyFriendAction.Walkin;
         }
         else if (this.xPlayerLockedOnto != this.xPetOwner)
         {
             if (this.xPlayerLockedOnto != null)
             {
                 this.v2RandMoveDir = Vector2.Zero;
             }
             if (fDistanceFromPlayer < 55f)
             {
                 this.enCurrentAction = FrostyFriendLevelOneAI.FrostyFriendAction.Chillin;
             }
             else
             {
                 this.enCurrentAction = FrostyFriendLevelOneAI.FrostyFriendAction.GoToPlayer;
                 xClosestTarget = this.xPetOwner;
             }
         }
         if (this.xPlayerLockedOnto != this.xPetOwner || xClosestTarget != null)
         {
             this.xPlayerLockedOnto = xClosestTarget;
         }
         this.iNextHardUpdate = 20;
     }
     if (this.xOwner.xRenderComponent.GetCurrentAnimation().bIsMoveCancellable && this.v2KnockBackDir == Vector2.Zero && this.v2RandMoveDir != Vector2.Zero)
     {
         this.xOwner.xTransform.v2Pos += this.v2RandMoveDir * this.xOwner.xBaseStats.fMovementSpeed;
         if (this.xOwner.xRenderComponent.iActiveAnimation < 8)
         {
             float fAnimSpeed = 1f;
             if (this.xOwner.xBaseStats.fMovementSpeed > 2f)
             {
                 fAnimSpeed = 1.5f;
             }
             this.xOwner.xRenderComponent.SwitchAnimation((ushort)(4 + Utility.ConvertV2DirectionToClosestByteDirection(this.v2RandMoveDir)), Animation.CancelOptions.IgnoreIfPlaying, fAnimSpeed);
         }
     }
     else if (this.v2KnockBackDir != Vector2.Zero)
     {
         this.xOwner.xTransform.v2Pos += this.v2KnockBackDir;
         this.v2KnockBackDir *= 0.95f;
         if (this.xOwner.xRenderComponent.iActiveAnimation < 4)
         {
             Program.game._EffectMaster_AddEffect(new SortedAnimated(this.xOwner.xTransform.v2Pos + new Vector2((float)(-7 + CAS.RandomInVisual.Next(14)), (float)(-3 + CAS.RandomInVisual.Next(6))), SortedAnimated.SortedAnimatedEffects.ShieldBreakGroundsmoke));
         }
         if (this.v2KnockBackDir.Length() < 1f)
         {
             this.v2KnockBackDir = Vector2.Zero;
         }
     }
     if (this.enCurrentAction == FrostyFriendLevelOneAI.FrostyFriendAction.GoToPlayer)
     {
         if (this.iCounter % 5 == 0)
         {
             if (Vector2.Distance(this.v2LastPos, this.xOwner.xTransform.v2Pos) < 6f)
             {
                 this.iStuckCounter++;
                 if (this.iStuckCounter >= 30)
                 {
                     base.TeleportToOwner();
                 }
             }
             else
             {
                 this.iStuckCounter = 0;
             }
             this.v2LastPos = this.xOwner.xTransform.v2Pos;
         }
         if (fDistanceFromPlayer < 30f)
         {
             this.xOwner.xRenderComponent.SwitchAnimation((ushort)this.xOwner.byAnimationDirection);
             this.enCurrentAction = FrostyFriendLevelOneAI.FrostyFriendAction.Chillin;
             this.xPlayerLockedOnto = null;
             this.ChangeSpeed(0);
             this.v2RandMoveDir = Vector2.Zero;
             this.iTimeChilling = 0;
         }
     }
     if (bChillOutMan && this.enCurrentAction != FrostyFriendLevelOneAI.FrostyFriendAction.GoToPlayer)
     {
         this.enCurrentAction = FrostyFriendLevelOneAI.FrostyFriendAction.Chillin;
         this.v2RandMoveDir = Vector2.Zero;
         this.xPlayerLockedOnto = null;
         if (this.xOwner.xRenderComponent.iActiveAnimation > 3)
         {
             this.xOwner.xRenderComponent.SwitchAnimation((ushort)this.xOwner.byAnimationDirection);
         }
     }
     if (this.enCurrentAction == FrostyFriendLevelOneAI.FrostyFriendAction.PostAttackChill)
     {
         if (this.xPlayerLockedOnto != null && this.iCounterAtLastAttack < this.iCounter - 50)
         {
             Vector2 v2Slash = Utility.RotateDirectionVector(Utility.Normalize(this.xPlayerLockedOnto.xTransform.v2Pos - this.xOwner.xTransform.v2Pos), 1.57079637f) * (float)this.iSlashDir;
             this.v2RandMoveDir = Utility.Normalize(this.xPlayerLockedOnto.xTransform.v2Pos + v2Slash * 50f - this.xOwner.xTransform.v2Pos);
         }
         if (this.iNextHardUpdate <= 0)
         {
             this.enCurrentAction = FrostyFriendLevelOneAI.FrostyFriendAction.Chillin;
         }
     }
     else if (this.xPlayerLockedOnto != null)
     {
         if (this.xPlayerLockedOnto != this.xPetOwner)
         {
             this.ChangeSpeed(0);
         }
         if (this.enCurrentAction == FrostyFriendLevelOneAI.FrostyFriendAction.Walkin || this.enCurrentAction == FrostyFriendLevelOneAI.FrostyFriendAction.GoToPlayer)
         {
             Vector2 v2Pasa = this.xPlayerLockedOnto.xCollisionComponent.GetClosestPositionToHitbox(this.xOwner.xTransform.v2Pos);
             float fDistance = Vector2.Distance(v2Pasa, this.xOwner.xTransform.v2Pos);
             float fMaxAttackDistance = 34f;
             if (fDistance > fMaxAttackDistance || this.enCurrentAction == FrostyFriendLevelOneAI.FrostyFriendAction.GoToPlayer)
             {
                 if (this.iCounter % 20 == 0)
                 {
                     if (Program.game._CollisionMaster_RayCastVsStatic(this.xOwner.xTransform.v2Pos, this.xPlayerLockedOnto.xTransform.v2Pos, 3f, 3, Utility.CreateIntMask(new int[]
                     {
                         30
                     })))
                     {
                         List<PathFindingSystem.PFNode> lxTempPath = Program.game.xLevelMaster.xPathFinding.FindPath(this.xOwner.xTransform.v2Pos, this.xPlayerLockedOnto.xTransform.v2Pos);
                         if (lxTempPath != null && (this.lxPath == null || (!lxTempPath.Contains(this.lxPath[0]) && PathFindingSystem.PathLengthSquared(this.lxPath) > PathFindingSystem.PathLengthSquared(lxTempPath))))
                         {
                             this.lxPath = lxTempPath;
                         }
                     }
                     else
                     {
                         this.lxPath = null;
                     }
                 }
                 if (this.lxPath == null)
                 {
                     this.v2RandMoveDir = Utility.Normalize(this.xPlayerLockedOnto.xTransform.v2Pos - this.xOwner.xTransform.v2Pos);
                 }
                 else
                 {
                     this.v2RandMoveDir = Vector2.Lerp(this.v2RandMoveDir, Vector2.Normalize(this.lxPath[0].v2Position - this.xOwner.xTransform.v2Pos), 0.1f);
                     if (Vector2.Distance(this.lxPath[0].v2Position, this.xOwner.xTransform.v2Pos) <= this.xOwner.xBaseStats.fMovementSpeed)
                     {
                         this.lxPath.RemoveAt(0);
                         if (this.lxPath.Count == 0)
                         {
                             this.lxPath = null;
                         }
                     }
                 }
             }
             else
             {
                 this.iCounterAtLastAttack = this.iCounter;
                 byte byAdd = 0;
                 this.iSlashDir = ((CAS.RandomInLogic.Next(2) == 0) ? 1 : -1);
                 if (CAS.RandomInLogic.Next(2) == 0)
                 {
                     byAdd = 4;
                 }
                 Vector2 v2Point = this.xPlayerLockedOnto.xCollisionComponent.GetClosestPositionToHitbox(this.xOwner.xTransform.v2Pos);
                 if (MathHelper.Distance(this.xOwner.xTransform.v2Pos.X, v2Point.X) < 7f)
                 {
                     this.enCurrentAction = FrostyFriendLevelOneAI.FrostyFriendAction.PostAttackChill;
                     this.iNextHardUpdate = 60;
                     if (this.xOwner.xTransform.v2Pos.Y < this.xPlayerLockedOnto.xTransform.v2Pos.Y)
                     {
                         Program.game._Enemy_EnterAttackAnimation(this.xOwner, (ushort)(10 + byAdd));
                         this.v2RandMoveDir = Vector2.Zero;
                     }
                     else
                     {
                         Program.game._Enemy_EnterAttackAnimation(this.xOwner, (ushort)(8 + byAdd));
                         this.v2RandMoveDir = Vector2.Zero;
                     }
                 }
                 else if (MathHelper.Distance(this.xOwner.xTransform.v2Pos.Y, v2Point.Y) < 7f)
                 {
                     this.enCurrentAction = FrostyFriendLevelOneAI.FrostyFriendAction.PostAttackChill;
                     this.iNextHardUpdate = 60;
                     if (this.xOwner.xTransform.v2Pos.X < this.xPlayerLockedOnto.xTransform.v2Pos.X)
                     {
                         Program.game._Enemy_EnterAttackAnimation(this.xOwner, (ushort)(9 + byAdd));
                         this.v2RandMoveDir = Vector2.Zero;
                     }
                     else
                     {
                         Program.game._Enemy_EnterAttackAnimation(this.xOwner, (ushort)(11 + byAdd));
                         this.v2RandMoveDir = Vector2.Zero;
                     }
                 }
                 else if (MathHelper.Distance(this.xOwner.xTransform.v2Pos.X, v2Point.X) < MathHelper.Distance(this.xOwner.xTransform.v2Pos.Y, v2Point.Y))
                 {
                     if (this.xOwner.xTransform.v2Pos.Y < v2Point.Y)
                     {
                         this.v2RandMoveDir = new Vector2(0f, 1f);
                     }
                     else
                     {
                         this.v2RandMoveDir = new Vector2(0f, -1f);
                     }
                 }
                 else if (this.xOwner.xTransform.v2Pos.X < v2Point.X)
                 {
                     this.v2RandMoveDir = new Vector2(1f, 0f);
                 }
                 else
                 {
                     this.v2RandMoveDir = new Vector2(-1f, 0f);
                 }
             }
         }
     }
     else if (this.enCurrentAction == FrostyFriendLevelOneAI.FrostyFriendAction.Chillin)
     {
         this.iTimeChilling++;
         if (this.iTimeChilling < 180)
         {
             this.xOwner.xRenderComponent.SwitchAnimation((ushort)this.xOwner.byAnimationDirection);
         }
         else if (this.iTimeChilling % 264 == 0)
         {
             float arg_EAF_0 = this.xOwner.xRenderComponent.fPassedTicks;
             this.xOwner.xRenderComponent.SwitchAnimation((ushort)CAS.RandomInVisual.Next(4));
         }
     }
     this.xOwner.xTransform.v2ServerPos = this.xOwner.xTransform.v2Pos;
 }
 public override void OnClientUpdate()
 {
     if (this.bDesummoned)
     {
         return;
     }
     base.CheckFade();
     if (this.bGonnaDie)
     {
         this.MoveInDeath();
         if ((this.xPetOwner as PlayerEntity).Owner == CAS.LocalPlayer && this.fDeathSpeed == 0f && CAS.GameMode != StateMaster.GameModes.RogueLike)
         {
             float fMaxDistance = 20f;
             if (this.xResurrectAid.xCurrentResurrector != null)
             {
                 PlayerView xPlayer = this.xResurrectAid.xCurrentResurrector;
                 if (xPlayer.xViewStats.bIsDead || (!Utility.IsWithinRange((int)xPlayer.xEntity.xRenderComponent.iActiveAnimation, 0, 3) && !Utility.IsWithinRange((int)xPlayer.xEntity.xRenderComponent.iActiveAnimation, 512, 515)) || Vector2.Distance(this.xOwner.xTransform.v2Pos, xPlayer.xEntity.xTransform.v2Pos) > fMaxDistance)
                 {
                     if (!xPlayer.xViewStats.bIsDead)
                     {
                         xPlayer.xEntity.xRenderComponent.SwitchAnimation((ushort)(516 + (int)xPlayer.xEntity.byAnimationDirection), Animation.CancelOptions.IgnoreIfPlaying);
                     }
                     this.xResurrectAid.iCounter = 0;
                     this.xResurrectAid.xCurrentResurrector = null;
                     return;
                 }
                 this.xResurrectAid.iCounter++;
                 xPlayer.xEntity.xRenderComponent.SwitchAnimation((ushort)(512 + (int)xPlayer.xEntity.byAnimationDirection), Animation.CancelOptions.IgnoreIfPlaying);
                 if (this.xResurrectAid.iCounter > this.xResurrectAid.iResurrectTick && Program.game.xNetworkInfo.enCurrentRole != NetworkHelperInterface.NetworkRole.Client)
                 {
                     xPlayer.xEntity.xRenderComponent.SwitchAnimation((ushort)(508 + (int)xPlayer.xEntity.byAnimationDirection), Animation.CancelOptions.IgnoreIfPlaying);
                     xPlayer.xEntity.xRenderComponent.fPassedTicks = 12f;
                     Effect_CrossFadeFlash xEfLol = new Effect_CrossFadeFlash(Program.GetTheGame().Content.Load<Texture2D>("GUI/HUD/castbar_filled"), Program.GetTheGame().Content.Load<Texture2D>("GUI/HUD/castbar_flash"), Vector2.Zero, 15, 20, 35);
                     xEfLol.rcFirstTexture.v2OffsetRenderPos = new Vector2(1f, -37f);
                     xEfLol.rcSecondTexture.v2OffsetRenderPos = new Vector2(1f, -37f);
                     Program.game._EffectMaster_AddEffect(xEfLol);
                     return;
                 }
             }
             else if (this.xPetOwner is PlayerEntity)
             {
                 bool bLegit = true;
                 PlayerView xPlayer2 = (this.xPetOwner as PlayerEntity).Owner;
                 if (xPlayer2.xViewStats.bIsDead)
                 {
                     bLegit = false;
                 }
                 if (!Utility.IsWithinRange((int)xPlayer2.xEntity.xRenderComponent.iActiveAnimation, 0, 3) && !Utility.IsWithinRange((int)xPlayer2.xEntity.xRenderComponent.iActiveAnimation, 512, 515))
                 {
                     bLegit = false;
                 }
                 if (Vector2.Distance(this.xOwner.xTransform.v2Pos, xPlayer2.xEntity.xTransform.v2Pos) > fMaxDistance)
                 {
                     bLegit = false;
                 }
                 if (bLegit)
                 {
                     this.xResurrectAid.xCurrentResurrector = xPlayer2;
                     xPlayer2.xGUIStuff.xPetResurrect = this.xResurrectAid;
                     return;
                 }
                 xPlayer2.xGUIStuff.xPetResurrect = null;
                 return;
             }
         }
     }
     else if (this.v2KnockBackDir != Vector2.Zero)
     {
         this.xOwner.xTransform.v2Pos += this.v2KnockBackDir;
         this.v2KnockBackDir *= 0.95f;
         if (this.xOwner.xRenderComponent.iActiveAnimation < 4)
         {
             Program.game._EffectMaster_AddEffect(new SortedAnimated(this.xOwner.xTransform.v2Pos + new Vector2((float)(-7 + CAS.RandomInVisual.Next(14)), (float)(-3 + CAS.RandomInVisual.Next(6))), SortedAnimated.SortedAnimatedEffects.ShieldBreakGroundsmoke));
         }
         if (this.v2KnockBackDir.Length() < 1f)
         {
             this.v2KnockBackDir = Vector2.Zero;
         }
     }
 }