public void Update()
 {
     if (!m_isActive && SetState(null) == ExpandHammerState.Gone)
     {
         return;
     }
     if (m_isActive && SetState(null) == ExpandHammerState.Gone)
     {
         Vector2 unitBottomLeft = m_room.area.UnitBottomLeft;
         Vector2 unitTopRight   = m_room.area.UnitTopRight;
         int     num            = 0;
         for (int i = 0; i < GameManager.Instance.AllPlayers.Length; i++)
         {
             PlayerController playerController = GameManager.Instance.AllPlayers[i];
             if (playerController && playerController.healthHaver.IsAlive)
             {
                 Vector2 centerPosition = playerController.CenterPosition;
                 if (BraveMathCollege.AABBContains(unitBottomLeft - Vector2.one, unitTopRight + Vector2.one, centerPosition))
                 {
                     num++;
                 }
             }
         }
         if (num == 0)
         {
             Deactivate();
         }
     }
     m_timer = Mathf.Max(0f, m_timer - LocalDeltaTime);
     UpdateState(SetState(null));
 }
        private void BeginHammerState(ExpandHammerState state)
        {
            if (state == ExpandHammerState.InitialDelay)
            {
                TargetAnimator.renderer.enabled    = false;
                HitEffectAnimator.renderer.enabled = false;
                sprite.renderer.enabled            = false;
                m_timer = InitialDelay;
            }
            else if (state == ExpandHammerState.PreSwing)
            {
                if (m_Owner != null)
                {
                    m_targetPlayer = m_Owner;
                }
                else
                {
                    m_targetPlayer = GameManager.Instance.GetRandomActivePlayer();
                }
                if (TracksRandomEnemy)
                {
                    m_SelectedEnemy = m_room.GetRandomActiveEnemy(false);
                    if (DisablesRegularForgeHammers && GameManager.Instance.Dungeon.tileIndices.tilesetId == GlobalDungeonData.ValidTilesets.FORGEGEON)
                    {
                        if (StaticReferenceManager.AllForgeHammers != null && StaticReferenceManager.AllForgeHammers.Count > 0)
                        {
                            List <ForgeHammerController> AllForgeHammers = StaticReferenceManager.AllForgeHammers;
                            for (int i = 0; i < AllForgeHammers.Count; i++)
                            {
                                if (AllForgeHammers[i].transform.position.GetAbsoluteRoom() == m_room)
                                {
                                    AllForgeHammers[i].Deactivate();
                                }
                            }
                        }
                    }
                }
                if (GameManager.Instance.CurrentGameType == GameManager.GameType.COOP_2_PLAYER)
                {
                    List <PlayerController> list = new List <PlayerController>(2);
                    Vector2 unitBottomLeft       = m_room.area.UnitBottomLeft;
                    Vector2 unitTopRight         = m_room.area.UnitTopRight;
                    for (int i = 0; i < GameManager.Instance.AllPlayers.Length; i++)
                    {
                        PlayerController playerController = GameManager.Instance.AllPlayers[i];
                        if (playerController && playerController.healthHaver.IsAlive)
                        {
                            Vector2 centerPosition = playerController.CenterPosition;
                            if (BraveMathCollege.AABBContains(unitBottomLeft - Vector2.one, unitTopRight + Vector2.one, centerPosition))
                            {
                                list.Add(playerController);
                            }
                        }
                    }
                    if (list.Count > 0)
                    {
                        m_targetPlayer = BraveUtility.RandomElement(list);
                    }
                }
                IntVector2 a = m_targetPlayer.CenterPosition.ToIntVector2(VectorConversions.Floor);
                if (ForceLeft)
                {
                    m_attackIsLeft = true;
                }
                else if (ForceRight)
                {
                    m_attackIsLeft = false;
                }
                else
                {
                    int num = 0;
                    while (GameManager.Instance.Dungeon.data[a + IntVector2.Left * num].type != CellType.WALL)
                    {
                        num++;
                    }
                    int num2 = 0;
                    while (GameManager.Instance.Dungeon.data[a + IntVector2.Right * num2].type != CellType.WALL)
                    {
                        num2++;
                    }
                    m_attackIsLeft = (num < num2);
                }
                m_inAnim  = ((!m_attackIsLeft) ? Hammer_Anim_In_Right : Hammer_Anim_In_Left);
                m_outAnim = ((!m_attackIsLeft) ? Hammer_Anim_Out_Right : Hammer_Anim_Out_Left);
                TargetAnimator.StopAndResetFrame();
                if (TracksPlayer | TracksRandomEnemy)
                {
                    TargetAnimator.renderer.enabled = true;
                }
                else
                {
                    TargetAnimator.renderer.enabled = false;
                }
                TargetAnimator.PlayAndDisableRenderer((!m_attackIsLeft) ? "hammer_right_target" : "hammer_left_target");
                m_targetOffset = ((!m_attackIsLeft) ? new Vector2(4.625f, 1.9375f) : new Vector2(1.9375f, 1.9375f));
                m_timer        = FlashDurationBeforeAttack;
            }
            else if (state == ExpandHammerState.Swing)
            {
                sprite.renderer.enabled = true;
                spriteAnimator.Play(m_inAnim);
                ShadowAnimator.renderer.enabled = true;
                ShadowAnimator.Play((!m_attackIsLeft) ? "hammer_right_slam_shadow" : "hammer_left_slam_shadow");
                sprite.HeightOffGround = -2.5f;
                sprite.UpdateZDepth();
                m_additionalTrackTimer = AdditionalTrackingTime;
            }
            else if (state == ExpandHammerState.Grounded)
            {
                if (DoScreenShake)
                {
                    GameManager.Instance.MainCameraController.DoScreenShake(ScreenShake, new Vector2?(specRigidbody.UnitCenter), false);
                }
                specRigidbody.enabled = true;
                specRigidbody.PixelColliders[0].ManualOffsetX = ((!m_attackIsLeft) ? 59 : 16);
                specRigidbody.PixelColliders[1].ManualOffsetX = ((!m_attackIsLeft) ? 59 : 16);
                specRigidbody.ForceRegenerate(null, null);
                specRigidbody.Reinitialize();
                Exploder.DoRadialMinorBreakableBreak(TargetAnimator.sprite.WorldCenter, 4f);
                HitEffectAnimator.renderer.enabled = true;
                HitEffectAnimator.PlayAndDisableRenderer((!m_attackIsLeft) ? "hammer_right_slam_vfx" : "hammer_left_slam_vfx");
                List <SpeculativeRigidbody> overlappingRigidbodies = PhysicsEngine.Instance.GetOverlappingRigidbodies(specRigidbody, null, false);
                for (int j = 0; j < overlappingRigidbodies.Count; j++)
                {
                    if (overlappingRigidbodies[j].gameActor)
                    {
                        Vector2 direction = overlappingRigidbodies[j].UnitCenter - specRigidbody.UnitCenter;
                        if (overlappingRigidbodies[j].gameActor is PlayerController)
                        {
                            PlayerController playerController2 = overlappingRigidbodies[j].gameActor as PlayerController;
                            if (overlappingRigidbodies[j].CollideWithOthers)
                            {
                                if (!playerController2.DodgeRollIsBlink || !playerController2.IsDodgeRolling)
                                {
                                    if (overlappingRigidbodies[j].healthHaver)
                                    {
                                        overlappingRigidbodies[j].healthHaver.ApplyDamage(0.5f, direction, StringTableManager.GetEnemiesString("#FORGE_HAMMER", -1), CoreDamageTypes.None, DamageCategory.Normal, false, null, false);
                                    }
                                    if (overlappingRigidbodies[j].knockbackDoer)
                                    {
                                        overlappingRigidbodies[j].knockbackDoer.ApplyKnockback(direction, KnockbackForcePlayers, false);
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (overlappingRigidbodies[j].healthHaver)
                            {
                                overlappingRigidbodies[j].healthHaver.ApplyDamage(DamageToEnemies, direction, StringTableManager.GetEnemiesString("#FORGE_HAMMER", -1), CoreDamageTypes.None, DamageCategory.Normal, false, null, false);
                            }
                            if (overlappingRigidbodies[j].knockbackDoer)
                            {
                                overlappingRigidbodies[j].knockbackDoer.ApplyKnockback(direction, KnockbackForceEnemies, false);
                            }
                        }
                    }
                }
                PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(specRigidbody, null, false);
                if (DoGoopOnImpact)
                {
                    DeadlyDeadlyGoopManager.GetGoopManagerForGoopType(GoopToDo).AddGoopRect(specRigidbody.UnitCenter + new Vector2(-1f, -1.25f), specRigidbody.UnitCenter + new Vector2(1f, 0.75f));
                }
                if (DoesBulletsOnImpact && m_isActive)
                {
                    ShootPoint.transform.position = specRigidbody.UnitCenter;
                    CellData cell = ShootPoint.transform.position.GetCell();
                    if (cell != null && cell.type != CellType.WALL)
                    {
                        if (!m_bulletSource)
                        {
                            m_bulletSource = ShootPoint.gameObject.GetOrAddComponent <BulletScriptSource>();
                        }
                        m_bulletSource.BulletManager = bulletBank;
                        m_bulletSource.BulletScript  = BulletScript;
                        m_bulletSource.Initialize();
                        if (TracksRandomEnemy && m_Owner != null)
                        {
                            if (bulletBank)
                            {
                                bulletBank.OnProjectileCreated = (Action <Projectile>)Delegate.Combine(bulletBank.OnProjectileCreated, new Action <Projectile>(HandleForgeHammerPostProcessProjectile));

                                /*if (gameObject.GetComponent<AIBulletBank>()) {
                                 *  AIBulletBank aiBulletBank = gameObject.GetComponent<AIBulletBank>();
                                 *  aiBulletBank.Bullets[0].forceCanHitEnemies = true;
                                 * }*/
                            }
                        }
                    }
                }
                m_timer = UnityEngine.Random.Range(MinTimeToRestOnGround, MaxTimeToRestOnGround);
            }
            else if (state == ExpandHammerState.UpSwing)
            {
                spriteAnimator.Play(m_outAnim);
                ShadowAnimator.PlayAndDisableRenderer((!m_attackIsLeft) ? "hammer_right_out_shadow" : "hammer_left_out_shadow");
            }
            else if (state == ExpandHammerState.Gone)
            {
                sprite.renderer.enabled = false;
                m_timer = UnityEngine.Random.Range(MinTimeBetweenAttacks, MaxTimeBetweenAttacks);
            }
        }