// public void Start() { }
        // private void Update() { }

        public void ConfigureOnPlacement(RoomHandler room)
        {
            m_room = room;

            if (!isMusicSwitch)
            {
                if (UnityEngine.Random.value <= 0.01f)
                {
                    Vector3    SpawnPosition          = (transform.position + new Vector3(0.5f, 0, 0));
                    GameObject RealRainbowChestObject = Instantiate(GameManager.Instance.RewardManager.Rainbow_Chest.gameObject, SpawnPosition, Quaternion.identity);
                    if (RealRainbowChestObject && RealRainbowChestObject.GetComponent <Chest>())
                    {
                        Chest RealRainbowChest = RealRainbowChestObject.GetComponent <Chest>();
                        RealRainbowChest.ConfigureOnPlacement(m_room);
                        m_room.RegisterInteractable(RealRainbowChest);
                        ExpandRickRollSpawnNote NoteSpawner = RealRainbowChest.gameObject.AddComponent <ExpandRickRollSpawnNote>();
                        NoteSpawner.ParentRoom           = m_room;
                        NoteSpawner.CachedSpawnLocation  = (transform.position - new Vector3(0, 1.5f, 0));
                        NoteSpawner.CachedSpawnLocation += new Vector3(1, 0, 0);
                        NoteSpawner.Configured           = true;
                        Destroy(gameObject);
                        return;
                    }
                }
                Initialize();
                if (!m_configured)
                {
                    RegisterFakeChestOnMinimap(room);
                }
            }
            else
            {
                if (ExpandStats.youtubeSafeMode)
                {
                    sprite.SetSprite("music_switch_idle_off_001");
                }
                else
                {
                    sprite.SetSprite("music_switch_idle_on_001");
                }
            }
            m_configured = true;
        }
        private void HandleChestRoomSetup()
        {
            AssetBundle          sharedAssets1  = ResourceManager.LoadAssetBundle("shared_auto_001");
            AssetBundle          sharedAssets2  = ResourceManager.LoadAssetBundle("shared_auto_002");
            ExpandObjectDatabase objectDatabase = new ExpandObjectDatabase();

            try {
                DungeonPlaceable ChestPlatform = sharedAssets2.LoadAsset <DungeonPlaceable>("Treasure_Dais_Stone_Carpet");
                GameObject       Chest_Black   = sharedAssets1.LoadAsset <GameObject>("Chest_Black");
                GameObject       Chest_Rainbow = sharedAssets1.LoadAsset <GameObject>("Chest_Rainbow");
                GameObject       Chest_Rat     = sharedAssets1.LoadAsset <GameObject>("Chest_Rat");

                IntVector2 TreasureChestCarpetPosition1 = new IntVector2(8, 29);
                IntVector2 TreasureChestCarpetPosition2 = new IntVector2(8, 54);
                IntVector2 SecretChestPosition1         = new IntVector2(8, 31);
                IntVector2 SecretChestPosition2         = new IntVector2(8, 56);
                GameObject TreasureChestStoneCarpet1    = ChestPlatform.InstantiateObject(m_ParentRoom, TreasureChestCarpetPosition1);
                GameObject TreasureChestStoneCarpet2    = ChestPlatform.InstantiateObject(m_ParentRoom, TreasureChestCarpetPosition2);
                TreasureChestStoneCarpet1.transform.position -= new Vector3(0.55f, 0);
                TreasureChestStoneCarpet2.transform.position -= new Vector3(0.55f, 0);
                TreasureChestStoneCarpet1.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                TreasureChestStoneCarpet2.transform.SetParent(m_ParentRoom.hierarchyParent, true);

                GameObject PlacedBlackChestObject   = ExpandUtility.GenerateDungeonPlacable(Chest_Black, false, true).InstantiateObject(m_ParentRoom, SecretChestPosition1);
                GameObject PlacedRainbowChestObject = ExpandUtility.GenerateDungeonPlacable(Chest_Rainbow, false, true).InstantiateObject(m_ParentRoom, SecretChestPosition2);
                PlacedBlackChestObject.transform.position    += new Vector3(0.5f, 0);
                PlacedRainbowChestObject.transform.position  += new Vector3(0.5f, 0);
                TreasureChestStoneCarpet1.transform.position += new Vector3(0.5f, 0);
                TreasureChestStoneCarpet2.transform.position += new Vector3(0.5f, 0);
                PlacedBlackChestObject.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PlacedRainbowChestObject.transform.SetParent(m_ParentRoom.hierarchyParent, true);

                tk2dBaseSprite PlacedBlackChestSprite = PlacedBlackChestObject.GetComponentInChildren <tk2dBaseSprite>();

                GenericLootTable BlackChestLootTable = GameManager.Instance.RewardManager.ItemsLootTable;

                Chest PlacedBlackChestComponent   = PlacedBlackChestObject.GetComponent <Chest>();
                Chest PlacedRainbowChestComponent = PlacedRainbowChestObject.GetComponent <Chest>();
                PlacedBlackChestComponent.ChestType           = Chest.GeneralChestType.ITEM;
                PlacedBlackChestComponent.lootTable.lootTable = BlackChestLootTable;
                bool LootTableCheck = PlacedBlackChestComponent.lootTable.canDropMultipleItems && PlacedBlackChestComponent.lootTable.overrideItemLootTables != null && PlacedBlackChestComponent.lootTable.overrideItemLootTables.Count > 0;
                if (LootTableCheck)
                {
                    PlacedBlackChestComponent.lootTable.overrideItemLootTables[0] = BlackChestLootTable;
                }
                PlacedBlackChestComponent.overrideMimicChance = 0f;
                PlacedBlackChestComponent.ForceUnlock();
                PlacedBlackChestComponent.PreventFuse = true;
                PlacedRainbowChestComponent.ForceUnlock();
                PlacedRainbowChestComponent.PreventFuse = true;
                m_ParentRoom.RegisterInteractable(PlacedBlackChestComponent);
                m_ParentRoom.RegisterInteractable(PlacedRainbowChestComponent);

                Vector3    SpecialLockedDoorPosition = (new Vector3(9, 52.25f) + m_ParentRoom.area.basePosition.ToVector3());
                GameObject SpecialLockedDoor         = Instantiate(objectDatabase.LockedJailDoor, SpecialLockedDoorPosition, Quaternion.identity);
                SpecialLockedDoor.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                InteractableLock SpecialLockedDoorComponent = SpecialLockedDoor.GetComponentInChildren <InteractableLock>();
                SpecialLockedDoorComponent.lockMode      = InteractableLock.InteractableLockMode.RESOURCEFUL_RAT;
                SpecialLockedDoorComponent.JailCellKeyId = 0;
                tk2dBaseSprite RainbowLockSprite = SpecialLockedDoorComponent.GetComponentInChildren <tk2dBaseSprite>();
                if (RainbowLockSprite != null)
                {
                    ExpandShaders.Instance.ApplyRainbowShader(RainbowLockSprite);
                }

                IntVector2 PuzzleChestPosition1       = new IntVector2(4, 19);
                IntVector2 PuzzleChestPosition2       = new IntVector2(12, 19);
                IntVector2 PuzzleChestPosition3       = new IntVector2(4, 40);
                IntVector2 PuzzleChestPosition4       = new IntVector2(12, 40);
                IntVector2 PuzzleChestPosition5       = new IntVector2(4, 50);
                IntVector2 PuzzleChestPosition6       = new IntVector2(12, 50);
                IntVector2 PuzzleChestCarpetPosition1 = (PuzzleChestPosition1 - new IntVector2(0, 1));
                IntVector2 PuzzleChestCarpetPosition2 = (PuzzleChestPosition2 - new IntVector2(0, 1));
                IntVector2 PuzzleChestCarpetPosition3 = (PuzzleChestPosition3 - new IntVector2(0, 1));
                IntVector2 PuzzleChestCarpetPosition4 = (PuzzleChestPosition4 - new IntVector2(0, 1));
                IntVector2 PuzzleChestCarpetPosition5 = (PuzzleChestPosition5 - new IntVector2(0, 1));
                IntVector2 PuzzleChestCarpetPosition6 = (PuzzleChestPosition6 - new IntVector2(0, 1));

                GameObject PlacedPuzzleRatChest1   = ExpandUtility.GenerateDungeonPlacable(Chest_Rat, false, true).InstantiateObject(m_ParentRoom, PuzzleChestPosition1, false, true);
                GameObject PlacedPuzzleRatChest2   = ExpandUtility.GenerateDungeonPlacable(Chest_Rat, false, true).InstantiateObject(m_ParentRoom, PuzzleChestPosition2, false, true);
                GameObject PlacedPuzzleRatChest3   = ExpandUtility.GenerateDungeonPlacable(Chest_Rat, false, true).InstantiateObject(m_ParentRoom, PuzzleChestPosition3, false, true);
                GameObject PlacedPuzzleRatChest4   = ExpandUtility.GenerateDungeonPlacable(Chest_Rat, false, true).InstantiateObject(m_ParentRoom, PuzzleChestPosition4, false, true);
                GameObject PlacedPuzzleRatChest5   = ExpandUtility.GenerateDungeonPlacable(Chest_Rat, false, true).InstantiateObject(m_ParentRoom, PuzzleChestPosition5, false, true);
                GameObject PlacedPuzzleRatChest6   = ExpandUtility.GenerateDungeonPlacable(Chest_Rat, false, true).InstantiateObject(m_ParentRoom, PuzzleChestPosition6, false, true);
                GameObject PuzzleChestStoneCarpet1 = ChestPlatform.InstantiateObject(m_ParentRoom, PuzzleChestCarpetPosition1);
                GameObject PuzzleChestStoneCarpet2 = ChestPlatform.InstantiateObject(m_ParentRoom, PuzzleChestCarpetPosition2);
                GameObject PuzzleChestStoneCarpet3 = ChestPlatform.InstantiateObject(m_ParentRoom, PuzzleChestCarpetPosition3);
                GameObject PuzzleChestStoneCarpet4 = ChestPlatform.InstantiateObject(m_ParentRoom, PuzzleChestCarpetPosition4);
                GameObject PuzzleChestStoneCarpet5 = ChestPlatform.InstantiateObject(m_ParentRoom, PuzzleChestCarpetPosition5);
                GameObject PuzzleChestStoneCarpet6 = ChestPlatform.InstantiateObject(m_ParentRoom, PuzzleChestCarpetPosition6);
                PlacedPuzzleRatChest1.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PlacedPuzzleRatChest2.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PlacedPuzzleRatChest3.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PlacedPuzzleRatChest4.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PlacedPuzzleRatChest5.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PlacedPuzzleRatChest6.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PuzzleChestStoneCarpet1.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PuzzleChestStoneCarpet2.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PuzzleChestStoneCarpet3.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PuzzleChestStoneCarpet4.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PuzzleChestStoneCarpet5.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PuzzleChestStoneCarpet6.transform.SetParent(m_ParentRoom.hierarchyParent, true);

                Chest PuzzleRatChest1Component = PlacedPuzzleRatChest1.GetComponent <Chest>();
                Chest PuzzleRatChest2Component = PlacedPuzzleRatChest2.GetComponent <Chest>();
                Chest PuzzleRatChest3Component = PlacedPuzzleRatChest3.GetComponent <Chest>();
                Chest PuzzleRatChest4Component = PlacedPuzzleRatChest4.GetComponent <Chest>();
                Chest PuzzleRatChest5Component = PlacedPuzzleRatChest5.GetComponent <Chest>();
                Chest PuzzleRatChest6Component = PlacedPuzzleRatChest6.GetComponent <Chest>();
                PuzzleRatChest1Component.PreventFuse         = true;
                PuzzleRatChest2Component.PreventFuse         = true;
                PuzzleRatChest3Component.PreventFuse         = true;
                PuzzleRatChest4Component.PreventFuse         = true;
                PuzzleRatChest5Component.PreventFuse         = true;
                PuzzleRatChest6Component.PreventFuse         = true;
                PuzzleRatChest1Component.overrideMimicChance = 0f;
                PuzzleRatChest2Component.overrideMimicChance = 0f;
                PuzzleRatChest3Component.overrideMimicChance = 0f;
                PuzzleRatChest4Component.overrideMimicChance = 0f;
                PuzzleRatChest5Component.overrideMimicChance = 0f;
                PuzzleRatChest6Component.overrideMimicChance = 0f;

                float Seed = UnityEngine.Random.value;

                if (Seed <= 0.5f)
                {
                    PuzzleRatChest1Component.forceContentIds = new List <int> {
                        68
                    };
                    PuzzleRatChest2Component.forceContentIds = new List <int> {
                        727, 727
                    };
                }
                else
                {
                    PuzzleRatChest1Component.forceContentIds = new List <int> {
                        727, 727
                    };
                    PuzzleRatChest2Component.forceContentIds = new List <int> {
                        68
                    };
                }
                if (BraveUtility.RandomBool())
                {
                    PuzzleRatChest3Component.forceContentIds = new List <int> {
                        70, 70, 70, 70
                    };
                    PuzzleRatChest4Component.forceContentIds = new List <int> {
                        727, 727
                    };
                }
                else
                {
                    PuzzleRatChest3Component.forceContentIds = new List <int> {
                        727, 727
                    };
                    PuzzleRatChest4Component.forceContentIds = new List <int> {
                        70, 70, 70, 70
                    };
                }
                if (BraveUtility.RandomBool())
                {
                    PuzzleRatChest5Component.forceContentIds = new List <int> {
                        74
                    };
                    PuzzleRatChest6Component.forceContentIds = new List <int> {
                        316
                    };
                }
                else
                {
                    PuzzleRatChest5Component.forceContentIds = new List <int> {
                        316
                    };
                    PuzzleRatChest6Component.forceContentIds = new List <int> {
                        74
                    };
                }

                PuzzleRatChest1Component.ConfigureOnPlacement(m_ParentRoom);
                PuzzleRatChest2Component.ConfigureOnPlacement(m_ParentRoom);
                PuzzleRatChest3Component.ConfigureOnPlacement(m_ParentRoom);
                PuzzleRatChest4Component.ConfigureOnPlacement(m_ParentRoom);
                PuzzleRatChest5Component.ConfigureOnPlacement(m_ParentRoom);
                PuzzleRatChest6Component.ConfigureOnPlacement(m_ParentRoom);
                m_ParentRoom.RegisterInteractable(PuzzleRatChest1Component);
                m_ParentRoom.RegisterInteractable(PuzzleRatChest2Component);
                m_ParentRoom.RegisterInteractable(PuzzleRatChest3Component);
                m_ParentRoom.RegisterInteractable(PuzzleRatChest4Component);
                m_ParentRoom.RegisterInteractable(PuzzleRatChest5Component);
                m_ParentRoom.RegisterInteractable(PuzzleRatChest6Component);

                Vector3 InfoSignPosition = (new Vector3(6, 4) + m_ParentRoom.area.basePosition.ToVector3());

                GameObject ChestPuzzleInfoSign = Instantiate(ExpandPrefabs.Jungle_BlobLostSign, InfoSignPosition, Quaternion.identity);
                ChestPuzzleInfoSign.name = "Lunk's Minigame Sign";
                ChestPuzzleInfoSign.GetComponent <ExpandNoteDoer>().stringKey = "A minigame Lunk created based on a game he used to play in a land far away.\nGuess the right chest to continue forward.\n If you can guess the correct chest 3 times, the ultimate prize shall be gained!";
                m_ParentRoom.RegisterInteractable(ChestPuzzleInfoSign.GetComponent <ExpandNoteDoer>());
            } catch (Exception ex) {
                if (ExpandStats.debugMode)
                {
                    string Message = "[ExpandTheGungeon] Warning: Exception caught in ExpandWestPuzzleRoomController.HandleChestRoomSetup!";
                    ETGModConsole.Log(Message);
                    Debug.Log(Message);
                    Debug.LogException(ex);
                }
            }
            sharedAssets1  = null;
            sharedAssets2  = null;
            objectDatabase = null;
        }
        private void Start()
        {
            PlayerReflection.TargetPlayer = GameManager.Instance.PrimaryPlayer;
            PlayerReflection.MirrorSprite = MirrorSprite;
            if (!isGlitched)
            {
                if (GameManager.Instance.CurrentGameType == GameManager.GameType.COOP_2_PLAYER)
                {
                    CoopPlayerReflection.TargetPlayer = GameManager.Instance.SecondaryPlayer;
                    CoopPlayerReflection.MirrorSprite = MirrorSprite;
                }
                else
                {
                    CoopPlayerReflection.gameObject.SetActive(false);
                }
            }
            else
            {
                PlayerReflection.gameObject.SetActive(false);
                CoopPlayerReflection.gameObject.SetActive(false);
                tk2dBaseSprite[] AllMirrorSprites = gameObject.GetComponents <tk2dBaseSprite>();
                if (AllMirrorSprites != null && AllMirrorSprites.Length > 0)
                {
                    ChaosShaders.Instance.ApplyGlitchShader(null, AllMirrorSprites[0]);
                }
            }

            IntVector2 MirrorChestPosition = (base.transform.position.IntXY(VectorConversions.Round) + new IntVector2(0, -2) - m_ParentRoom.area.basePosition);

            if (spawnBellosChest)
            {
                MirrorChest = ChaosUtility.GenerateChest(MirrorChestPosition, m_ParentRoom, PickupObject.ItemQuality.A, 0, false);
                MirrorChest.forceContentIds = new List <int>()
                {
                    435, 493
                };
            }
            else
            {
                MirrorChest = ChaosUtility.GenerateChest(MirrorChestPosition, m_ParentRoom, null, -1f);
            }
            MirrorChest.PreventFuse = true;
            SpriteOutlineManager.RemoveOutlineFromSprite(MirrorChest.sprite, false);
            Transform transform = MirrorChest.gameObject.transform.Find("Shadow");

            if (transform)
            {
                MirrorChest.ShadowSprite = transform.GetComponent <tk2dSprite>();
            }
            MirrorChest.IsMirrorChest = true;
            MirrorChest.ConfigureOnPlacement(m_ParentRoom);
            m_ParentRoom.RegisterInteractable(MirrorChest);
            if (spawnBellosChest)
            {
                MirrorChest.DeregisterChestOnMinimap();
            }
            if (MirrorChest.majorBreakable)
            {
                MirrorChest.majorBreakable.TemporarilyInvulnerable = true;
            }
            ChestSprite = MirrorChest.sprite;
            ChestSprite.renderer.enabled = false;
            ChestReflection.TargetSprite = ChestSprite;
            ChestReflection.MirrorSprite = MirrorSprite;
            SpeculativeRigidbody specRigidbody = MirrorSprite.specRigidbody;

            specRigidbody.OnRigidbodyCollision = (SpeculativeRigidbody.OnRigidbodyCollisionDelegate)Delegate.Combine(specRigidbody.OnRigidbodyCollision, new SpeculativeRigidbody.OnRigidbodyCollisionDelegate(HandleRigidbodyCollisionWithMirror));
            MinorBreakable componentInChildren = GetComponentInChildren <MinorBreakable>();

            componentInChildren.OnlyBrokenByCode = true;
            componentInChildren.heightOffGround  = 4f;

            IPlayerInteractable[] TableInterfacesInChildren = GameObjectExtensions.GetInterfacesInChildren <IPlayerInteractable>(gameObject);
            for (int i = 0; i < TableInterfacesInChildren.Length; i++)
            {
                if (!m_ParentRoom.IsRegistered(TableInterfacesInChildren[i]))
                {
                    m_ParentRoom.RegisterInteractable(TableInterfacesInChildren[i]);
                }
            }
            // Destroy(gameObject.GetComponent<MirrorController>());

            // SpeculativeRigidbody InteractableRigidMirror = gameObject.GetComponent<SpeculativeRigidbody>();
            // InteractableRigidMirror.Initialize();
            // PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(InteractableRigidMirror, null, false);
        }