using ExIni;
using MyRoomCustom;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using UnityEngine.PostProcessing;

namespace CM3D2.MultipleMaids.Plugin
{
    public partial class MultipleMaids
    {
        public void init2()
        {
            for (int index1 = 0; index1 < GameMain.Instance.CharacterMgr.GetStockMaidCount(); ++index1)
            {
                Maid stockMaid = GameMain.Instance.CharacterMgr.GetStockMaidList()[index1];
                if (goSlot[index1] != null)
                {
                    stockMaid.body0.goSlot = new List<TBodySkin>(goSlot[index1]);
                    for (int index2 = 0; index2 < bodyHit[index1].Count; ++index2)
                    {
                        stockMaid.body0.goSlot[index2].bonehair.bodyhit = bodyHit[index1][index2];
                    }

                    if (!GameMain.Instance.VRMode)
                    {
                        stockMaid.body0.quaDefEyeL.eulerAngles = eyeL[index1];
                        stockMaid.body0.quaDefEyeR.eulerAngles = eyeR[index1];
                    }

                    shodaiFlg[index1] = false;
                }

                if (SkirtListArray[index1] != null)
                {
                    for (int index2 = 0; index2 < stockMaid.body0.goSlot.Count; ++index2)
                    {
                        SetFieldValue8<BoneHair3, DynamicSkirtBone>(stockMaid.body0.goSlot[index2].bonehair3,
                                                                    "m_SkirtBone",
                                                                    SkirtListArray[index1][index2]);
                    }
                }
            }

            for (int index1 = 0; index1 < maxMaidCnt; ++index1)
            {
                if (maidArray[index1])
                {
                    maidArray[index1].StopKuchipakuPattern();
                }

                if (maidArray[index1])
                {
                    maidArray[index1].body0.trsLookTarget = GameMain.Instance.MainCamera.transform;
                }

                if (maidArray[index1] && maidArray[index1].Visible && maidArray[index1].body0.isLoadedBody)
                {
                    maidArray[index1].CrossFade(poseArray[0] + ".anm", false, true, false, 0.0f, 1f);
                    maidArray[index1].SetAutoTwistAll(true);
                    maidArray[index1].body0.MuneYureL(1f);
                    maidArray[index1].body0.MuneYureR(1f);
                    maidArray[index1].body0.jbMuneL.enabled = true;
                    maidArray[index1].body0.jbMuneR.enabled = true;
                }

                if (maidArray[index1])
                {
                    maidArray[index1].boMabataki = true;
                    if (maidArray[index1].body0.isLoadedBody)
                    {
                        Maid maid = maidArray[index1];
                        for (int index2 = 0; index2 < maid.body0.goSlot.Count; ++index2)
                        {
                            List<THair1> fieldValue = GetFieldValue<TBoneHair_, List<THair1>>(maid.body0.goSlot[index2].bonehair, "hair1list");
                            for (int index3 = 0; index3 < fieldValue.Count; ++index3)
                            {
                                fieldValue[index3].SoftG = new Vector3(0.0f, -3f / 1000f, 0.0f);
                            }
                        }
                    }
                }
            }

            goSlot = new List<TBodySkin>[maxMaidCnt * 2];
            bodyHit = new List<TBodyHit>[maxMaidCnt * 2];
            allowUpdate = true;
            okFlg = false;
            isDance = false;
            isDanceChu = false;
            isSavePose = false;
            // bgIndex = 0;
            // bgIndexB = 0;
            bgIndex = bgCombo2.selectedItemIndex = bgCombo.selectedItemIndex = Array.FindIndex(bgArray, bg => bg == "Theater");
            bg.localScale = new Vector3(1f, 1f, 1f);
            softG = new Vector3(0.0f, -3f / 1000f, 0.0f);
            softG2 = new Vector3(0.0f, -0.005f, 0.0f);
            if (!GameMain.Instance.VRMode)
            {
                Bloom fieldValue = GetFieldValue<CameraMain, Bloom>(mainCamera, "m_gcBloom");
                fieldValue.enabled = true;
                fieldValue.bloomIntensity = 2.85f;
                fieldValue.hdr = Bloom.HDRBloomMode.Auto;
                fieldValue.bloomThreshholdColor = new Color(1f, 1f, 1f);
                fieldValue.bloomBlurIterations = 3;
            }

            mainCamera.GetComponent<Camera>().backgroundColor = new Color(0.0f, 0.0f, 0.0f);
            maidCnt = 1;
            editMaid = 0;
            wearIndex = 0;
            bGuiMessage = false;
            inName = "";
            inName2 = "";
            inName3 = "";
            inText = "";
            fontSize = 25;
            isMessage = false;
            GameObject gameObject = GameObject.Find("__GameMain__/SystemUI Root").transform.Find("MessageWindowPanel").gameObject;
            MessageWindowMgr messageWindowMgr = GameMain.Instance.ScriptMgr.adv_kag.MessageWindowMgr;
            new MessageClass(gameObject, messageWindowMgr).Clear();
            messageWindowMgr.CloseMessageWindowPanel();
            SetFieldValue2<UILabel, int>(UTY.GetChildObject(gameObject, "MessageViewer/MsgParent/Message", false).GetComponent<UILabel>(),
                                         "mFontSize",
                                         fontSize);
            ikMaid = 0;
            ikBui = 0;
            faceFlg = false;
            faceFlg2 = false;
            sceneFlg = false;
            poseFlg = false;
            kankyoFlg = false;
            kankyo2Flg = false;
            unLockFlg = false;
            isNamida = false;
            isNamidaH = false;
            isSekimenH = false;
            isHohoH = false;
            isTear1 = false;
            isTear2 = false;
            isTear3 = false;
            isShock = false;
            isYodare = false;
            isHoho = false;
            isHoho2 = false;
            isHohos = false;
            isHohol = false;
            isToothoff = false;
            isNosefook = false;
            isFaceInit = false;
            isPoseInit = false;
            isWear = true;
            isSkirt = true;
            isMekure1 = false;
            isMekure2 = false;
            isZurasi = false;
            isBra = true;
            isPanz = true;
            isHeadset = true;
            isAccUde = true;
            isStkg = true;
            isShoes = true;
            isGlove = true;
            isMegane = true;
            isAccSenaka = true;
            isMaid = true;
            isF6 = false;
            isPanel = true;
            isBloom = false;
            isBloomA = false;
            isBlur = false;
            isBlur2 = false;
            bloom1 = 2.85f;
            bloom2 = 3f;
            bloom3 = 0.0f;
            bloom4 = 0.0f;
            bloom5 = 0.0f;
            blur1 = -3.98f;
            blur4 = -0.75f;
            blur2 = 0.9f;
            blur3 = 4.19f;
            bokashi = 0.0f;
            kamiyure = 0.0f;
            isDepth = false;
            isDepthA = false;
            depth1 = 3f;
            depth2 = 0.1f;
            depth3 = 15f;
            depth4 = 2.5f;
            isFog = false;
            fog1 = 4f;
            fog2 = 1f;
            fog3 = 1f;
            fog4 = 0.0f;
            fog5 = 1f;
            fog6 = 1f;
            fog7 = 1f;
            isSepia = false;
            isSepian = false;
            isBloomS = true;
            isDepthS = false;
            isBlurS = false;
            isFogS = false;
            isHairSetting = true;
            isSkirtSetting = false;
            if (depth_field_ != null)
            {
                depth_field_.enabled = false;
            }

            if (fog_ != null)
            {
                fog_.enabled = false;
            }

            if (sepia_tone_ != null)
            {
                sepia_tone_.enabled = false;
            }

            isCube = false;
            isCube2 = true;
            isCube3 = false;
            isCube4 = true;
            isCubeS = false;
            cubeSize = 0.12f;
            isPoseEdit = false;
            isFaceEdit = false;
            bgmIndex = 0;
            if (sceneLevel == 5)
            {
                bgmIndex = 2;
            }

            effectIndex = 0;
            selectMaidIndex = 0;
            copyIndex = 0;
            selectLightIndex = 0;
            doguBIndex = 0;
            parIndex = 0;
            isEditNo = 0;
            editSelectMaid = null;
            for (int index = 0; index < 10; ++index)
            {
                date[index] = "";
                ninzu[index] = "";
            }

            isDanceStart1F = false;
            isDanceStart1K = false;
            isDanceStart2F = false;
            isDanceStart3F = false;
            isDanceStart3K = false;
            isDanceStart4F = false;
            isDanceStart4K = false;
            isDanceStart5F = false;
            isDanceStart5K = false;
            isDanceStart6F = false;
            isDanceStart6K = false;
            isDanceStart7F = false;
            isDanceStart7V = false;
            isDanceStart8F = false;
            isDanceStart8V = false;
            isDanceStart8P = false;
            isDanceStart9F = false;
            isDanceStart9K = false;
            isDanceStart10F = false;
            isDanceStart11F = false;
            isDanceStart11V = false;
            isDanceStart12F = false;
            isDanceStart13F = false;
            isDanceStart13K = false;
            isDanceStart14F = false;
            isDanceStart14V = false;
            isDanceStart15F = false;
            isDanceStart15V = false;
            for (int index1 = 0; index1 < maxMaidCnt; ++index1)
            {
                danceFace[index1] = 0.0f;
                FaceName[index1] = "";
                FaceName2[index1] = "";
                FaceName3[index1] = "";
                isStop[index1] = false;
                isBone[index1] = false;
                isBoneN[index1] = false;
                poseIndex[index1] = 0;
                itemIndex[index1] = 0;
                itemIndex2[index1] = 0;
                faceIndex[index1] = 0;
                faceBlendIndex[index1] = 0;
                headEyeIndex[index1] = 0;
                isLock[index1] = false;
                isFace[index1] = true;
                mekure1[index1] = false;
                mekure2[index1] = false;
                zurasi[index1] = false;
                mekure1n[index1] = false;
                mekure2n[index1] = false;
                zurasin[index1] = false;
                isLook[index1] = false;
                isLookn[index1] = false;
                lookX[index1] = 0.0f;
                lookY[index1] = -0.0f;
                lookXn[index1] = 0.0f;
                lookYn[index1] = -0.0f;
                voice1[index1] = false;
                voice2[index1] = false;
                voice1n[index1] = false;
                voice2n[index1] = false;
                hanten[index1] = false;
                hantenn[index1] = false;
                kotei[index1] = false;
                xFlg[index1] = false;
                zFlg[index1] = false;
                ikMode[index1] = 0;
                GraphicsUtils.Destroy(gMaid[index1]);
                GraphicsUtils.Destroy(gMaidC[index1]);
                GraphicsUtils.Destroy(gHandL[index1]);
                GraphicsUtils.Destroy(gArmL[index1]);
                GraphicsUtils.Destroy(gHandR[index1]);
                GraphicsUtils.Destroy(gArmR[index1]);
                GraphicsUtils.Destroy(gFootL[index1]);
                GraphicsUtils.Destroy(gHizaL[index1]);
                GraphicsUtils.Destroy(gFootR[index1]);
                GraphicsUtils.Destroy(gHizaR[index1]);
                GraphicsUtils.Destroy(gClavicleL[index1]);
                GraphicsUtils.Destroy(gClavicleR[index1]);
                GraphicsUtils.Destroy(gNeck[index1]);
                GraphicsUtils.Destroy(gSpine[index1]);
                GraphicsUtils.Destroy(gSpine0a[index1]);
                GraphicsUtils.Destroy(gSpine1a[index1]);
                GraphicsUtils.Destroy(gSpine1[index1]);
                GraphicsUtils.Destroy(gPelvis[index1]);
                GraphicsUtils.Destroy(gizmoHandL[index1]);
                GraphicsUtils.Destroy(gizmoHandR[index1]);
                GraphicsUtils.Destroy(gizmoFootL[index1]);
                GraphicsUtils.Destroy(gizmoFootR[index1]);
                GraphicsUtils.Destroy(gizmoNeck[index1]);
                GraphicsUtils.Destroy(gizmoPelvis[index1]);

                HandL1[index1] = null;
                for (int index2 = 0; index2 < 30; ++index2)
                {
                    GraphicsUtils.Destroy(gFinger[index1, index2]);
                }

                for (int index2 = 0; index2 < 12; ++index2)
                {
                    GraphicsUtils.Destroy(gFinger2[index1, index2]);
                }

                isIK[index1] = isIKAll;
                pHandL[index1] = 0;
                pHandR[index1] = 0;
                muneIKL[index1] = false;
                muneIKR[index1] = false;
            }

            if (kami)
            {
                kami.SetActive(false);
            }

            danceCheckIndex = 0;
            for (int index = 0; index < danceCheck.Length; ++index)
            {
                danceCheck[danceCheckIndex] = 1f;
            }

            lightIndex = new List<int>
            {
                0
            };
            lightColorR = new List<float>
            {
                1f
            };
            lightColorG = new List<float>
            {
                1f
            };
            lightColorB = new List<float>
            {
                1f
            };
            lightX = new List<float>
            {
                40f
            };
            lightY = new List<float>
            {
                180f
            };
            lightAkarusa = new List<float>
            {
                0.95f
            };
            lightKage = new List<float>
            {
                0.098f
            };
            lightRange = new List<float>
            {
                50f
            };
            isIdx1 = false;
            isIdx2 = false;
            isIdx3 = false;
            isIdx4 = false;
            bgObject.SetActive(true);
            GameMain.Instance.MainLight.Reset();
            GameMain.Instance.MainLight.SetIntensity(0.95f);
            GameMain.Instance.MainLight.GetComponent<Light>().spotAngle = 30f;
            GameMain.Instance.MainLight.GetComponent<Light>().range = 10f;
            GameMain.Instance.MainLight.GetComponent<Light>().type = LightType.Directional;
            GameMain.Instance.MainLight.gameObject.transform.position = new Vector3(0.0f, 2f, 0.0f);
            for (int index = 0; index < doguBObject.Count; ++index)
            {
                GraphicsUtils.Destroy(doguBObject[index]);
            }

            doguBObject.Clear();
            doguBIndex = 0;
            parIndex = 0;
            doguCombo.selectedItemIndex = 0;
            parCombo.selectedItemIndex = 0;
            for (int index = 1; index < lightList.Count; ++index)
            {
                GraphicsUtils.Destroy(lightList[index]);
            }

            lightList = new List<GameObject>
            {
                GameMain.Instance.MainLight.gameObject
            };
            lightComboList = new GUIContent[lightList.Count];
            lightComboList[0] = new GUIContent("メイン");
            lightCombo.selectedItemIndex = 0;
            selectLightIndex = 0;
            // bgCombo.selectedItemIndex = 0;
            kankyoCombo.selectedItemIndex = 0;
            // bgCombo2.selectedItemIndex = 0;
            itemCombo2.selectedItemIndex = 0;
            slotCombo.selectedItemIndex = 0;
            sortList.Clear();
            maidCallScrollPos = new Vector2(0.0f, 0.0f);
            poseScrollPos = new Vector2(0.0f, 0.0f);
            faceScrollPos = new Vector2(0.0f, 0.0f);
            bgScrollPos = new Vector2(0.0f, 0.0f);
            saveSceneScrollPos = new Vector2(0.0f, 0.0f);
            bg2ScrollPos = new Vector2(0.0f, 0.0f);
            Vignetting component = GameMain.Instance.MainCamera.gameObject.GetComponent<Vignetting>();
            component.mode = Vignetting.AberrationMode.Simple;
            component.intensity = -3.98f;
            component.chromaticAberration = -0.75f;
            component.axialAberration = 1.18f;
            component.blurSpread = 4.19f;
            component.luminanceDependency = 0.494f;
            component.blurDistance = 1.71f;
            component.enabled = false;
            doguIndex.Clear();
            doguSelectIndex = 0;
            for (int index = 0; index < doguObject.Count; ++index)
            {
                if (doguObject[index] != null)
                {
                    GraphicsUtils.Destroy(doguObject[index]);
                    doguObject[index] = null;
                }
            }

            doguObject.Clear();
        }

        public void init()
        {
            isInit = true;
            isVR = GameMain.Instance.VRMode;
            for (int index1 = 0; index1 < GameMain.Instance.CharacterMgr.GetStockMaidCount(); ++index1)
            {
                Maid stockMaid = GameMain.Instance.CharacterMgr.GetStockMaidList()[index1];
                if (goSlot[index1] != null)
                {
                    stockMaid.body0.goSlot = new List<TBodySkin>(goSlot[index1]);
                    for (int index2 = 0; index2 < bodyHit[index1].Count; ++index2)
                    {
                        stockMaid.body0.goSlot[index2].bonehair.bodyhit = bodyHit[index1][index2];
                    }

                    if (!GameMain.Instance.VRMode)
                    {
                        stockMaid.body0.quaDefEyeL.eulerAngles = eyeL[index1];
                        stockMaid.body0.quaDefEyeR.eulerAngles = eyeR[index1];
                    }

                    shodaiFlg[index1] = false;
                }

                if (SkirtListArray[index1] != null)
                {
                    for (int index2 = 0; index2 < stockMaid.body0.goSlot.Count; ++index2)
                    {
                        SetFieldValue8<BoneHair3, DynamicSkirtBone>(stockMaid.body0.goSlot[index2].bonehair3,
                                                                    "m_SkirtBone",
                                                                    SkirtListArray[index1][index2]);
                    }
                }
            }

            for (int index1 = 0; index1 < maxMaidCnt; ++index1)
            {
                if (maidArray[index1])
                {
                    maidArray[index1].StopKuchipakuPattern();
                }

                if (maidArray[index1])
                {
                    maidArray[index1].body0.trsLookTarget = GameMain.Instance.MainCamera.transform;
                }

                if (maidArray[index1] && maidArray[index1].Visible && maidArray[index1].body0.isLoadedBody)
                {
                    maidArray[index1].CrossFade(poseArray[0] + ".anm", false, true, false, 0.0f, 1f);
                    maidArray[index1].SetAutoTwistAll(true);
                    maidArray[index1].body0.MuneYureL(1f);
                    maidArray[index1].body0.MuneYureR(1f);
                    maidArray[index1].body0.jbMuneL.enabled = true;
                    maidArray[index1].body0.jbMuneR.enabled = true;
                }

                if (maidArray[index1])
                {
                    maidArray[index1].body0.SetMask(TBody.SlotID.wear, true);
                    maidArray[index1].body0.SetMask(TBody.SlotID.skirt, true);
                    maidArray[index1].body0.SetMask(TBody.SlotID.bra, true);
                    maidArray[index1].body0.SetMask(TBody.SlotID.panz, true);
                    maidArray[index1].body0.SetMask(TBody.SlotID.mizugi, true);
                    maidArray[index1].body0.SetMask(TBody.SlotID.onepiece, true);
                    if (maidArray[index1].body0.isLoadedBody)
                    {
                        Maid maid = maidArray[index1];
                        for (int index2 = 0; index2 < maid.body0.goSlot.Count; ++index2)
                        {
                            List<THair1> fieldValue = GetFieldValue<TBoneHair_, List<THair1>>(maid.body0.goSlot[index2].bonehair, "hair1list");
                            for (int index3 = 0; index3 < fieldValue.Count; ++index3)
                            {
                                fieldValue[index3].SoftG = new Vector3(0.0f, -3f / 1000f, 0.0f);
                            }
                        }
                    }
                }

                maidArray[index1] = null;
            }

            goSlot = new List<TBodySkin>[maxMaidCnt * 2];
            bodyHit = new List<TBodyHit>[maxMaidCnt * 2];
            allowUpdate = true;
            if (okFlg)
            {
                GameMain.Instance.CharacterMgr.ResetCharaPosAll();
                for (int index = 0; index < GameMain.Instance.CharacterMgr.GetStockMaidCount(); ++index)
                {
                    if (sceneLevel != 5 || index != editMaid)
                    {
                        Maid stockMaid = GameMain.Instance.CharacterMgr.GetStockMaidList()[index];
                        stockMaid.transform.localScale = new Vector3(1f, 1f, 1f);
                        TBody.MaskMode f_eMode = (TBody.MaskMode)Enum.Parse(typeof(TBody.MaskMode), "None");
                        stockMaid.body0.SetMaskMode(f_eMode);
                        stockMaid.boMabataki = true;
                    }
                }

                GameMain.Instance.CharacterMgr.DeactivateCharaAll();
                for (int index = 11; index < GameMain.Instance.CharacterMgr.GetStockMaidCount(); ++index)
                {
                    Maid stockMaid = GameMain.Instance.CharacterMgr.GetStockMaidList()[index];
                    Vector3 zero = Vector3.zero;
                    stockMaid.SetPos(zero);
                    stockMaid.SetRot(zero);
                    stockMaid.SetPosOffset(zero);
                    if (stockMaid.body0 != null)
                    {
                        stockMaid.body0.SetBoneHitHeightY(0.0f);
                    }

                    stockMaid.Visible = false;
                    stockMaid.ActiveSlotNo = -1;
                    stockMaid.DelPrefabAll();
                    if (stockMaid.body0.isLoadedBody)
                    {
                        stockMaid.CrossFade(poseArray[0] + ".anm", false, true, false, 0.0f, 1f);
                        stockMaid.SetAutoTwistAll(true);
                    }

                    stockMaid.boMabataki = true;
                }
            }

            okFlg = false;
            isDance = false;
            isDanceChu = false;
            isSavePose = false;
            // bgIndex = 0;
            // bgIndexB = 0;
            bg.localScale = new Vector3(1f, 1f, 1f);
            softG = new Vector3(0.0f, -3f / 1000f, 0.0f);
            softG2 = new Vector3(0.0f, -0.005f, 0.0f);
            if (!GameMain.Instance.VRMode)
            {
                Bloom fieldValue = GetFieldValue<CameraMain, Bloom>(mainCamera, "m_gcBloom");
                fieldValue.enabled = true;
                fieldValue.bloomIntensity = 2.85f;
                fieldValue.hdr = Bloom.HDRBloomMode.Auto;
                fieldValue.bloomThreshholdColor = new Color(1f, 1f, 1f);
                fieldValue.bloomBlurIterations = 3;
            }

            mainCamera.GetComponent<Camera>().backgroundColor = new Color(0.0f, 0.0f, 0.0f);
            maidCnt = 0;
            wearIndex = 0;
            isF6 = false;
            faceFlg = false;
            faceFlg2 = false;
            sceneFlg = false;
            poseFlg = false;
            kankyoFlg = false;
            kankyo2Flg = false;
            unLockFlg = false;
            inName = "";
            inName2 = "";
            inName3 = "";
            inText = "";
            fontSize = 25;
            bGuiMessage = false;
            isMessage = false;
            GameObject gameObject = GameObject.Find("__GameMain__/SystemUI Root").transform.Find("MessageWindowPanel").gameObject;
            MessageWindowMgr messageWindowMgr = GameMain.Instance.ScriptMgr.adv_kag.MessageWindowMgr;
            new MessageClass(gameObject, messageWindowMgr).Clear();
            messageWindowMgr.CloseMessageWindowPanel();
            SetFieldValue2<UILabel, int>(UTY.GetChildObject(gameObject, "MessageViewer/MsgParent/Message", false).GetComponent<UILabel>(),
                                         "mFontSize",
                                         fontSize);
            ikMaid = 0;
            ikBui = 0;
            isNamida = false;
            isNamidaH = false;
            isSekimenH = false;
            isHohoH = false;
            isTear1 = false;
            isTear2 = false;
            isTear3 = false;
            isShock = false;
            isYodare = false;
            isHoho = false;
            isHoho2 = false;
            isHohos = false;
            isHohol = false;
            isToothoff = false;
            isNosefook = false;
            isFaceInit = false;
            isPoseInit = false;
            isWear = true;
            isSkirt = true;
            isMekure1 = false;
            isMekure2 = false;
            isZurasi = false;
            isBra = true;
            isPanz = true;
            isHeadset = true;
            isAccUde = true;
            isStkg = true;
            isShoes = true;
            isGlove = true;
            isMegane = true;
            isAccSenaka = true;
            isMaid = true;
            isPanel = true;
            isBloom = false;
            isBloomA = false;
            isBlur = false;
            isBlur2 = false;
            bloom1 = 2.85f;
            bloom2 = 3f;
            bloom3 = 0.0f;
            bloom4 = 0.0f;
            bloom5 = 0.0f;
            blur1 = -3.98f;
            blur4 = -0.75f;
            blur2 = 0.9f;
            blur3 = 4.19f;
            bokashi = 0.0f;
            kamiyure = 0.0f;
            isDepth = false;
            isDepthA = false;
            depth1 = 3f;
            depth2 = 0.1f;
            depth3 = 15f;
            depth4 = 2.5f;
            isFog = false;
            fog1 = 4f;
            fog2 = 1f;
            fog3 = 1f;
            fog4 = 0.0f;
            fog5 = 1f;
            fog6 = 1f;
            fog7 = 1f;
            isSepia = false;
            isSepian = false;
            isBloomS = true;
            isDepthS = false;
            isBlurS = false;
            isFogS = false;
            isHairSetting = true;
            isSkirtSetting = false;
            if (depth_field_ != null)
            {
                depth_field_.enabled = false;
            }

            if (fog_ != null)
            {
                fog_.enabled = false;
            }

            if (sepia_tone_ != null)
            {
                sepia_tone_.enabled = false;
            }

            isCube = false;
            isCube2 = true;
            isCube3 = false;
            isCube4 = true;
            isCubeS = false;
            cubeSize = 0.12f;
            isPoseEdit = false;
            isFaceEdit = false;
            bgmIndex = 0;
            if (sceneLevel == 5)
            {
                bgmIndex = 2;
            }

            effectIndex = 0;
            selectMaidIndex = 0;
            copyIndex = 0;
            selectLightIndex = 0;
            doguBIndex = 0;
            parIndex = 0;
            isEditNo = 0;
            editSelectMaid = null;
            for (int index = 0; index < 10; ++index)
            {
                date[index] = "";
                ninzu[index] = "";
            }

            isDanceStart1F = false;
            isDanceStart1K = false;
            isDanceStart2F = false;
            isDanceStart3F = false;
            isDanceStart3K = false;
            isDanceStart4F = false;
            isDanceStart4K = false;
            isDanceStart5F = false;
            isDanceStart5K = false;
            isDanceStart6F = false;
            isDanceStart6K = false;
            isDanceStart7F = false;
            isDanceStart7V = false;
            isDanceStart8F = false;
            isDanceStart8V = false;
            isDanceStart8P = false;
            isDanceStart9F = false;
            isDanceStart9K = false;
            isDanceStart10F = false;
            isDanceStart11F = false;
            isDanceStart11V = false;
            isDanceStart12F = false;
            isDanceStart13F = false;
            isDanceStart13K = false;
            isDanceStart14F = false;
            isDanceStart14V = false;
            isDanceStart15F = false;
            isDanceStart15V = false;
            for (int index1 = 0; index1 < maxMaidCnt; ++index1)
            {
                danceFace[index1] = 0.0f;
                FaceName[index1] = "";
                FaceName2[index1] = "";
                FaceName3[index1] = "";
                isStop[index1] = false;
                isBone[index1] = false;
                isBoneN[index1] = false;
                poseIndex[index1] = 0;
                itemIndex[index1] = 0;
                itemIndex2[index1] = 0;
                faceIndex[index1] = 0;
                faceBlendIndex[index1] = 0;
                headEyeIndex[index1] = 0;
                isLock[index1] = false;
                isFace[index1] = true;
                mekure1[index1] = false;
                mekure2[index1] = false;
                zurasi[index1] = false;
                mekure1n[index1] = false;
                mekure2n[index1] = false;
                zurasin[index1] = false;
                isLook[index1] = false;
                isLookn[index1] = false;
                lookX[index1] = 0.0f;
                lookY[index1] = -0.0f;
                lookXn[index1] = 0.0f;
                lookYn[index1] = -0.0f;
                voice1[index1] = false;
                voice2[index1] = false;
                voice1n[index1] = false;
                voice2n[index1] = false;
                hanten[index1] = false;
                hantenn[index1] = false;
                kotei[index1] = false;
                xFlg[index1] = false;
                zFlg[index1] = false;
                ikMode[index1] = 0;
                GraphicsUtils.Destroy(gMaid[index1]);
                GraphicsUtils.Destroy(gMaidC[index1]);
                GraphicsUtils.Destroy(gHandL[index1]);
                GraphicsUtils.Destroy(gArmL[index1]);
                GraphicsUtils.Destroy(gHandR[index1]);
                GraphicsUtils.Destroy(gArmR[index1]);
                GraphicsUtils.Destroy(gFootL[index1]);
                GraphicsUtils.Destroy(gHizaL[index1]);
                GraphicsUtils.Destroy(gFootR[index1]);
                GraphicsUtils.Destroy(gHizaR[index1]);
                GraphicsUtils.Destroy(gClavicleL[index1]);
                GraphicsUtils.Destroy(gClavicleR[index1]);
                GraphicsUtils.Destroy(gNeck[index1]);
                GraphicsUtils.Destroy(gSpine[index1]);
                GraphicsUtils.Destroy(gSpine0a[index1]);
                GraphicsUtils.Destroy(gSpine1a[index1]);
                GraphicsUtils.Destroy(gSpine1[index1]);
                GraphicsUtils.Destroy(gPelvis[index1]);
                GraphicsUtils.Destroy(gizmoHandL[index1]);
                GraphicsUtils.Destroy(gizmoHandR[index1]);
                GraphicsUtils.Destroy(gizmoFootL[index1]);
                GraphicsUtils.Destroy(gizmoFootR[index1]);
                GraphicsUtils.Destroy(gizmoNeck[index1]);
                GraphicsUtils.Destroy(gizmoPelvis[index1]);

                HandL1[index1] = null;
                for (int index2 = 0; index2 < 30; ++index2)
                {
                    GraphicsUtils.Destroy(gFinger[index1, index2]);
                }

                for (int index2 = 0; index2 < 12; ++index2)
                {
                    GraphicsUtils.Destroy(gFinger2[index1, index2]);
                }

                isIK[index1] = isIKAll;
                pHandL[index1] = 0;
                pHandR[index1] = 0;
                muneIKL[index1] = false;
                muneIKR[index1] = false;
            }

            if (kami)
            {
                kami.SetActive(false);
            }

            danceCheckIndex = 0;
            for (int index = 0; index < danceCheck.Length; ++index)
            {
                danceCheck[danceCheckIndex] = 1f;
            }

            lightIndex = new List<int>
            {
                0
            };
            lightColorR = new List<float>
            {
                1f
            };
            lightColorG = new List<float>
            {
                1f
            };
            lightColorB = new List<float>
            {
                1f
            };
            lightX = new List<float>
            {
                40f
            };
            lightY = new List<float>
            {
                180f
            };
            lightAkarusa = new List<float>
            {
                0.95f
            };
            lightKage = new List<float>
            {
                0.098f
            };
            lightRange = new List<float>
            {
                50f
            };
            isIdx1 = false;
            isIdx2 = false;
            isIdx3 = false;
            isIdx4 = false;
            GraphicsUtils.Destroy(cameraObj);
            GraphicsUtils.Destroy(subcamera);
            bgObject.SetActive(true);
            GameMain.Instance.MainLight.Reset();
            GameMain.Instance.MainLight.SetIntensity(0.95f);
            GameMain.Instance.MainLight.GetComponent<Light>().spotAngle = 30f;
            GameMain.Instance.MainLight.GetComponent<Light>().range = 10f;
            GameMain.Instance.MainLight.GetComponent<Light>().type = LightType.Directional;
            GameMain.Instance.MainLight.gameObject.transform.position = new Vector3(0.0f, 2f, 0.0f);
            if (!GameMain.Instance.VRMode)
            {
                m_material = new Material(Shader.Find("Transparent/Diffuse"))
                {
                    color = new Color(0.4f, 0.4f, 1f, 0.8f)
                };
                m_UOCamera = GetFieldValue<CameraMain, UltimateOrbitCamera>(mainCamera, "m_UOCamera");
                if (sceneLevel == 3)
                {
                    m_UOCamera.enabled = true;
                }
            }

            for (int index = 0; index < doguBObject.Count; ++index)
            {
                GraphicsUtils.Destroy(doguBObject[index]);
            }

            doguBObject.Clear();
            doguBIndex = 0;
            parIndex = 0;
            doguCombo.selectedItemIndex = 0;
            parCombo.selectedItemIndex = 0;
            for (int index = 1; index < lightList.Count; ++index)
            {
                GraphicsUtils.Destroy(lightList[index]);
            }

            lightList = new List<GameObject>
            {
                GameMain.Instance.MainLight.gameObject
            };
            lightComboList = new GUIContent[lightList.Count];
            lightComboList[0] = new GUIContent("メイン");
            lightCombo.selectedItemIndex = 0;
            selectLightIndex = 0;
            // bgCombo.selectedItemIndex = 0;
            kankyoCombo.selectedItemIndex = 0;
            // bgCombo2.selectedItemIndex = 0;
            itemCombo2.selectedItemIndex = 0;
            slotCombo.selectedItemIndex = 0;
            sortList.Clear();
            maidCallScrollPos = new Vector2(0.0f, 0.0f);
            poseScrollPos = new Vector2(0.0f, 0.0f);
            faceScrollPos = new Vector2(0.0f, 0.0f);
            bgScrollPos = new Vector2(0.0f, 0.0f);
            saveSceneScrollPos = new Vector2(0.0f, 0.0f);
            bg2ScrollPos = new Vector2(0.0f, 0.0f);
            if (!GameMain.Instance.VRMode)
            {
                Vignetting component = GameMain.Instance.MainCamera.gameObject.GetComponent<Vignetting>();
                component.mode = Vignetting.AberrationMode.Simple;
                component.intensity = -3.98f;
                component.chromaticAberration = -0.75f;
                component.axialAberration = 1.18f;
                component.blurSpread = 4.19f;
                component.luminanceDependency = 0.494f;
                component.blurDistance = 1.71f;
                component.enabled = false;
            }

            doguIndex.Clear();
            doguSelectIndex = 0;
            for (int index = 0; index < doguObject.Count; ++index)
            {
                if (doguObject[index] != null)
                {
                    GraphicsUtils.Destroy(doguObject[index]);
                    doguObject[index] = null;
                }
            }

            doguObject.Clear();
            string path1 = Path.GetFullPath(".\\") + "Mod\\MultipleMaidsPose";
            if (!File.Exists(path1))
            {
                Directory.CreateDirectory(path1);
            }

            int countS = this.countS;
            Action<string, List<string>> action1 = (path, result_list) =>
                                                            {
                                                                string[] files = Directory.GetFiles(path);
                                                                this.countS = 0;
                                                                for (int index = 0; index < files.Length; ++index)
                                                                {
                                                                    if (Path.GetExtension(files[index]) == ".anm")
                                                                    {
                                                                        strListS.Add(files[index].Split('\\')[files[index]
                                                                                                              .Split('\\').Length - 1]
                                                                                                 .Split('.')[0] + "　　　　　　　　　　　　　　　　　　　　/"
                                                                                                                + files[index]);
                                                                        ++this.countS;
                                                                    }
                                                                }
                                                            };
            List<string> stringList1 = new List<string>();
            action1(path1, stringList1);
            if (this.countS != countS)
            {
                poseArray = null;
            }

            if (poseArray != null)
            {
                return;
            }

            strList2 = new List<string>();
            strListE = new List<string>();
            strListE2 = new List<string>();
            strListS = new List<string>();
            strListD = new List<string>();
            strS = "";
            List<string> stringList2 = new List<string>
            {
                string.Empty
            };
            stringList2.AddRange(GameUty.PathList);
            List<string> bgList2 = new List<string>();
            Action<string> action2 = strFileName =>
                                              {
                                                  if (!GameUty.FileSystem.IsExistentFile(strFileName))
                                                  {
                                                      return;
                                                  }

                                                  using (AFileBase file = GameUty.FileSystem.FileOpen(strFileName))
                                                  {
                                                      using (CsvParser csvParser = new CsvParser())
                                                      {
                                                          csvParser.Open(file);
                                                          for (int cell_y = 1; cell_y < csvParser.max_cell_y; ++cell_y)
                                                          {
                                                              if (csvParser.IsCellToExistData(0, cell_y))
                                                              {
                                                                  bgList2.Add(csvParser.GetCellAsString(1, cell_y));
                                                              }
                                                          }
                                                      }
                                                  }
                                              };
            action2("edit_bg.nei");
            for (int index = 0; index < stringList2.Count; ++index)
            {
                action2("edit_bg_" + stringList2[index] + ".nei");
            }

            List<string> stringList3 = new List<string>();
            for (int index1 = 0; index1 < bgList2.Count; ++index1)
            {
                bool flag = false;
                for (int index2 = 0; index2 < bgArray21.Length; ++index2)
                {
                    if (bgList2[index1] == bgArray21[index2])
                    {
                        flag = true;
                    }
                }

                if (!flag && bgList2[index1] != "HoneymoonRoom" && bgList2[index1] != "ClassRoom_Play" && bgList2[index1] != "BigSight"
                    && bgList2[index1] != "PrivateRoom" && bgList2[index1] != "Sea_Night" && bgList2[index1] != "Yashiki")
                {
                    stringList3.Add(bgList2[index1]);
                }
            }

            if (GameMain.Instance.BgMgr.CreateAssetBundle("SMRoom2") != null)
            {
                isVP = true;
            }
            if (GameMain.Instance.BgMgr.CreateAssetBundle("Train") != null)
            {
                isPP = true;
            }

            if (GameMain.Instance.BgMgr.CreateAssetBundle("HoneymoonRoom") != null)
            {
                isPP2 = true;
            }

            if (GameMain.Instance.BgMgr.CreateAssetBundle("BigSight") != null)
            {
                isPP3 = true;
            }

            if (GameMain.Instance.BgMgr.CreateAssetBundle("rotenburo") != null)
            {
                isVA = true;
            }

            if (GameMain.Instance.BgMgr.CreateAssetBundle("karaokeroom") != null)
            {
                isKA = true;
            }

            if (GameUty.IsEnabledCompatibilityMode)
            {
                isCM3D2 = true;
            }

            List<string> stringList4 = new List<string>(350 + poseArray2.Length);
            stringList4.AddRange(poseArray2);
            List<string> stringList5 = new List<string>();
            for (int index = 11; index < 200; ++index)
            {
                if (index < 100)
                {
                    using (AFileBase afileBase1 = GameUty.FileSystem.FileOpen("edit_pose_0" + index + "_f.anm"))
                    {
                        if (afileBase1.IsValid())
                        {
                            stringList5.Add("edit_pose_0" + index + "_f");
                        }
                        else
                        {
                            using (AFileBase afileBase2 = GameUty.FileSystem.FileOpen("edit_pose_" + index + "_f.anm"))
                            {
                                if (afileBase2.IsValid())
                                {
                                    stringList5.Add("edit_pose_" + index + "_f");
                                }
                            }
                        }
                    }
                }
            }

            for (int index1 = 15; index1 < 25; ++index1)
            {
                for (int index2 = 0; index2 < 2; ++index2)
                {
                    string str = "s";
                    if (index2 == 1)
                    {
                        str = "w";
                    }

                    for (int index3 = 1; index3 < 20; ++index3)
                    {
                        if (index3 < 10)
                        {
                            using (AFileBase afileBase3 =
                                GameUty.FileSystem.FileOpen("edit_pose_dg" + index1 + str + "_00" + index3 + "_f.anm"))
                            {
                                if (afileBase3.IsValid())
                                {
                                    stringList5.Add("edit_pose_dg" + index1 + str + "_00" + index3 + "_f");
                                }
                                else
                                {
                                    using (AFileBase afileBase4 =
                                        GameUty.FileSystem.FileOpen("edit_pose_dg" + index1 + str + "_0" + index3 + "_f.anm"))
                                    {
                                        if (afileBase4.IsValid())
                                        {
                                            stringList5.Add("edit_pose_dg" + index1 + str + "_0" + index3 + "_f");
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (stringList5.Count > 0)
            {
                stringList4.AddRange(stringList5.ToArray());
            }

            using (GameUty.FileSystem.FileOpen("dance_cm3d_003_sp2_f1.anm"))
            {
                ;
            }

            using (GameUty.FileSystem.FileOpen("dance_cm3d2_kara_003_ddfl_f1.anm"))
            {
                ;
            }

            using (GameUty.FileSystem.FileOpen("dance_cm3d2_kara02_001_smt_f1.anm"))
            {
                ;
            }

            stringList4.AddRange(poseArrayVP2);
            stringList4.AddRange(poseArrayFB);
            stringList4.AddRange(poseArray4);
            stringList4.AddRange(poseArray5);
            stringList4.AddRange(poseArray6);
            poseArray = stringList4.ToArray();
            ((Action<string, List<string>>)((path, result_list) =>
                                               {
                                                   string[] files = Directory.GetFiles(path);
                                                   this.countS = 0;
                                                   for (int index = 0; index < files.Length; ++index)
                                                   {
                                                       if (Path.GetExtension(files[index]) == ".anm")
                                                       {
                                                           strListS.Add(files[index].Split('\\')[files[index].Split('\\').Length - 1]
                                                                                    .Split('.')[0] + "　　　　　　　　　　　　　　　　　　　　/"
                                                                                                   + files[index]);
                                                           ++this.countS;
                                                       }
                                                   }
                                               }))(Path.GetFullPath(".\\") + "Mod\\MultipleMaidsPose", new List<string>());
            string[] list = GameUty.FileSystem.GetList("motion", AFileSystemBase.ListType.AllFile);
            int num = 0;
            List<string> stringList6 = new List<string>();
            foreach (string path2 in list)
            {
                string withoutExtension = Path.GetFileNameWithoutExtension(path2);
                string directoryName = Path.GetDirectoryName(path2);
                if (!withoutExtension.StartsWith("maid_motion_") && !withoutExtension.StartsWith("work_00")
                                                                 && !withoutExtension.EndsWith("_3_") && !withoutExtension.EndsWith("_5_")
                                                                 && !withoutExtension.StartsWith("ck_")
                                                                 && !withoutExtension.StartsWith("vr_")
                                                                 && !withoutExtension.StartsWith("dance_mc")
                                                                 && !withoutExtension.Contains("a01_") && !withoutExtension.StartsWith("j_")
                                                                 && !withoutExtension.StartsWith("k_") && !withoutExtension.StartsWith("t_")
                                                                 && !withoutExtension.StartsWith("cbl_")
                                                                 && !withoutExtension.Contains("b01_") && !withoutExtension.Contains("b02_")
                                                                 && !withoutExtension.Contains("_kubi_")
                                                                 && !withoutExtension.EndsWith("_m2") && !withoutExtension.EndsWith("_m3")
                                                                 && !withoutExtension.Contains("_m2_once")
                                                                 && !withoutExtension.Contains("_m3_once")
                                                                 && !withoutExtension.StartsWith("h_")
                                                                 && !withoutExtension.StartsWith("event_")
                                                                 && !withoutExtension.StartsWith("man_") && !withoutExtension.EndsWith("_m")
                                                                 && !withoutExtension.Contains("_m_") && !withoutExtension.Contains("_man")
                                                                 && !(withoutExtension == "dance_cm3d2_001_zoukin")
                                                                 && !(withoutExtension == "dance_cm3d2_001_mop")
                                                                 && !(withoutExtension == "maid_motion")
                                                                 && !(withoutExtension == "aruki_1_idougo_f")
                                                                 && !(withoutExtension == "sleep2") && !(withoutExtension == "stand_akire2")
                                                                 && !(withoutExtension == "ero_scene_001")
                                                                 && !(withoutExtension == "ero_scenefm_001")
                                                                 && !(withoutExtension == "training_001")
                                                                 && !(withoutExtension == "workff_001")
                                                                 && !(withoutExtension == "workfm_001")
                                                                 && !(withoutExtension == "dance_cm3d21_005_moe_mset")
                                                                 && !(withoutExtension == "hinpyoukai_001"))
                {
                    if (!directoryName.Contains("\\sex\\"))
                    {
                        if (!withoutExtension.StartsWith("sex_"))
                        {
                            if (withoutExtension.StartsWith("dance_test"))
                            {
                                strListD.Add(withoutExtension);
                            }
                            else
                            {
                                bool flag = false;
                                foreach (string str1 in strListS)
                                {
                                    char[] chArray = new char[1] { '/' };
                                    string str2 = str1.Split(chArray)[0].Replace("　　　　　　　　　　　　　　　　　　　　", "");
                                    if (withoutExtension == str2)
                                    {
                                        flag = true;
                                        break;
                                    }
                                }

                                if (!flag)
                                {
                                    stringList6.Add(withoutExtension);
                                }
                            }
                        }
                    }
                    else if (!withoutExtension.StartsWith("pose_"))
                    {
                        strListE.Add(withoutExtension);
                    }
                }
            }

            foreach (string str in stringList6)
            {
                bool flag = false;
                for (int index = 0; index < poseArray.Length; ++index)
                {
                    if (str == poseArray[index])
                    {
                        flag = true;
                    }
                }

                if (!flag && str.StartsWith("edit_"))
                {
                    strList2.Add(str);
                }
            }

            foreach (string str in stringList6)
            {
                bool flag = false;
                for (int index = 0; index < poseArray.Length; ++index)
                {
                    if (str == poseArray[index])
                    {
                        flag = true;
                    }
                }

                if (!flag && str.StartsWith("pose_"))
                {
                    strList2.Add(str);
                }
            }

            foreach (string str in stringList6)
            {
                bool flag = false;
                for (int index = 0; index < poseArray.Length; ++index)
                {
                    if (str == poseArray[index])
                    {
                        flag = true;
                    }
                }

                if (!flag && !str.StartsWith("edit_") && !str.StartsWith("pose_"))
                {
                    strList2.Add(str);
                }
            }

            foreach (string str in strListE)
            {
                bool flag = false;
                for (int index = 0; index < poseArray.Length; ++index)
                {
                    if (str == poseArray[index])
                    {
                        flag = true;
                    }
                }

                if (!flag)
                {
                    strListE2.Add(str);
                    ++num;
                }
            }

            stringList4.AddRange(strList2.ToArray());
            stringList4.AddRange(strListE2.ToArray());
            existPose = false;
            poseIniStr = "";
            foreach (IniKey key in Preferences["pose"].Keys)
            {
                IniKey iniKey = Preferences["pose"][key.Key];
                if (iniKey.Value != null && iniKey.Value != "" && iniKey.Value != "del")
                {
                    stringList4.AddRange(new string[1] { key.Key });
                    existPose = true;
                    if (poseIniStr == "")
                    {
                        poseIniStr = key.Key;
                    }
                }
            }

            stringList4.AddRange(strListS.ToArray());
            poseArray = stringList4.ToArray();
            List<string> stringList7 = new List<string>(50 + poseGroupArray2.Length);
            stringList7.AddRange(poseGroupArray2);
            stringList7.AddRange(poseGroupArrayVP);
            stringList7.AddRange(poseGroupArrayFB);
            stringList7.AddRange(poseGroupArray3);
            stringList7.Add(poseArray5[0]);
            stringList7.Add(poseArray6[0]);
            stringList7.Add(strList2[0]);
            stringList7.Add(strListE2[0]);
            if (strListS.Count > 0 && poseIniStr == "")
            {
                stringList7.Add(strListS[0]);
                existPose = true;
            }

            if (poseIniStr != "")
            {
                stringList7.Add(poseIniStr);
            }

            poseGroupArray = stringList7.ToArray();
            groupList = new ArrayList();
            for (int index1 = 0; index1 < poseArray.Length; ++index1)
            {
                for (int index2 = 0; index2 < poseGroupArray.Length; ++index2)
                {
                    if (poseGroupArray[index2] == poseArray[index1])
                    {
                        groupList.Add(index1);
                        if (poseGroupArray[index2] == strList2[0])
                        {
                            sPoseCount = index1;
                        }
                    }
                }
            }

            string[] strArray1 = new string[1] { "Salon_Day" };
            string[] strArray2 = new string[2] { "SMRoom2", "LockerRoom" };
            string[] strArray3 = new string[4] { "Train", "Toilet", "Oheya", "MyBedRoom_NightOff" };
            string[] strArray4 = new string[4] { "ClassRoom", "ClassRoom_Play", "HoneymoonRoom", "OutletPark" };
            string[] strArray5 = new string[9]
            {
                    "BigSight", "BigSight_Night", "PrivateRoom", "PrivateRoom_Night", "Sea", "Sea_Night", "Yashiki_Day", "Yashiki",
                    "Yashiki_Pillow"
            };
            string[] strArray6 = new string[8]
            {
                    "rotenburo", "rotenburo_night", "villa", "villa_night", "villa_bedroom", "villa_bedroom_night", "villa_farm",
                    "villa_farm_night"
            };
            string[] strArray7 = new string[1] { "karaokeroom" };
            List<string> stringList8 = new List<string>(50 + poseArray2.Length);

            PhotoBGData.Create();
            bgDict = new Dictionary<string, string>();
            List<PhotoBGData> photList = PhotoBGData.data;
            IEnumerable<string> neiList = photList.Select(bgdata => bgdata.create_prefab_name).Where(name => !string.IsNullOrEmpty(name));

            foreach (PhotoBGData bgdata in photList)
            {
                if (!string.IsNullOrEmpty(bgdata.create_prefab_name))
                {
                    bgDict[bgdata.create_prefab_name] = bgdata.name;
                }
            }

            bgUiNames.ToList().ForEach(x => bgDict[x.Key] = x.Value);

            stringList8.AddRange(neiList);

            List<string> stringList9 = new List<string>();
            Dictionary<string, string> saveDataDic = CreativeRoomManager.GetSaveDataDic();
            if (saveDataDic != null)
            {
                foreach (KeyValuePair<string, string> keyValuePair in saveDataDic)
                {
                    stringList9.Add(keyValuePair.Key);
                    bgDict[keyValuePair.Key] = keyValuePair.Value;
                }
            }

            stringList8.AddRange(stringList9.ToArray());
            if (isCM3D2)
            {
                stringList8.AddRange(bgArray21);
                if (isVP)
                {
                    stringList8.AddRange(strArray2);
                }

                if (isPP)
                {
                    stringList8.AddRange(strArray3);
                }

                if (isPP2)
                {
                    stringList8.AddRange(strArray4);
                }

                if (isPP3)
                {
                    stringList8.AddRange(strArray5);
                }

                if (isVA)
                {
                    stringList8.AddRange(strArray6);
                }

                if (isKA || isKA2)
                {
                    stringList8.AddRange(strArray7);
                }

                stringList8.AddRange(strArray1);
            }

            bgArray = stringList8.ToArray();
            bgIndex = bgCombo2.selectedItemIndex = bgCombo.selectedItemIndex = Array.FindIndex(bgArray, bg => bg == "Theater");
            string[] strArray8 = new string[3] { "dokidokifallinlove_short_inst", "dokidokifallinlove_short", "entrancetoyou_short" };
            string[] strArray9 = new string[1] { "scarlet leap_short" };
            string[] strArray11 = new string[1] { "RhythmixToYou" };
            string[] strArray15 = new string[5]
            {
                    "bloomingdreaming_short", "kiminiaijodelicious_short", "luminousmoment_short", "nightmagicfire_short",
                    "melodyofempire_short"
            };
            List<string> stringList10 = new List<string>(50);
            stringList10.AddRange(bgmArray2);
            List<string> stringList11 = new List<string>();
            for (int index = 18; index < 210; ++index)
            {
                if (index < 100)
                {
                    using (AFileBase afileBase5 = GameUty.FileSystem.FileOpen("bgm0" + index + ".ogg"))
                    {
                        if (afileBase5.IsValid())
                        {
                            stringList11.Add("bgm0" + index);
                        }
                        else
                        {
                            using (AFileBase afileBase6 = GameUty.FileSystem.FileOpen("bgm" + index + ".ogg"))
                            {
                                if (afileBase6.IsValid())
                                {
                                    stringList11.Add("bgm" + index);
                                }
                            }
                        }
                    }
                }
            }

            if (stringList11.Count > 0)
            {
                stringList10.AddRange(stringList11.ToArray());
            }

            stringList10.AddRange(strArray8);
            stringList10.AddRange(strArray9);
            stringList10.AddRange(strArray11);
            stringList10.AddRange(strArray15);
            bgmArray = stringList10.ToArray();
            List<string> stringList12 = new List<string>(50 + parArray2.Length);
            stringList12.AddRange(parArray2);
            HashSet<int> enabled_id_list = new HashSet<int>();
            Action<string> action3 = file_name =>
                                              {
                                                  file_name += ".nei";
                                                  if (!GameUty.FileSystem.IsExistentFile(file_name))
                                                  {
                                                      return;
                                                  }

                                                  using (AFileBase file = GameUty.FileSystem.FileOpen(file_name))
                                                  {
                                                      using (CsvParser csvParser = new CsvParser())
                                                      {
                                                          NDebug.Assert(csvParser.Open(file), file_name + "\nopen failed.");
                                                          for (int cell_y = 1; cell_y < csvParser.max_cell_y; ++cell_y)
                                                          {
                                                              if (csvParser.IsCellToExistData(0, cell_y))
                                                              {
                                                                  int cellAsInteger = csvParser.GetCellAsInteger(0, cell_y);
                                                                  if (!enabled_id_list.Contains(cellAsInteger))
                                                                  {
                                                                      enabled_id_list.Add(cellAsInteger);
                                                                  }
                                                              }
                                                          }
                                                      }
                                                  }
                                              };
            action3("desk_item_enabled_id");
            for (int index = 0; index < GameUty.PathList.Count; ++index)
            {
                action3("desk_item_enabled_id_" + GameUty.PathList[index]);
            }

            using (AFileBase file = GameUty.FileSystem.FileOpen("desk_item_detail.nei"))
            {
                using (CsvParser csv = new CsvParser())
                {
                    NDebug.Assert(csv.Open(file), "desk_item_detail.nei\nopen failed.");
                    for (int index = 1; index < csv.max_cell_y; ++index)
                    {
                        if (csv.IsCellToExistData(0, index))
                        {
                            int cellAsInteger = csv.GetCellAsInteger(0, index);
                            if (enabled_id_list.Contains(cellAsInteger))
                            {
                                ItemData2 itemData2 = new ItemData2(csv, index);
                                if (itemData2.asset_name != "")
                                {
                                    stringList12.AddRange(new string[1] { itemData2.name + "　　　　　　　　　　　　　　　　　　　　#" + itemData2.asset_name });
                                }
                            }
                        }
                    }
                }
            }

            stringList12.AddRange(parArray3);
            parArray = stringList12.ToArray();
            List<string> stringList13 = new List<string>(50 + doguBArray.Length);

            PhotoBGObjectData.Create();
            doguDict = new Dictionary<string, PhotoBGObjectData>();
            IEnumerable<PhotoBGObjectData> filteredList = PhotoBGObjectData.data.Where(prpdata => prpdata.category != "パーティクル");
            foreach (PhotoBGObjectData bgObj in filteredList)
            {
                string tmp = null;
                if (!string.IsNullOrEmpty(bgObj.create_prefab_name))
                {
                    doguDict[bgObj.create_prefab_name] = bgObj;
                    tmp = bgObj.create_prefab_name;
                }
                else if (!string.IsNullOrEmpty(bgObj.create_asset_bundle_name))
                {
                    doguDict[bgObj.create_asset_bundle_name] = bgObj;
                    tmp = bgObj.create_asset_bundle_name;
                }
                else if (!string.IsNullOrEmpty(bgObj.direct_file))
                {
                    doguDict[bgObj.direct_file] = bgObj;
                    tmp = bgObj.direct_file;

                }
                if (!string.IsNullOrEmpty(tmp))
                {
                    doguUiNames[tmp] = bgObj.name;
                }
            }

            IEnumerable<string> propList1 = filteredList.Where(prpdata => !string.IsNullOrEmpty(prpdata.create_prefab_name))
                                        .Select(prpdata => prpdata.create_prefab_name);
            IEnumerable<string> propList2 = filteredList.Where(prpdata => !string.IsNullOrEmpty(prpdata.create_asset_bundle_name))
                                        .Select(prpdata => prpdata.create_asset_bundle_name);
            List<string> propList = propList1.ToList();
            propList.AddRange(propList2.ToList());
            stringList13.AddRange(propList);
            stringList13.AddRange(doguBArray);

            if (isCM3D2)
            {
                if (isVA)
                {
                    stringList13.AddRange(doguB2Array);
                }

                if (isKA)
                {
                    stringList13.AddRange(doguB3Array);
                }

                if (isKA2)
                {
                    stringList13.AddRange(doguB4Array);
                }
            }

            doguBArray = stringList13.ToArray();
            List<string> stringList14 = new List<string>(100 + itemBArray.Length);
            stringList14.AddRange(itemBArray);
            if (isCM3D2)
            {
                if (isVA)
                {
                    stringList14.AddRange(itemB2Array);
                }

                if (isKA)
                {
                    stringList14.AddRange(itemB3Array);
                }

                if (isKA2)
                {
                    stringList14.AddRange(itemB4Array);
                }
            }

            itemBArray = stringList14.ToArray();

            //rectWin.y = GetPix(65);
        }
    }
}
