コード例 #1
0
        private static void AfterDanCharacterReload(object __instance)
        {
            if (!inHScene || hScene == null)
            {
                return;
            }

            ChaControl chaControl = (ChaControl)__instance.GetPrivateProperty("ChaControl");

            if (chaControl == null || (chaControl.sex != 0 && !chaControl.fileParam.futanari))
            {
                return;
            }

            List <DanOptions> danOptions = PopulateDanOptionsList();

            ChaControl[]      maleArray = hScene.GetMales();
            List <ChaControl> maleList  = new List <ChaControl>();

            foreach (var character in maleArray)
            {
                if (character == null)
                {
                    continue;
                }
                maleList.Add(character);
            }

            CoreGame.InitializeDanAgents(maleList, danOptions);
            loadingCharacter = false;
        }
コード例 #2
0
        public static void HScene_SetStartVoice_ApplyClothesConfig(HScene __instance)
        {
            hScene = __instance;

            var hData = Manager.Config.HData;
            var males = __instance.GetMales();

            if (males[0] != null)
            {
                foreach (var kind in clothesKindList.Where(kind => males[0].IsClothesStateKind(kind)))
                {
                    males[0].SetClothesState(kind, (byte)(hData.Cloth ? 0 : 2));
                }

                males[0].SetAccessoryStateAll(hData.Accessory);
                males[0].SetClothesState(7, (byte)(!hData.Shoes ? 2 : 0));
            }

            if (males[1] != null)
            {
                foreach (var kind in clothesKindList.Where(kind => males[1].IsClothesStateKind(kind)))
                {
                    males[1].SetClothesState(kind, (byte)(hData.Cloth ? 0 : 2));
                }

                males[1].SetAccessoryStateAll(hData.Accessory);
                males[1].SetClothesState(7, (byte)(!hData.Shoes ? 2 : 0));
            }
        }
コード例 #3
0
        private static void HScene_PostSetStartVoice(HScene __instance)
        {
            hScene = __instance;

            List <DanOptions>       danOptions       = PopulateDanOptionsList();
            List <CollisionOptions> collisionOptions = PopulateCollisionOptionsList();

            ChaControl[]      femaleArray = hScene.GetFemales();
            List <ChaControl> femaleList  = new List <ChaControl>();

            foreach (var character in femaleArray)
            {
                if (character == null)
                {
                    continue;
                }
                femaleList.Add(character);
            }

            ChaControl[]      maleArray = hScene.GetMales();
            List <ChaControl> maleList  = new List <ChaControl>();

            foreach (var character in maleArray)
            {
                if (character == null)
                {
                    continue;
                }
                maleList.Add(character);
            }

            CoreGame.InitializeAgents(maleList, femaleList, danOptions, collisionOptions);
            inHScene = true;
        }
コード例 #4
0
        private static void HScene_StripClothes(bool shouldStrip)
        {
            if (!inHScene || !shouldStrip || hScene == null)
            {
                return;
            }

            bool stripMales   = stripMaleClothes.Value != Tools.OffHStartAnimChange.Off;
            bool stripFemales = stripFemaleClothes.Value != Tools.OffHStartAnimChange.Off;

            var males   = hScene.GetMales();
            var females = hScene.GetFemales();

            if (stripMales && males != null && males.Length > 0)
            {
                Dictionary <int, Tools.ClothesStrip> stripAmounts = new Dictionary <int, Tools.ClothesStrip>
                {
                    { 0, stripMaleTop.Value },
                    { 1, stripMaleBottom.Value },
                    { 2, stripMaleBra.Value },
                    { 3, stripMalePanties.Value },
                    { 4, stripMaleGloves.Value },
                    { 5, stripMalePantyhose.Value },
                    { 6, stripMaleSocks.Value },
                    { 7, stripMaleShoes.Value }
                };

                foreach (var male in males.Where(male => male != null))
                {
                    foreach (var strip in stripAmounts.Where(strip => strip.Value > 0 && male.IsClothesStateKind(strip.Key) && male.fileStatus.clothesState[strip.Key] != 2))
                    {
                        male.SetClothesState(strip.Key, (byte)strip.Value);
                    }
                }
            }

            if (stripFemales && females != null && females.Length > 0)
            {
                Dictionary <int, Tools.ClothesStrip> stripAmounts = new Dictionary <int, Tools.ClothesStrip>
                {
                    { 0, stripFemaleTop.Value },
                    { 1, stripFemaleBottom.Value },
                    { 2, stripFemaleBra.Value },
                    { 3, stripFemalePanties.Value },
                    { 4, stripFemaleGloves.Value },
                    { 5, stripFemalePantyhose.Value },
                    { 6, stripFemaleSocks.Value },
                    { 7, stripFemaleShoes.Value }
                };

                foreach (var female in females.Where(female => female != null))
                {
                    foreach (var strip in stripAmounts.Where(strip => strip.Value > 0 && female.IsClothesStateKind(strip.Key) && female.fileStatus.clothesState[strip.Key] != 2))
                    {
                        female.SetClothesState(strip.Key, (byte)strip.Value);
                    }
                }
            }
        }
コード例 #5
0
        public static void HScene_SetStartAnimationInfo_HeightPostfix(HScene __instance, HSceneManager ___hSceneManager)
        {
            manager = ___hSceneManager;
            males   = __instance.GetMales();

            HS2_UnlockPlayerHeight.chara    = males[0];
            HS2_UnlockPlayerHeight.chara2nd = males[1];

            HS2_UnlockPlayerHeight.cardHeightValue    = 0.75f;
            HS2_UnlockPlayerHeight.cardHeightValue2nd = 0.75f;

            var png1 = manager.pngMale;

            if (HS2_UnlockPlayerHeight.chara != null && png1 != null)
            {
                if (png1 == "")
                {
                    png1 = HS2_UnlockPlayerHeight.chara.chaFile.charaFileName;

                    if (png1 == "")
                    {
                        png1 = "HS2_ill_M_000";
                    }
                }

                var card = new ChaFileControl();
                if (manager.bFutanari && card.LoadCharaFile(png1, 1, true) || card.LoadCharaFile(png1, 255, true))
                {
                    HS2_UnlockPlayerHeight.cardHeightValue = card.custom.body.shapeValueBody[0];
                    HS2_UnlockPlayerHeight.ApplySettings(false);
                }
            }

            var png2 = manager.pngMaleSecond;

            if (HS2_UnlockPlayerHeight.chara2nd != null && png2 != null)
            {
                if (png2 == "")
                {
                    png2 = HS2_UnlockPlayerHeight.chara2nd.chaFile.charaFileName;

                    if (png2 == "")
                    {
                        png2 = "HS2_ill_M_000";
                    }
                }

                var card = new ChaFileControl();
                if (manager.bFutanariSecond && card.LoadCharaFile(png2, 1, true) || card.LoadCharaFile(png2, 255, true))
                {
                    HS2_UnlockPlayerHeight.cardHeightValue2nd = card.custom.body.shapeValueBody[0];
                    HS2_UnlockPlayerHeight.ApplySettings(true);
                }
            }
        }
コード例 #6
0
        private static void HScene_StripClothes(bool stripMales, bool stripFemales)
        {
            if (stripMales)
            {
                var malesStrip = new List <Tools.ClothesStrip>
                {
                    stripMaleTop.Value,
                    stripMaleBottom.Value,
                    stripMaleBra.Value,
                    stripMalePanties.Value,
                    stripMaleGloves.Value,
                    stripMalePantyhose.Value,
                    stripMaleSocks.Value,
                    stripMaleShoes.Value,
                };

                foreach (var male in hScene.GetMales().Where(male => male != null))
                {
                    foreach (var item in malesStrip.Select((x, i) => new { x, i }))
                    {
                        if (item.x > 0 && male.IsClothesStateKind(item.i) && male.fileStatus.clothesState[item.i] != 2)
                        {
                            male.SetClothesState(item.i, (byte)item.x);
                        }
                    }
                }
            }

            if (stripFemales)
            {
                var femalesStrip = new List <Tools.ClothesStrip>
                {
                    stripFemaleTop.Value,
                    stripFemaleBottom.Value,
                    stripFemaleBra.Value,
                    stripFemalePanties.Value,
                    stripFemaleGloves.Value,
                    stripFemalePantyhose.Value,
                    stripFemaleSocks.Value,
                    stripFemaleShoes.Value,
                };

                foreach (var female in hScene.GetFemales().Where(female => female != null))
                {
                    foreach (var item in femalesStrip.Select((x, i) => new { x, i }))
                    {
                        if (item.x > 0 && female.IsClothesStateKind(item.i) && female.fileStatus.clothesState[item.i] != 2)
                        {
                            female.SetClothesState(item.i, (byte)item.x);
                        }
                    }
                }
            }
        }
コード例 #7
0
        public static ChaControl[] newGetFemales()
        {
            var females = hScene.GetFemales();
            var males   = hScene.GetMales();

            var newFemales = new ChaControl[females.Length + males.Length];

            for (var i = 0; i < females.Length; i++)
            {
                newFemales[i] = females[i];
            }

            for (var i = 0; i < males.Length; i++)
            {
                newFemales[i + females.Length] = males[i];
            }

            return(newFemales);
        }
コード例 #8
0
        public static void SetupVariables(HScene __instance)
        {
            AI_BetterHScenes.map = GameObject.Find("map00_Beach");
            if (AI_BetterHScenes.map == null)
            {
                AI_BetterHScenes.map = GameObject.Find("map_01_data");
            }

            AI_BetterHScenes.mapSimulation    = GameObject.Find("CommonSpace/MapRoot/MapSimulation(Clone)/EnviroSkyGroup(Clone)");
            AI_BetterHScenes.collisionHelpers = new List <SkinnedCollisionHelper>();

            AI_BetterHScenes.hScene = __instance;
            var hTrav = Traverse.Create(__instance);

            AI_BetterHScenes.hFlagCtrl = __instance.ctrlFlag;
            AI_BetterHScenes.manager   = hTrav.Field("hSceneManager").GetValue <HSceneManager>();
            AI_BetterHScenes.hSprite   = hTrav.Field("sprite").GetValue <HSceneSprite>();

            AI_BetterHScenes.characters = new List <ChaControl>();
            AI_BetterHScenes.characters.AddRange(__instance.GetMales());
            AI_BetterHScenes.characters.AddRange(__instance.GetFemales());

            AI_BetterHScenes.cameraShouldLock = true;

            if (__instance.ctrlFlag != null)
            {
                Traverse.Create(__instance.ctrlFlag).Field("gotoFaintnessCount").SetValue(AI_BetterHScenes.countToWeakness.Value);

                if (__instance.ctrlFlag.cameraCtrl != null)
                {
                    AI_BetterHScenes.hCamera = __instance.ctrlFlag.cameraCtrl;
                }
            }

            AI_BetterHScenes.finishObjects = new List <GameObject>();
            foreach (var name in finishFindTransforms)
            {
                AI_BetterHScenes.finishObjects.Add(AI_BetterHScenes.hSprite.categoryFinish.transform.Find(name).gameObject);
            }

            UI.InitDraggersUI();
        }
コード例 #9
0
        public static void HScene_SetStartAnimationInfo_Patch(HScene __instance, HSceneSprite ___sprite)
        {
            hScene  = __instance;
            hSprite = ___sprite;

            if (hScene == null || hSprite == null)
            {
                return;
            }

            hFlagCtrl = hScene.ctrlFlag;
            if (hFlagCtrl == null)
            {
                return;
            }

            cameraCtrl = hFlagCtrl.cameraCtrl;
            if (cameraCtrl == null)
            {
                return;
            }

            hSceneTrav          = Traverse.Create(hScene);
            Tools.hFlagCtrlTrav = Traverse.Create(hFlagCtrl);

            listTrav       = Traverse.Create(hScene.ctrlEyeNeckMale[0]);
            maleMotionList = listTrav?.Field("lstEyeNeck").GetValue <List <HMotionEyeNeckMale.EyeNeck> >();

            if (unlockCamera.Value)
            {
                cameraCtrl.isLimitDir = false;
                cameraCtrl.isLimitPos = false;
            }

            cameraShouldLock = true;

            characters     = new List <ChaControl>();
            maleCharacters = new List <ChaControl>();
            ChaControl[] males = __instance.GetMales();
            foreach (var male in males.Where(male => male != null))
            {
                maleCharacters.Add(male);
                characters.Add(male);
            }

            femaleCharacters = new List <ChaControl>();
            ChaControl[] females = __instance.GetFemales();
            foreach (var female in females.Where(female => female != null))
            {
                femaleCharacters.Add(female);
                characters.Add(female);
            }

            if (characters == null)
            {
                return;
            }

            obiSolver = GameObject.Find("SiruObiMgr").GetComponentInChildren <Obi.ObiSolver>(true);

            if (obiSolver != null)
            {
                obiSolver.UpdateOrder = obiUpdateMode.Value;
            }

            Tools.SetGotoWeaknessCount(countToWeakness.Value);
            SliderUI.InitDraggersUI();
        }
コード例 #10
0
        public static void AddPColliders()
        {
            if (hScene == null)
            {
                return;
            }

            male_list = hScene.GetMales().Where(male => male != null).ToArray();
            fem_list  = hScene.GetFemales().Where(female => female != null).ToArray();

            danPoints             = new DanPoints[male_list.Length];
            referenceLookAtTarget = new Transform[male_list.Length];
            constrainPoints       = new ConstrainPoints[fem_list.Length];
            kokanBones            = new List <DynamicBone> [fem_list.Length];

            int maleNum = 0;

            foreach (var male in male_list.Where(male => male != null))
            {
                Transform dan101 = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_base)).FirstOrDefault();
                Transform dan109 = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_head)).FirstOrDefault();
                Transform danTop = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_sack)).FirstOrDefault();

                bDansFound[maleNum]      = false;
                bDanPenetration[maleNum] = false;
                targetF[maleNum]         = 0;
                if (dan101 != null && dan109 != null && danTop != null)
                {
                    danPoints[maleNum] = new DanPoints(dan101, dan109, danTop);

                    bDansFound[maleNum] = true;
                    dan101.localScale   = new Vector3(_dan_girth[maleNum].Value, _dan_girth[maleNum].Value, 1);

                    danCollider[maleNum] = dan101.GetComponent <DynamicBoneCollider>();

                    if (danCollider[maleNum] == null)
                    {
                        danCollider[maleNum] = dan101.gameObject.AddComponent(typeof(DynamicBoneCollider)) as DynamicBoneCollider;
                    }

                    danCollider[maleNum].m_Direction = DynamicBoneColliderBase.Direction.Z;
                    danCollider[maleNum].m_Center    = new Vector3(0, _dan_collider_verticalcenter[maleNum].Value, _dan_length[maleNum].Value / 2);
                    danCollider[maleNum].m_Bound     = DynamicBoneColliderBase.Bound.Outside;
                    danCollider[maleNum].m_Radius    = _dan_collider_radius[maleNum].Value;
                    danCollider[maleNum].m_Height    = _dan_length[maleNum].Value + (_dan_collider_headlength[maleNum].Value * 2);

                    danPoints[maleNum].danTop.localScale = new Vector3(_dan_sack_size[maleNum].Value, _dan_sack_size[maleNum].Value, _dan_sack_size[maleNum].Value);
                    lastDan109Position[maleNum]          = danPoints[maleNum].danEnd.position;
                    lastDanRotation[maleNum]             = danPoints[maleNum].danEnd.rotation;
                    lastAdjustTime[maleNum] = Time.time;
                }

                referenceLookAtTarget[maleNum]    = danPoints[maleNum].danEnd;
                lastDan101TargetDistance[maleNum] = Vector3.Distance(referenceLookAtTarget[maleNum].position, danPoints[maleNum].danStart.position);
                Console.WriteLine("bDansFound " + bDansFound[maleNum]);
                maleNum++;
            }

            int femaleNum = 0;

            foreach (var female in fem_list.Where(female => female != null))
            {
                List <Transform> frontHPoints = new List <Transform>();
                List <Transform> backHPoints  = new List <Transform>();
                Transform        hPointBackOfHead;
                bHPointsFound[femaleNum] = false;

                for (int index = 0; index < frontHPointsList.Length; index++)
                {
                    frontHPoints.Add(female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(frontHPointsList[index])).FirstOrDefault());
                }

                for (int index = 0; index < backHPointsList.Length; index++)
                {
                    backHPoints.Add(female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(backHPointsList[index])).FirstOrDefault());
                }

                hPointBackOfHead = female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(headHPoint)).FirstOrDefault();

                bpKokanTarget[femaleNum] = female.GetComponentsInChildren <Transform>().Where(x => x.name.Equals(bp_kokan_target)).FirstOrDefault();
                if (bpKokanTarget[femaleNum] != null)
                {
                    Console.WriteLine("BP Target Found " + bpKokanTarget[femaleNum].name);
                    frontHPoints[0] = bpKokanTarget[femaleNum];
                }

                if (frontHPoints.Count == frontHPointsList.Length && backHPoints.Count == backHPointsList.Length && hPointBackOfHead != null)
                {
                    bHPointsFound[femaleNum]   = true;
                    constrainPoints[femaleNum] = new ConstrainPoints(frontHPoints, backHPoints, hPointBackOfHead);
                }

                foreach (DynamicBone db in female.GetComponentsInChildren <DynamicBone>().Where(x => x.name.Contains("cf_J_Vagina")))
                {
                    db.m_Colliders.Clear();
                }

                Console.WriteLine("bHPointsFound " + bHPointsFound[femaleNum]);

                List <DynamicBone> dbList = new List <DynamicBone>();
                foreach (DynamicBone db in female.GetComponentsInChildren <DynamicBone>().Where(x => x.name.Contains("cf_J_Vagina")))
                {
                    if (db == null)
                    {
                        continue;
                    }

                    if (db.m_Root != null)
                    {
                        for (int i = 0; i < colliderList.Length; i++)
                        {
                            if (db.m_Root.name.Equals(dynamicBonesList[i]))
                            {
                                DynamicBoneCollider dbc = female.GetComponentsInChildren <DynamicBoneCollider>().Where(x => x.name.Contains(colliderList[i])).FirstOrDefault();
                                if (dbc == null)
                                {
                                    Transform colliderTransform = female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(colliderList[i])).FirstOrDefault();

                                    if (colliderTransform != null)
                                    {
                                        Console.WriteLine("collider " + colliderTransform.name);

                                        dbc             = colliderTransform.gameObject.AddComponent(typeof(DynamicBoneCollider)) as DynamicBoneCollider;
                                        dbc.m_Bound     = DynamicBoneColliderBase.Bound.Inside;
                                        dbc.m_Direction = DynamicBoneColliderBase.Direction.Y;
                                        dbc.m_Height    = colliderHeightList[i];
                                        dbc.m_Radius    = colliderRadiusList[i];
                                    }
                                }

                                if (dbc != null)
                                {
                                    db.m_Colliders.Add(dbc);
                                    foreach (DynamicBoneColliderBase dbcb in db.m_Colliders)
                                    {
                                        Console.WriteLine(db.m_Root.name + " collider " + dbcb.name);
                                    }
                                }
                                else
                                {
                                    Console.WriteLine(colliderList[i] + " collider not found for " + female.name);
                                }
                            }
                        }
                    }

                    dbList.Add(db);
                }

                kokanBones[femaleNum] = dbList;
                femaleNum++;
            }

            Console.WriteLine("AddColliders done.");
        }
コード例 #11
0
        public static void AddPColliders(HScene __instance)
        {
            hScene    = __instance;
            male_list = __instance.GetMales().Where(male => male != null).ToArray();
            fem_list  = __instance.GetFemales().Where(female => female != null).ToArray();

            danPoints             = new DanPoints[male_list.Length];
            referenceLookAtTarget = new Transform[male_list.Length];
            constrainPoints       = new ConstrainPoints[fem_list.Length];
            kokanBones            = new List <DynamicBone> [fem_list.Length];

            int maleNum = 0;

            foreach (var male in male_list.Where(male => male != null))
            {
                Transform dan101 = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_base)).FirstOrDefault();
                Transform dan109 = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_head)).FirstOrDefault();
                Transform danTop = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_sack)).FirstOrDefault();

                bDansFound[maleNum]      = false;
                bDanPenetration[maleNum] = false;
                targetF[maleNum]         = 0;
                if (dan101 != null && dan109 != null && danTop != null)
                {
                    danPoints[maleNum] = new DanPoints(dan101, dan109, danTop);

                    bDansFound[maleNum] = true;
                    dan101.localScale   = new Vector3(_dan_girth[maleNum].Value, _dan_girth[maleNum].Value, 1);

                    danCollider[maleNum] = dan101.GetComponent <DynamicBoneCollider>();

                    if (danCollider[maleNum] == null)
                    {
                        danCollider[maleNum] = dan101.gameObject.AddComponent(typeof(DynamicBoneCollider)) as DynamicBoneCollider;
                    }

                    danCollider[maleNum].m_Direction     = DynamicBoneColliderBase.Direction.Z;
                    danCollider[maleNum].m_Center        = new Vector3(0, 0, _dan_length[maleNum].Value / 2);
                    danCollider[maleNum].m_Bound         = DynamicBoneColliderBase.Bound.Outside;
                    danCollider[maleNum].m_Radius        = _dan_collider_radius[maleNum].Value;
                    danCollider[maleNum].m_Height        = _dan_length[maleNum].Value + (_dan_collider_headlength[maleNum].Value * 2);
                    danPoints[maleNum].danTop.localScale = new Vector3(_dan_sack_size[maleNum].Value, _dan_sack_size[maleNum].Value, _dan_sack_size[maleNum].Value);

                    lastDan109Position[maleNum] = danPoints[maleNum].danEnd.position;
                    lastDanRotation[maleNum]    = danPoints[maleNum].danEnd.rotation;
                    lastDanVector[maleNum]      = danPoints[maleNum].danEnd.position - danPoints[maleNum].danStart.position;
                    lastDanLength[maleNum]      = _dan_length[maleNum].Value;
                    lastAdjustTime[maleNum]     = Time.time;
                }

                referenceLookAtTarget[maleNum]    = danPoints[maleNum].danEnd;
                lastDan101TargetDistance[maleNum] = Vector3.Distance(referenceLookAtTarget[maleNum].position, danPoints[maleNum].danStart.position);
                Console.WriteLine("bDansFound " + bDansFound[maleNum]);
                maleNum++;
            }

            int femaleNum = 0;

            foreach (var female in fem_list.Where(female => female != null))
            {
                List <Transform> frontHPoints = new List <Transform>();
                List <Transform> backHPoints  = new List <Transform>();
                Transform        hPointBackOfHead;
                bHPointsFound[femaleNum] = false;

                for (int index = 0; index < frontHPointsList.Length; index++)
                {
                    frontHPoints.Add(female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(frontHPointsList[index])).FirstOrDefault());
                }

                for (int index = 0; index < backHPointsList.Length; index++)
                {
                    backHPoints.Add(female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(backHPointsList[index])).FirstOrDefault());
                }

                hPointBackOfHead = female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(headHPoint)).FirstOrDefault();

                if (frontHPoints.Count == frontHPointsList.Length && backHPoints.Count == backHPointsList.Length && hPointBackOfHead != null)
                {
                    bHPointsFound[femaleNum]   = true;
                    constrainPoints[femaleNum] = new ConstrainPoints(frontHPoints, backHPoints, hPointBackOfHead);
                }

                Console.WriteLine("bHPointsFound " + bHPointsFound[femaleNum]);

                List <DynamicBone> dbList = new List <DynamicBone>();

                foreach (DynamicBone db in female.GetComponentsInChildren <DynamicBone>().Where(x => x.name.Contains("cf_J_Vagina")))
                {
                    if (db != null)
                    {
                        Console.WriteLine(db.m_Root.name + " found, adding collilders");

                        dbList.Add(db);

                        for (int i = 0; i < danCollider.Length; i++)
                        {
                            if (db.m_Colliders.Contains(danCollider[i]))
                            {
                                Console.WriteLine("Instance of " + danCollider[i].name + " already exists in list for DB " + db.name);
                            }
                            else
                            {
                                db.m_Colliders.Add(danCollider[i]);
                                Console.WriteLine(danCollider[i].name + " added to " + female.name + " for bone " + db.name);
                            }
                        }
                    }
                }

                kokanBones[femaleNum] = dbList;
                femaleNum++;
            }
            inHScene = true;
            Console.WriteLine("AddColliders done.");
        }
コード例 #12
0
        public static void AddPColliders(bool setDanLength)
        {
            if (hScene == null)
            {
                return;
            }

            male_list = hScene.GetMales().Where(male => male != null).ToArray();
            fem_list  = hScene.GetFemales().Where(female => female != null).ToArray();

            danCollider           = new DynamicBoneCollider();
            referenceLookAtTarget = null;
            constrainPoints       = new ConstrainPoints();
            kokanBones            = new List <DynamicBone>();

            bDansFound = false;
            foreach (var male in male_list.Where(male => male != null))
            {
                if (!bDansFound)
                {
                    Transform dan101 = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_base)).FirstOrDefault();
                    Transform dan109 = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_head)).FirstOrDefault();
                    Transform danTop = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_sack)).FirstOrDefault();
                    Transform index  = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(index_finger)).FirstOrDefault();
                    Transform middle = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(middle_finger)).FirstOrDefault();
                    Transform ring   = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(ring_finger)).FirstOrDefault();

                    bDanPenetration = false;
                    if (dan101 != null && dan109 != null && danTop != null)
                    {
                        if (setDanLength)
                        {
                            baseDanLength = Vector3.Distance(dan101.position, dan109.position);
                            if (Geometry.ApproximatelyZero(baseDanLength))
                            {
                                baseDanLength = 1.8f;
                            }
                        }

                        danPoints      = new DanPoints(dan101, dan109, danTop);
                        lastDanPostion = new Vector3(0, 0, 0);
                        bDansFound     = true;

                        danCollider = dan101.GetComponent <DynamicBoneCollider>();

                        if (danCollider == null)
                        {
                            danCollider = dan101.gameObject.AddComponent(typeof(DynamicBoneCollider)) as DynamicBoneCollider;
                        }

                        danCollider.m_Direction = DynamicBoneColliderBase.Direction.Z;
                        danCollider.m_Bound     = DynamicBoneColliderBase.Bound.Outside;
                        danCollider.m_Center    = new Vector3(0, _dan_collider_verticalcenter.Value, baseDanLength / 2);
                        danCollider.m_Radius    = _dan_collider_radius.Value;
                        danCollider.m_Height    = baseDanLength + (_dan_collider_headlength.Value * 2);
                    }

                    if (index != null && middle != null && ring != null)
                    {
                        indexCollider  = index.GetComponent <DynamicBoneCollider>();
                        middleCollider = middle.GetComponent <DynamicBoneCollider>();
                        ringCollider   = ring.GetComponent <DynamicBoneCollider>();

                        if (indexCollider == null)
                        {
                            indexCollider = index.gameObject.AddComponent(typeof(DynamicBoneCollider)) as DynamicBoneCollider;
                        }

                        if (middleCollider == null)
                        {
                            middleCollider = middle.gameObject.AddComponent(typeof(DynamicBoneCollider)) as DynamicBoneCollider;
                        }

                        if (ringCollider == null)
                        {
                            ringCollider = ring.gameObject.AddComponent(typeof(DynamicBoneCollider)) as DynamicBoneCollider;
                        }

                        indexCollider.m_Direction = DynamicBoneColliderBase.Direction.X;
                        indexCollider.m_Center    = new Vector3(0, 0, 0);
                        indexCollider.m_Bound     = DynamicBoneColliderBase.Bound.Outside;
                        indexCollider.m_Radius    = _finger_collider_radius.Value;
                        indexCollider.m_Height    = _finger_collider_length.Value;

                        middleCollider.m_Direction = DynamicBoneColliderBase.Direction.X;
                        middleCollider.m_Center    = new Vector3(0, 0, 0);
                        middleCollider.m_Bound     = DynamicBoneColliderBase.Bound.Outside;
                        middleCollider.m_Radius    = _finger_collider_radius.Value;
                        middleCollider.m_Height    = _finger_collider_length.Value;

                        ringCollider.m_Direction = DynamicBoneColliderBase.Direction.X;
                        ringCollider.m_Center    = new Vector3(0, 0, 0);
                        ringCollider.m_Bound     = DynamicBoneColliderBase.Bound.Outside;
                        ringCollider.m_Radius    = _finger_collider_radius.Value;
                        ringCollider.m_Height    = _finger_collider_length.Value;
                    }

                    Console.WriteLine("bDansFound " + bDansFound);
                }
            }

            bHPointsFound = false;
            foreach (var female in fem_list.Where(female => female != null))
            {
                if (!bHPointsFound)
                {
                    List <Transform> frontHPoints = new List <Transform>();
                    List <Transform> backHPoints  = new List <Transform>();
                    Transform        hPointBackOfHead;

                    for (int index = 0; index < frontHPointsList.Count; index++)
                    {
                        frontHPoints.Add(female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(frontHPointsList[index])).FirstOrDefault());
                    }

                    for (int index = 0; index < backHPointsList.Count; index++)
                    {
                        backHPoints.Add(female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(backHPointsList[index])).FirstOrDefault());
                    }

                    hPointBackOfHead = female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(headHPoint)).FirstOrDefault();

                    bpKokanTarget = female.GetComponentsInChildren <Transform>(true).Where(x => x.name.Equals(bp_kokan_target)).FirstOrDefault();
                    if (bpKokanTarget != null)
                    {
                        if (bpKokanTarget.gameObject.activeSelf == false)
                        {
                            bpKokanTarget.gameObject.SetActive(true);
                        }

                        Console.WriteLine("BP Target Found " + bpKokanTarget.name);
                        frontHPoints[0] = bpKokanTarget;
                    }

                    if (frontHPoints.Count == frontHPointsList.Count && backHPoints.Count == backHPointsList.Count && hPointBackOfHead != null)
                    {
                        bHPointsFound   = true;
                        constrainPoints = new ConstrainPoints(frontHPoints, backHPoints, hPointBackOfHead);
                    }

                    foreach (DynamicBone db in female.GetComponentsInChildren <DynamicBone>(true).Where(x => x.name.Contains("cf_J_Vagina")))
                    {
                        db.m_Colliders.Clear();
                    }

                    Console.WriteLine("bHPointsFound " + bHPointsFound);

                    Transform          kokanBone = female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains("cf_J_Kokan")).FirstOrDefault();
                    List <DynamicBone> dbList    = new List <DynamicBone>();
                    foreach (DynamicBone db in female.GetComponentsInChildren <DynamicBone>(true).Where(x => x.name.Contains("cf_J_Vagina")))
                    {
                        if (db == null)
                        {
                            continue;
                        }

                        if (db.enabled == false)
                        {
                            db.enabled = true;
                        }

                        if (db.m_Root != null)
                        {
                            int colliderIndex = dynamicBonesList.IndexOf(db.m_Root.name);
                            if (colliderIndex >= 0)
                            {
                                //    DynamicBoneCollider dbc = female.GetComponentsInChildren<DynamicBoneCollider>().Where(x => x.name.Contains(colliderList[colliderIndex])).FirstOrDefault();
                                //   if (dbc == null)
                                //   {
                                Transform colliderTransform = female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(colliderList[colliderIndex])).FirstOrDefault();

                                if (colliderTransform != null)
                                {
                                    Console.WriteLine("collider " + colliderTransform.name);

                                    //     dbc = colliderTransform.gameObject.AddComponent(typeof(DynamicBoneCollider)) as DynamicBoneCollider;
                                    //     dbc.m_Bound = DynamicBoneColliderBase.Bound.Inside;
                                    //     dbc.m_Direction = DynamicBoneColliderBase.Direction.Y;

                                    if (kokanBone == null)
                                    {
                                        //          dbc.m_Height = colliderHeightList[colliderIndex];
                                        //          dbc.m_Radius = colliderRadiusList[colliderIndex];
                                    }
                                    else
                                    {
                                        if (colliderIndex < 3)
                                        {
                                            //                dbc.m_Height = colliderHeightList[colliderIndex] * kokanBone.lossyScale.z;
                                            //              dbc.m_Radius = colliderRadiusList[colliderIndex] * kokanBone.lossyScale.z;
                                            db.m_Radius *= kokanBone.lossyScale.z;
                                        }
                                        else
                                        {
                                            //                dbc.m_Height = colliderHeightList[colliderIndex] * (kokanBone.lossyScale.x + kokanBone.lossyScale.z) / 2;
                                            //                dbc.m_Radius = colliderRadiusList[colliderIndex] * (kokanBone.lossyScale.x + kokanBone.lossyScale.z) / 2;
                                            db.m_Radius *= (kokanBone.lossyScale.x + kokanBone.lossyScale.z) / 2;
                                        }
                                    }
                                }
                                //     }

                                //       if (_use_bounding_colliders.Value && dbc != null)
                                //             db.m_Colliders.Add(dbc);
                            }
                            else if (kokanBone != null)
                            {
                                db.m_Radius *= kokanBone.lossyScale.x;
                            }

                            db.UpdateParameters();
                            dbList.Add(db);
                        }
                    }

                    kokanBones = dbList;
                }

                kokanBoneAdjustTarget = fem_list[0].GetComponentsInChildren <Transform>().Where(x => x.name.Contains("cf_J_Kokan")).FirstOrDefault();
            }
            Console.WriteLine("AddColliders done.");
        }
コード例 #13
0
        public static void AddPColliders(HScene __instance)
        {
            hScene    = __instance;
            male_list = __instance.GetMales().Where(male => male != null).ToArray();
            fem_list  = __instance.GetFemales().Where(female => female != null).ToArray();

            danCollider     = new DynamicBoneCollider();
            constrainPoints = new ConstrainPoints();
            kokanBones      = new List <DynamicBone>();

            bDansFound = false;
            foreach (var male in male_list.Where(male => male != null))
            {
                if (!bDansFound)
                {
                    Transform dan101 = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_base)).FirstOrDefault();
                    Transform dan109 = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_head)).FirstOrDefault();
                    Transform danTop = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_sack)).FirstOrDefault();

                    bDanPenetration = false;
                    if (dan101 != null && dan109 != null && danTop != null)
                    {
                        danPoints = new DanPoints(dan101, dan109, danTop);

                        bDansFound        = true;
                        dan101.localScale = new Vector3(_dan_girth.Value, _dan_girth.Value, 1);

                        danCollider = dan101.GetComponent <DynamicBoneCollider>();

                        if (danCollider == null)
                        {
                            danCollider = dan101.gameObject.AddComponent(typeof(DynamicBoneCollider)) as DynamicBoneCollider;
                        }

                        danCollider.m_Direction = DynamicBoneColliderBase.Direction.Z;
                        danCollider.m_Center    = new Vector3(0, _dan_collider_verticalcenter.Value, _dan_length.Value / 2);
                        danCollider.m_Bound     = DynamicBoneColliderBase.Bound.Outside;
                        danCollider.m_Radius    = _dan_collider_radius.Value;
                        danCollider.m_Height    = _dan_length.Value + (_dan_collider_headlength.Value * 2);

                        danPoints.danTop.localScale = new Vector3(_dan_sack_size.Value, _dan_sack_size.Value, _dan_sack_size.Value);
                        lastDan109Position          = danPoints.danEnd.position;
                        lastDanRotation             = danPoints.danEnd.rotation;
                        lastDanVector  = danPoints.danEnd.position - danPoints.danStart.position;
                        lastDanLength  = _dan_length.Value;
                        lastAdjustTime = Time.time;
                    }

                    referenceLookAtTarget    = danPoints.danEnd;
                    lastDan101TargetDistance = Vector3.Distance(referenceLookAtTarget.position, danPoints.danStart.position);
                    Console.WriteLine("bDansFound " + bDansFound);
                }
            }

            bHPointsFound = false;
            foreach (var female in fem_list.Where(female => female != null))
            {
                if (!bHPointsFound)
                {
                    List <Transform> frontHPoints = new List <Transform>();
                    List <Transform> backHPoints  = new List <Transform>();
                    Transform        hPointBackOfHead;

                    for (int index = 0; index < frontHPointsList.Length; index++)
                    {
                        frontHPoints.Add(female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(frontHPointsList[index])).FirstOrDefault());
                    }

                    for (int index = 0; index < backHPointsList.Length; index++)
                    {
                        backHPoints.Add(female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(backHPointsList[index])).FirstOrDefault());
                    }

                    hPointBackOfHead = female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(headHPoint)).FirstOrDefault();

                    bpKokanTarget = female.GetComponentsInChildren <Transform>().Where(x => x.name.Equals(bp_kokan_target)).FirstOrDefault();
                    if (bpKokanTarget != null)
                    {
                        Console.WriteLine("BP Target Found " + bpKokanTarget.name);
                        frontHPoints[0] = bpKokanTarget;
                    }

                    if (frontHPoints.Count == frontHPointsList.Length && backHPoints.Count == backHPointsList.Length && hPointBackOfHead != null)
                    {
                        bHPointsFound   = true;
                        constrainPoints = new ConstrainPoints(frontHPoints, backHPoints, hPointBackOfHead);
                    }

                    foreach (DynamicBone db in female.GetComponentsInChildren <DynamicBone>().Where(x => x.name.Contains("cf_J_Vagina")))
                    {
                        db.m_Colliders.Clear();
                    }

                    Console.WriteLine("bHPointsFound " + bHPointsFound);

                    /*         for (int i = 0; i < colliderList.Length; i++)
                     *       {
                     *           DynamicBone db = female.GetComponentsInChildren<DynamicBone>().Where(x => x.m_Root.name.Equals(dynamicBonesList[i])).FirstOrDefault();
                     *           DynamicBoneCollider dbc = female.GetComponentsInChildren<DynamicBoneCollider>().Where(x => x.name.Equals(colliderList[i])).FirstOrDefault();
                     *
                     *           if (dbc == null)
                     *           {
                     *               Transform colliderTransform = female.GetComponentsInChildren<Transform>().Where(x => x.name.Contains(colliderList[i])).FirstOrDefault();
                     *
                     *               if (colliderTransform != null)
                     *               {
                     *                   dbc = colliderTransform.gameObject.AddComponent(typeof(DynamicBoneCollider)) as DynamicBoneCollider;
                     *                   dbc.m_Bound = DynamicBoneColliderBase.Bound.Inside;
                     *                   dbc.m_Direction = DynamicBoneColliderBase.Direction.Y;
                     *                   dbc.m_Height = colliderHeightList[i];
                     *                   dbc.m_Radius = colliderRadiusList[i];
                     *               }
                     *           }
                     *
                     *           if (db != null && dbc != null)
                     *           {
                     *               db.m_Colliders.Add(dbc);
                     *
                     *               Console.WriteLine(dbc.name + " collider radius " + dbc.m_Radius + ", height: " + dbc.m_Height);
                     *
                     *               foreach (DynamicBoneColliderBase dbcb in db.m_Colliders)
                     *                   Console.WriteLine(db.m_Root.name + " collider " + dbcb.name);
                     *           }
                     *           else
                     *           {
                     *               if (db == null)
                     *                   Console.WriteLine(dynamicBonesList[i] + " bone not found for " + female.name);
                     *               if (dbc == null)
                     *                   Console.WriteLine(colliderList[i] + " collider not found for " + female.name);
                     *           }
                     *       }
                     */
                    List <DynamicBone> dbList = new List <DynamicBone>();
                    foreach (DynamicBone db in female.GetComponentsInChildren <DynamicBone>().Where(x => x.name.Contains("cf_J_Vagina")))
                    {
                        if (db != null)
                        {
                            dbList.Add(db);
                        }
                    }
                    kokanBones = dbList;
                }
            }
            inHScene = true;
            Console.WriteLine("AddColliders done.");
        }