Esempio n. 1
0
        private void TurnTableIntoRocket(FlippableCover table)
        {
            GameObject gameObject = (GameObject)ResourceCache.Acquire("Global VFX/VFX_Table_Exhaust");
            Vector2    vector     = DungeonData.GetIntVector2FromDirection(table.DirectionFlipped).ToVector2();
            float      num        = BraveMathCollege.Atan2Degrees(vector);
            Vector3    zero       = Vector3.zero;

            switch (table.DirectionFlipped)
            {
            case DungeonData.Direction.NORTH:
                zero = Vector3.zero;
                break;

            case DungeonData.Direction.EAST:
                zero = new Vector3(-0.5f, 0.25f, 0f);
                break;

            case DungeonData.Direction.SOUTH:
                zero = new Vector3(0f, 0.5f, 1f);
                break;

            case DungeonData.Direction.WEST:
                zero = new Vector3(0.5f, 0.25f, 0f);
                break;
            }
            GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(gameObject, table.specRigidbody.UnitCenter.ToVector3ZisY(0f) + zero, Quaternion.Euler(0f, 0f, num));

            gameObject2.transform.parent = table.specRigidbody.transform;
            Projectile projectile = table.specRigidbody.gameObject.AddComponent <Projectile>();

            projectile.Shooter         = Owner.specRigidbody;
            projectile.Owner           = Owner;
            projectile.baseData.damage = PickupObjectDatabase.GetById(398).GetComponent <TableFlipItem>().DirectHitBonusDamage;
            projectile.baseData.range  = 1000f;
            projectile.baseData.speed  = 20f;
            projectile.baseData.force  = 50f;
            projectile.baseData.UsesCustomAccelerationCurve     = true;
            projectile.baseData.AccelerationCurve               = PickupObjectDatabase.GetById(398).GetComponent <TableFlipItem>().CustomAccelerationCurve;
            projectile.baseData.CustomAccelerationCurveDuration = PickupObjectDatabase.GetById(398).GetComponent <TableFlipItem>().CustomAccelerationCurveDuration;
            projectile.shouldRotate = false;
            projectile.Start();
            projectile.SendInDirection(vector, true, true);
            projectile.collidesWithProjectiles = true;
            projectile.projectileHitHealth     = 20;
            Action <Projectile> value = delegate(Projectile p)
            {
                if (table && table.shadowSprite)
                {
                    table.shadowSprite.renderer.enabled = false;
                }
            };

            projectile.OnDestruction += value;
            ExplosiveModifier explosiveModifier = projectile.gameObject.AddComponent <ExplosiveModifier>();

            explosiveModifier.explosionData = PickupObjectDatabase.GetById(398).GetComponent <TableFlipItem>().ProjectileExplosionData;
            table.PreventPitFalls           = true;
        }
Esempio n. 2
0
 private void HandleTableVolley(TableTechChaosEffectIdentifier identifier, FlippableCover table)
 {
     if (identifier == TableTechChaosEffectIdentifier.TABLE_VOLLEY)
     {
         IntVector2           intVector2FromDirection = DungeonData.GetIntVector2FromDirection(table.DirectionFlipped);
         ProjectileVolleyData sourceVolley            = this.Volley;
         float d = 1f;
         if (this.m_owner && this.m_owner.PlayerHasActiveSynergy("#HIDDEN_TECH_SUPER_CHAOS"))
         {
             sourceVolley = this.VolleyOverride;
             d            = 2f;
         }
         VolleyUtility.FireVolley(sourceVolley, table.sprite.WorldCenter + intVector2FromDirection.ToVector2() * d, intVector2FromDirection.ToVector2(), this.m_owner, false);
     }
 }
        private void DoLaser(FlippableCover obj)
        {
            SpeculativeRigidbody rigidBody = obj.GetComponentInChildren <SpeculativeRigidbody>();

            PlayerController owner  = base.Owner;
            Vector2          vector = DungeonData.GetIntVector2FromDirection(obj.DirectionFlipped).ToVector2();
            BeamController   cont   = BeamToolbox.FreeFireBeamFromAnywhere(lasa, owner, obj.gameObject, rigidBody.UnitCenter, false, vector.ToAngle(), 20, true);


            GameObject gameObject = SpawnManager.SpawnProjectile(lasa.gameObject, rigidBody.UnitCenter, Quaternion.identity, true);
            Projectile component  = gameObject.GetComponent <Projectile>();

            component.Owner = owner;
            BeamController component2 = gameObject.GetComponent <BeamController>();

            component2.chargeDelay     = 0f;
            component2.usesChargeDelay = false;
            component2.Owner           = owner;
            component2.HitsPlayers     = false;
            component2.HitsEnemies     = true;
            component2.Direction       = vector;
            component2.Origin          = rigidBody.UnitCenter;
            GameManager.Instance.Dungeon.StartCoroutine(HandleFreeFiringBeam(component2, rigidBody, 20));
        }
Esempio n. 4
0
 public void Update()
 {
     if (m_WasKicked)
     {
         if (GetAbsoluteParentRoom() == null)
         {
             m_WasKicked           = false;
             willDefinitelyExplode = true;
             SelfDestructOnKick();
         }
         FlippableCover m_Table = GetComponent <FlippableCover>();
         if (m_Table)
         {
             if (m_Table.IsBroken)
             {
                 m_WasKicked           = false;
                 willDefinitelyExplode = true;
                 SelfDestructOnKick();
             }
         }
     }
     if (m_shouldDisplayOutline)
     {
         int num;
         DungeonData.Direction inverseDirection = DungeonData.GetInverseDirection(DungeonData.GetDirectionFromIntVector2(GetFlipDirection(m_lastInteractingPlayer.specRigidbody, out num)));
         if (inverseDirection != m_lastOutlineDirection || sprite.spriteId != m_lastSpriteId)
         {
             SpriteOutlineManager.RemoveOutlineFromSprite(sprite, false);
             SpriteOutlineManager.AddSingleOutlineToSprite <tk2dSprite>(sprite, DungeonData.GetIntVector2FromDirection(inverseDirection), Color.white, 0.25f, 0f);
         }
         m_lastOutlineDirection = inverseDirection;
         m_lastSpriteId         = sprite.spriteId;
     }
     if (leavesGoopTrail && specRigidbody.Velocity.magnitude > 0.1f)
     {
         m_goopElapsed += BraveTime.DeltaTime;
         if (m_goopElapsed > goopFrequency)
         {
             m_goopElapsed -= BraveTime.DeltaTime;
             if (m_goopManager == null)
             {
                 m_goopManager = DeadlyDeadlyGoopManager.GetGoopManagerForGoopType(goopType);
             }
             m_goopManager.AddGoopCircle(sprite.WorldCenter, goopRadius + 0.1f, -1, false, -1);
         }
         if (AllowTopWallTraversal && GameManager.Instance.Dungeon.data.CheckInBoundsAndValid(sprite.WorldCenter.ToIntVector2(VectorConversions.Floor)) && GameManager.Instance.Dungeon.data[sprite.WorldCenter.ToIntVector2(VectorConversions.Floor)].IsFireplaceCell)
         {
             MinorBreakable component = GetComponent <MinorBreakable>();
             if (component && !component.IsBroken)
             {
                 component.Break(Vector2.zero);
                 GameStatsManager.Instance.SetFlag(GungeonFlags.FLAG_ROLLED_BARREL_INTO_FIREPLACE, true);
             }
         }
     }
 }
        private IEnumerator ScoopPlayerToSafety()
        {
            PlayerController m_owner     = m_aiActor.CompanionOwner;
            RoomHandler      currentRoom = m_owner.CurrentRoom;

            if (currentRoom.area.PrototypeRoomNormalSubcategory != PrototypeDungeonRoom.RoomNormalSubCategory.TRAP)
            {
                m_aiActor.aiAnimator.PlayUntilCancelled("idle", false, null, -1f, false);
                yield break;
            }
            bool  hasFoundExit = false;
            float maxDistance  = float.MinValue;
            // This whole thing has been converted to Vector2 to avoid player being embeded into walls by failsafe teleport system (and to prevent Raccoon from doing this too)
            Vector2 mostDistantExit = new Vector2(-1, -1);

            for (int i = 0; i < currentRoom.connectedRooms.Count; i++)
            {
                PrototypeRoomExit exitConnectedToRoom = currentRoom.GetExitConnectedToRoom(currentRoom.connectedRooms[i]);
                if (exitConnectedToRoom != null)
                {
                    IntVector2 a          = exitConnectedToRoom.GetExitAttachPoint() - IntVector2.One;
                    Vector2    exitVector = (a + currentRoom.area.basePosition + DungeonData.GetIntVector2FromDirection(exitConnectedToRoom.exitDirection)).ToVector2();
                    // These adjustements should in most cases result in the Raccoon dropping the player near the exit and not inside the exit which can cause issues sometimes.
                    if (exitConnectedToRoom.exitDirection == DungeonData.Direction.WEST)
                    {
                        exitVector += new Vector2(2, 0.8f);
                    }
                    if (exitConnectedToRoom.exitDirection == DungeonData.Direction.EAST)
                    {
                        exitVector -= new Vector2(2.4f, 0);
                        exitVector += new Vector2(0, 0.8f);
                    }
                    if (exitConnectedToRoom.exitDirection == DungeonData.Direction.NORTH)
                    {
                        exitVector -= new Vector2(0, 2.4f);
                        exitVector += new Vector2(0.8f, 0);
                    }
                    if (exitConnectedToRoom.exitDirection == DungeonData.Direction.SOUTH)
                    {
                        exitVector += new Vector2(0.8f, 2.4f);
                    }
                    hasFoundExit = true;
                    float num = Vector2.Distance(m_owner.CenterPosition, exitVector);
                    if (num > maxDistance)
                    {
                        maxDistance = num; mostDistantExit = exitVector;
                    }
                }
            }
            yield return(null);

            if (!hasFoundExit)
            {
                yield break;
            }
            // If Raccoon gets stuck or gives up trying to path to exit, this will be set to true and checked later.
            bool hasFailed = false;
            CompanionFollowPlayerBehavior followBehavior = m_aiActor.behaviorSpeculator.MovementBehaviors[0] as CompanionFollowPlayerBehavior;

            followBehavior.TemporarilyDisabled = true;
            m_aiActor.PathableTiles            = (CellTypes.FLOOR | CellTypes.PIT);
            m_aiActor.ClearPath();
            m_owner.SetInputOverride("raccoon");
            m_owner.IsEthereal = true;
            m_owner.healthHaver.IsVulnerable = false;
            float cachedSpeed = m_aiActor.MovementSpeed;

            yield return(new WaitForSeconds(1f));

            m_aiActor.MovementSpeed = 4f;
            m_pathingTimeoutTimer2  = 120f;
            yield return(null);

            m_aiActor.aiAnimator.PlayUntilCancelled("raccoon_move", false, null, -1f, false);
            m_aiActor.PathfindToPosition(m_owner.transform.position + new Vector3(1f, 0.1f), null, true, null, null, null, false);
            // Add another timer. If player is close to south walls, Raccoon can't get into position.
            // If this happens he'll grab the player from the closest point he could get to and continue.
            while (!m_aiActor.PathComplete)
            {
                DecrementTimer(ref m_pathingTimeoutTimer2, false);
                if (m_pathingTimeoutTimer2 <= 0)
                {
                    m_aiActor.ClearPath();
                    break;
                }
                yield return(null);
            }
            m_aiActor.sprite.SpriteChanged += UpdatePlayerPosition;
            m_aiActor.aiAnimator.PlayUntilFinished("grab", false, null, -1f, false);
            yield return(null);

            Transform attachPoint = m_aiActor.transform.Find("carry");

            while (m_aiActor.aiAnimator.IsPlaying("grab"))
            {
                Vector2 preferredPrimaryPosition = attachPoint.position.XY() + (m_owner.transform.position.XY() - m_owner.sprite.WorldBottomCenter) + new Vector2(0f, -0.125f);
                m_owner.transform.position = preferredPrimaryPosition;
                m_owner.specRigidbody.Reinitialize();
                yield return(null);
            }
            m_owner.SetIsFlying(true, "raccoon", true, false);
            m_aiActor.MovementSpeed = 12f;
            m_aiActor.ClearPath();
            m_aiActor.PathfindToPosition(mostDistantExit, null, true, null, null, null, false);
            m_aiActor.aiAnimator.PlayUntilCancelled("carry", true, null, -1f, false);
            // Set timeout. If Raccoon gets stuck or for some reason won't let go of the player, he'll be forced to end this operation.
            m_pathingTimeoutTimer = 280f;
            yield return(null);

            while (!m_aiActor.PathComplete)
            {
                if (!hasFailed && !m_aiActor.Path.WillReachFinalGoal)
                {
                    hasFailed = true;
                }
                DecrementTimer(ref m_pathingTimeoutTimer, false);
                if (m_pathingTimeoutTimer <= 0)
                {
                    hasFailed = true;
                    break;
                }
                if (m_owner && m_owner.transform.position.XY() != null)
                {
                    Vector2 v = attachPoint.position.XY() + (m_owner.transform.position.XY() - m_owner.sprite.WorldBottomCenter) + new Vector2(0f, -0.125f);
                    m_owner.transform.position = v;
                    m_owner.specRigidbody.Reinitialize();
                }
                else
                {
                    m_aiActor.ClearPath();
                    hasFailed = true;
                    break;
                }
                yield return(null);
            }
            yield return(new WaitForSeconds(0.8f));

            m_aiActor.sprite.SpriteChanged -= UpdatePlayerPosition;
            m_aiActor.MovementSpeed         = cachedSpeed;
            yield return(null);

            // If Raccoon gets stuck or Raccoon gives up due to pathing fail, we'll use a graceful teleport to the intended exit with screen
            // fade instead of just dropping the player where ever the Racoon gave up at or leaving the player in limbo forever like the original
            // code would have done. (don't want Raccoon giving up and dropping player over a pit or near trap obstacle either. This is a no no! :P )
            if (hasFailed)
            {
                Pixelator.Instance.FadeToBlack(1f, false, 0f);
                yield return(new WaitForSeconds(1.1f));

                m_owner.WarpToPointAndBringCoopPartner(mostDistantExit, false, true);
                yield return(new WaitForSeconds(0.1f));

                Pixelator.Instance.FadeToBlack(1f, true, 0f);
                yield return(new WaitForSeconds(1f));
            }
            m_owner.healthHaver.IsVulnerable = true;
            m_owner.SetIsFlying(false, "raccoon", true, false);
            m_owner.ClearInputOverride("raccoon");
            m_owner.IsEthereal = false;
            yield return(null);

            m_aiActor.PathableTiles            = CellTypes.FLOOR;
            followBehavior.TemporarilyDisabled = false;
            m_aiActor.aiAnimator.PlayUntilCancelled("idle", false, null, -1f, false);
            m_pathingTimeoutTimer  = 0f;
            m_pathingTimeoutTimer2 = 0f;
            yield break;
        }
Esempio n. 6
0
        private void HandleProjectileEffect(TableTechChaosEffectIdentifier identifier, FlippableCover table)
        {
            if (identifier == TableTechChaosEffectIdentifier.PROJECTILE)
            {
                GameObject original = (GameObject)ResourceCache.Acquire("Global VFX/VFX_Table_Exhaust");
                Vector2    vector   = DungeonData.GetIntVector2FromDirection(table.DirectionFlipped).ToVector2();
                float      z        = BraveMathCollege.Atan2Degrees(vector);
                Vector3    zero     = Vector3.zero;
                switch (table.DirectionFlipped)
                {
                case DungeonData.Direction.NORTH:
                    zero = Vector3.zero;
                    break;

                case DungeonData.Direction.EAST:
                    zero = new Vector3(-0.5f, 0.25f, 0f);
                    break;

                case DungeonData.Direction.SOUTH:
                    zero = new Vector3(0f, 0.5f, 1f);
                    break;

                case DungeonData.Direction.WEST:
                    zero = new Vector3(0.5f, 0.25f, 0f);
                    break;
                }
                GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(original, table.specRigidbody.UnitCenter.ToVector3ZisY(0f) + zero, Quaternion.Euler(0f, 0f, z));
                gameObject.transform.parent = table.specRigidbody.transform;
                Projectile projectile = table.specRigidbody.gameObject.AddComponent <Projectile>();
                projectile.Shooter         = base.Owner.specRigidbody;
                projectile.Owner           = base.Owner;
                projectile.baseData.damage = 30f;
                projectile.baseData.range  = 1000f;
                projectile.baseData.speed  = 20f;
                projectile.baseData.force  = 50f;
                projectile.baseData.UsesCustomAccelerationCurve     = true;
                projectile.baseData.AccelerationCurve               = this.CustomAccelerationCurve;
                projectile.baseData.CustomAccelerationCurveDuration = 0.8f;
                projectile.shouldRotate = false;
                projectile.Start();
                projectile.SendInDirection(vector, true, true);
                projectile.collidesWithProjectiles = true;
                projectile.projectileHitHealth     = 20;
                Action <Projectile> value = delegate(Projectile p)
                {
                    if (table && table.shadowSprite)
                    {
                        table.shadowSprite.renderer.enabled = false;
                    }
                };
                projectile.OnDestruction += value;
                ExplosiveModifier explosiveModifier = projectile.gameObject.AddComponent <ExplosiveModifier>();
                explosiveModifier.explosionData = this.ProjectileExplosionData;
                table.PreventPitFalls           = true;
                if (base.Owner && base.Owner.PlayerHasActiveSynergy("#HIDDEN_TECH_SUPER_CHAOS"))
                {
                    HomingModifier homingModifier = projectile.gameObject.AddComponent <HomingModifier>();
                    homingModifier.AssignProjectile(projectile);
                    homingModifier.HomingRadius    = 20f;
                    homingModifier.AngularVelocity = 720f;
                    BounceProjModifier bounceProjModifier = projectile.gameObject.AddComponent <BounceProjModifier>();
                    bounceProjModifier.numberOfBounces    = 4;
                    bounceProjModifier.onlyBounceOffTiles = true;
                }
            }
        }
        private IEnumerator BecomeMimic()
        {
            if (m_hands == null)
            {
                StartCoroutine(DoIntro());
            }

            if (!ChaosConsole.WallMimicsUseRewardManager)
            {
                m_ChaosModeActive = true;
            }
            if (m_GlitchModeActive)
            {
                m_ItemDropOdds += 0.2f; m_FriendlyMimicOdds += 0.2f;
            }

            m_isHidden = false;
            SpeculativeRigidbody specRigidbody = this.specRigidbody;

            specRigidbody.OnRigidbodyCollision = (SpeculativeRigidbody.OnRigidbodyCollisionDelegate)Delegate.Remove(specRigidbody.OnRigidbodyCollision, new SpeculativeRigidbody.OnRigidbodyCollisionDelegate(HandleRigidbodyCollision));
            SpeculativeRigidbody specRigidbody2 = this.specRigidbody;

            specRigidbody2.OnBeamCollision = (SpeculativeRigidbody.OnBeamCollisionDelegate)Delegate.Remove(specRigidbody2.OnBeamCollision, new SpeculativeRigidbody.OnBeamCollisionDelegate(HandleBeamCollision));
            AIAnimator tongueAnimator = aiAnimator.ChildAnimator;

            tongueAnimator.renderer.enabled       = true;
            tongueAnimator.spriteAnimator.enabled = true;
            AIAnimator spitAnimator = tongueAnimator.ChildAnimator;

            spitAnimator.renderer.enabled       = true;
            spitAnimator.spriteAnimator.enabled = true;
            tongueAnimator.PlayUntilFinished("spawn", false, null, -1f, false);
            float delay        = tongueAnimator.CurrentClipLength;
            float timer        = 0f;
            bool  hasPlayedVFX = false;

            while (timer < delay)
            {
                yield return(null);

                timer += BraveTime.DeltaTime;
                if (!hasPlayedVFX && delay - timer < 0.1f)
                {
                    hasPlayedVFX = true;
                    if (WallDisappearVFX)
                    {
                        Vector2 zero  = Vector2.zero;
                        Vector2 zero2 = Vector2.zero;
                        DungeonData.Direction facingDirection = m_facingDirection;
                        if (facingDirection != DungeonData.Direction.SOUTH)
                        {
                            if (facingDirection != DungeonData.Direction.EAST)
                            {
                                if (facingDirection == DungeonData.Direction.WEST)
                                {
                                    zero  = new Vector2(0f, -1f);
                                    zero2 = new Vector2(0f, 1f);
                                }
                            }
                            else
                            {
                                zero  = new Vector2(0f, -1f);
                                zero2 = new Vector2(0f, 1f);
                            }
                        }
                        else
                        {
                            zero  = new Vector2(0f, -1f);
                            zero2 = new Vector2(0f, 1f);
                        }
                        Vector2 min = Vector2.Min(pos1.ToVector2(), pos2.ToVector2()) + zero;
                        Vector2 max = Vector2.Max(pos1.ToVector2(), pos2.ToVector2()) + new Vector2(1f, 1f) + zero2;
                        for (int i = 0; i < 5; i++)
                        {
                            Vector2        v              = BraveUtility.RandomVector2(min, max, new Vector2(0.25f, 0.25f)) + new Vector2(0f, 1f);
                            GameObject     gameObject     = SpawnManager.SpawnVFX(WallDisappearVFX, v, Quaternion.identity);
                            tk2dBaseSprite tk2dBaseSprite = (!gameObject) ? null : gameObject.GetComponent <tk2dBaseSprite>();
                            if (tk2dBaseSprite)
                            {
                                tk2dBaseSprite.HeightOffGround = 8f;
                                tk2dBaseSprite.UpdateZDepth();
                            }
                        }
                    }
                }
            }
            if (!m_failedWallConfigure && m_GlitchModeActive)
            {
                if (aiActor.ParentRoom != null && GlitchEnemyList != null && GlitchEnemyList.Count > 0 && UnityEngine.Random.value <= m_spawnGitchEnemyOdds)
                {
                    float RandomIntervalFloat       = UnityEngine.Random.Range(0.02f, 0.06f);
                    float RandomDispFloat           = UnityEngine.Random.Range(0.1f, 0.16f);
                    float RandomDispIntensityFloat  = UnityEngine.Random.Range(0.1f, 0.4f);
                    float RandomColorProbFloat      = UnityEngine.Random.Range(0.05f, 0.2f);
                    float RandomColorIntensityFloat = UnityEngine.Random.Range(0.1f, 0.25f);

                    int count2 = this.specRigidbody.PixelColliders.Count;
                    this.specRigidbody.PixelColliders.RemoveAt(count2 - 1);
                    this.specRigidbody.PixelColliders.RemoveAt(count2 - 2);
                    StaticReferenceManager.AllShadowSystemDepthHavers.Remove(m_fakeWall.transform);
                    Destroy(m_fakeWall);
                    Destroy(m_fakeCeiling);

                    Vector3 targetPosForSpawn = m_startingPos + DungeonData.GetIntVector2FromDirection(m_facingDirection).ToVector3();
                    while (timer < delay)
                    {
                        aiAnimator.LockFacingDirection = true;
                        aiAnimator.FacingDirection     = DungeonData.GetAngleFromDirection(m_facingDirection);
                        yield return(null);

                        timer += BraveTime.DeltaTime;
                        transform.position = Vector3.Lerp(m_startingPos, targetPosForSpawn, Mathf.InverseLerp(0.42f, 0.58f, timer));
                        this.specRigidbody.Reinitialize();
                    }
                    yield return(null);

                    Vector3 FinalSpawnLocation             = transform.position;
                    Vector3 VFXExplosionLocation           = transform.position;
                    Vector2 VFXExplosionSource             = Vector2.zero;
                    DungeonData.Direction CurrentDirection = m_facingDirection;
                    if (CurrentDirection == DungeonData.Direction.WEST)
                    {
                        FinalSpawnLocation   += new Vector3(2.5f, 3.5f);
                        VFXExplosionLocation += new Vector3(3.5f, 3.5f);
                        VFXExplosionSource    = new Vector2(1, 0);
                    }
                    else if (CurrentDirection == DungeonData.Direction.EAST)
                    {
                        FinalSpawnLocation   += new Vector3(4f, 3.5f);
                        VFXExplosionLocation += new Vector3(3f, 3.5f);
                    }
                    else if (CurrentDirection == DungeonData.Direction.NORTH)
                    {
                        FinalSpawnLocation   += new Vector3(3.5f, 4f);
                        VFXExplosionLocation += new Vector3(3.5f, 3f);
                        VFXExplosionSource    = new Vector2(0, 1);
                    }
                    else if (CurrentDirection == DungeonData.Direction.SOUTH)
                    {
                        FinalSpawnLocation   += new Vector3(3.5f, 1.5f);
                        VFXExplosionLocation += new Vector3(3.5f, 2.5f);
                    }
                    yield return(null);

                    string        SelectedEnemy          = BraveUtility.RandomElement(GlitchEnemyList);
                    ExplosionData wallMimicExplosionData = new ExplosionData();
                    wallMimicExplosionData.CopyFrom(GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultExplosionData);
                    wallMimicExplosionData.damage = 0f;
                    wallMimicExplosionData.force /= 1.6f;

                    if (SelectedEnemy != "RATCORPSE")
                    {
                        Exploder.Explode(VFXExplosionLocation, wallMimicExplosionData, VFXExplosionSource, ignoreQueues: true, damageTypes: CoreDamageTypes.None);
                        GameObject     SpawnVFXObject          = Instantiate((GameObject)ResourceCache.Acquire("Global VFX/VFX_Item_Spawn_Poof"));
                        tk2dBaseSprite SpawnVFXObjectComponent = SpawnVFXObject.GetComponent <tk2dBaseSprite>();
                        SpawnVFXObjectComponent.PlaceAtPositionByAnchor(FinalSpawnLocation + new Vector3(0f, 0.5f, 0f), tk2dBaseSprite.Anchor.MiddleCenter);
                        SpawnVFXObjectComponent.HeightOffGround = 1f;
                        SpawnVFXObjectComponent.UpdateZDepth();
                        AIActor glitchActor = AIActor.Spawn(EnemyDatabase.GetOrLoadByGuid(SelectedEnemy), FinalSpawnLocation, aiActor.ParentRoom, true, AIActor.AwakenAnimationType.Awaken, true);

                        /*if (aiActor.ParentRoom != null && !aiActor.ParentRoom.IsSealed && !glitchActor.IgnoreForRoomClear) {
                         *  if (GameManager.Instance.PrimaryPlayer.CurrentRoom == aiActor.ParentRoom && aiActor.ParentRoom.EverHadEnemies) {
                         *      aiActor.ParentRoom.SealRoom();
                         *  }
                         * }*/
                        PickupObject.ItemQuality targetGlitchEnemyItemQuality = (UnityEngine.Random.value >= 0.2f) ? ((!BraveUtility.RandomBool()) ? PickupObject.ItemQuality.C : PickupObject.ItemQuality.D) : PickupObject.ItemQuality.B;
                        GenericLootTable         glitchEnemyLootTable         = (!BraveUtility.RandomBool()) ? GameManager.Instance.RewardManager.GunsLootTable : GameManager.Instance.RewardManager.ItemsLootTable;
                        PickupObject             glitchEnemyItem = LootEngine.GetItemOfTypeAndQuality <PickupObject>(targetGlitchEnemyItemQuality, glitchEnemyLootTable, false);

                        /*if (BraveUtility.RandomBool()) {
                         *  ChaosUtility.MakeCompanion(glitchActor);
                         * } else {
                         *  ChaosShaders.Instance.ApplyGlitchShader(glitchActor, glitchActor.sprite, true, RandomIntervalFloat, RandomDispFloat, RandomDispIntensityFloat, RandomColorProbFloat, RandomColorIntensityFloat);
                         * }*/

                        ChaosShaders.Instance.ApplyGlitchShader(glitchActor, glitchActor.sprite, true, RandomIntervalFloat, RandomDispFloat, RandomDispIntensityFloat, RandomColorProbFloat, RandomColorIntensityFloat);

                        if (glitchEnemyItem)
                        {
                            glitchActor.AdditionalSafeItemDrops.Add(glitchEnemyItem);
                        }
                    }
                    else
                    {
                        Exploder.Explode(VFXExplosionLocation, wallMimicExplosionData, VFXExplosionSource, ignoreQueues: true, damageTypes: CoreDamageTypes.None);
                        GameObject     SpawnVFXObject          = Instantiate((GameObject)ResourceCache.Acquire("Global VFX/VFX_Item_Spawn_Poof"));
                        tk2dBaseSprite SpawnVFXObjectComponent = SpawnVFXObject.GetComponent <tk2dBaseSprite>();
                        SpawnVFXObjectComponent.PlaceAtPositionByAnchor(FinalSpawnLocation + new Vector3(0f, 0.5f, 0f), tk2dBaseSprite.Anchor.MiddleCenter);
                        SpawnVFXObjectComponent.HeightOffGround = 1f;
                        SpawnVFXObjectComponent.UpdateZDepth();
                        GameObject   spawnedRatCorpseObject = Instantiate(ChaosPrefabs.RatCorpseNPC, FinalSpawnLocation, Quaternion.identity);
                        TalkDoerLite talkdoerComponent      = spawnedRatCorpseObject.GetComponent <TalkDoerLite>();
                        talkdoerComponent.transform.position.XY().GetAbsoluteRoom().RegisterInteractable(talkdoerComponent);
                        talkdoerComponent.transform.position.XY().GetAbsoluteRoom().TransferInteractableOwnershipToDungeon(talkdoerComponent);
                        talkdoerComponent.playmakerFsm.SetState("Set Mode");
                        ChaosUtility.AddHealthHaver(talkdoerComponent.gameObject, 60, flashesOnDamage: false, exploderSpawnsItem: true);
                    }
                    yield return(null);

                    Destroy(aiActor.gameObject);
                    yield break;
                }
            }
            PickupObject.ItemQuality targetQuality = (UnityEngine.Random.value >= 0.2f) ? ((!BraveUtility.RandomBool()) ? PickupObject.ItemQuality.C : PickupObject.ItemQuality.D) : PickupObject.ItemQuality.B;
            GenericLootTable         lootTable     = (!BraveUtility.RandomBool()) ? GameManager.Instance.RewardManager.GunsLootTable : GameManager.Instance.RewardManager.ItemsLootTable;
            PickupObject             item          = LootEngine.GetItemOfTypeAndQuality <PickupObject>(targetQuality, lootTable, false);

            if (item)
            {
                if (m_ChaosModeActive)
                {
                    if (UnityEngine.Random.value <= m_ItemDropOdds)
                    {
                        aiActor.AdditionalSafeItemDrops.Add(item);
                    }
                    else
                    {
                        aiActor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(70));
                        if (BraveUtility.RandomBool())
                        {
                            aiActor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(70));
                        }
                        if (m_GlitchModeActive)
                        {
                            aiActor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(70));
                        }
                    }
                    if (UnityEngine.Random.value <= m_FriendlyMimicOdds)
                    {
                        m_isFriendlyMimic = true;
                    }
                }
                else
                {
                    aiActor.AdditionalSafeItemDrops.Add(item);
                }
            }
            else
            {
                if (m_ChaosModeActive && UnityEngine.Random.value <= m_FriendlyMimicOdds)
                {
                    m_isFriendlyMimic = true;
                }
            }
            aiActor.enabled            = true;
            behaviorSpeculator.enabled = true;
            if (aiActor.ParentRoom != null && aiActor.ParentRoom.IsSealed && !m_isFriendlyMimic)
            {
                aiActor.IgnoreForRoomClear = false;
            }
            // if (m_isFriendlyMimic) { ChaosUtility.MakeCompanion(aiActor); }
            if (m_isFriendlyMimic)
            {
                aiActor.ApplyEffect(GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultPermanentCharmEffect, 1f, null);
            }
            if (!m_failedWallConfigure)
            {
                int count = this.specRigidbody.PixelColliders.Count;
                for (int j = 0; j < count - 2; j++)
                {
                    this.specRigidbody.PixelColliders[j].Enabled = true;
                }
                this.specRigidbody.PixelColliders.RemoveAt(count - 1);
                this.specRigidbody.PixelColliders.RemoveAt(count - 2);
                StaticReferenceManager.AllShadowSystemDepthHavers.Remove(m_fakeWall.transform);
                Destroy(m_fakeWall);
                Destroy(m_fakeCeiling);
            }
            else
            {
                int count = this.specRigidbody.PixelColliders.Count;
                for (int j = 0; j < count; j++)
                {
                    this.specRigidbody.PixelColliders[j].Enabled = true;
                }
            }
            for (int k = 0; k < m_hands.Length; k++)
            {
                m_hands[k].gameObject.SetActive(true);
            }
            aiActor.ToggleRenderers(true);
            if (aiShooter)
            {
                aiShooter.ToggleGunAndHandRenderers(true, "ChaosWallMimicController");
            }
            aiActor.IsGone           = false;
            healthHaver.IsVulnerable = true;
            aiActor.State            = AIActor.ActorState.Normal;
            for (int l = 0; l < m_hands.Length; l++)
            {
                m_hands[l].gameObject.SetActive(false);
            }
            m_isFinished = true;
            delay        = 0.58f;
            timer        = 0f;
            Vector3 targetPos = m_startingPos + DungeonData.GetIntVector2FromDirection(m_facingDirection).ToVector3();

            while (timer < delay)
            {
                aiAnimator.LockFacingDirection = true;
                aiAnimator.FacingDirection     = DungeonData.GetAngleFromDirection(m_facingDirection);
                yield return(null);

                timer += BraveTime.DeltaTime;
                transform.position = Vector3.Lerp(m_startingPos, targetPos, Mathf.InverseLerp(0.42f, 0.58f, timer));
                this.specRigidbody.Reinitialize();
            }
            aiAnimator.LockFacingDirection = false;
            knockbackDoer.SetImmobile(false, "ChaosWallMimicController");
            aiActor.CollisionDamage            = 0.5f;
            aiActor.CollisionKnockbackStrength = m_collisionKnockbackStrength;
            yield break;
        }
 public void Update()
 {
     if (CanAwaken)
     {
         Vector2 vector  = specRigidbody.PixelColliders[0].UnitBottomLeft;
         Vector2 vector2 = vector;
         if (!m_failedWallConfigure)
         {
             vector = specRigidbody.PixelColliders[2].UnitBottomLeft;
         }
         if (m_facingDirection == DungeonData.Direction.SOUTH)
         {
             vector  += new Vector2(0f, -1.5f);
             vector2 += new Vector2(2f, 0f);
         }
         else if (m_facingDirection == DungeonData.Direction.NORTH)
         {
             vector  += new Vector2(0f, 1f);
             vector2 += new Vector2(2f, 3f);
         }
         else if (m_facingDirection == DungeonData.Direction.WEST)
         {
             vector  += new Vector2(-1.5f, 0f);
             vector2 += new Vector2(0f, 2f);
         }
         else if (m_facingDirection == DungeonData.Direction.EAST)
         {
             vector  += new Vector2(1f, 0f);
             vector2 += new Vector2(2.5f, 2f);
         }
         bool flag = false;
         foreach (PlayerController playerController in GameManager.Instance.AllPlayers)
         {
             if (playerController.CanDetectHiddenEnemies)
             {
                 flag = true;
                 if (!m_playerTrueSight)
                 {
                     m_playerTrueSight = true; aiActor.ToggleRenderers(true);
                 }
             }
             if (playerController && playerController.healthHaver.IsAlive && !playerController.IsGhost)
             {
                 Vector2 unitCenter = playerController.specRigidbody.GetUnitCenter(ColliderType.Ground);
                 if (unitCenter.IsWithin(vector, vector2))
                 {
                     if (m_goopDoer)
                     {
                         Vector2 vector3 = specRigidbody.PixelColliders[2].UnitCenter;
                         if (m_facingDirection == DungeonData.Direction.NORTH)
                         {
                             vector3 += Vector2.up;
                         }
                         DeadlyDeadlyGoopManager goopManagerForGoopType = DeadlyDeadlyGoopManager.GetGoopManagerForGoopType(m_goopDoer.goopDefinition);
                         goopManagerForGoopType.TimedAddGoopArc(vector3, 3f, 90f, DungeonData.GetIntVector2FromDirection(m_facingDirection).ToVector2(), 0.2f, null);
                     }
                     StartCoroutine(BecomeMimic());
                 }
             }
         }
         if (!flag && m_playerTrueSight)
         {
             m_playerTrueSight = false; aiActor.ToggleRenderers(false);
         }
     }
 }