Example #1
0
            public static void ChangeCustomClothesPostHook(ChaControl __instance, int kind)
            {
                var controller = __instance.GetComponent <KoiClothesOverlayController>();

                if (controller == null)
                {
                    return;
                }

                // Clean up no longer used textures after some clothes slots get disabled
                if (MakerAPI.InsideMaker && controller.CurrentOverlayTextures != null)
                {
                    var toRemoveList = controller.CurrentOverlayTextures.Where(x => !x.Value.IsEmpty() && controller.GetCustomClothesComponent(x.Key) == null).ToList();

                    if (toRemoveList.Count > 0)
                    {
                        KoiSkinOverlayMgr.Logger.LogMessage($"Removing {toRemoveList.Count} no longer used Top overlay(s)");

                        foreach (var toRemove in toRemoveList)
                        {
                            controller.GetOverlayTex(toRemove.Key, false)?.Clear();
                        }

                        controller.CleanupTextureList();
                    }
                }

                var clothesCtrl = GetCustomClothesComponent(__instance, kind);

                if (clothesCtrl != null)
                {
                    controller.ApplyOverlays(clothesCtrl);
                }
            }
Example #2
0
            public static bool RandomChangeOfClothseLowPolyEndPrefix(ChaControl __instance)
            {
                // Prevent the method from running if the clothes were not actually changed by RandomChangeOfClothesLowPoly
                // Avoids overriding our saved clothes state at the end of pretty much all actions, no real effect otherwise

                var controller = __instance.GetComponent <SkinEffectsController>();

                if (__instance.isChangeOfClothesRandom || !HasSiruState(controller) && !HasClothingState(controller))
                {
                    // Clear clothes state and save it
                    if (controller != null)
                    {
                        controller.SiruState      = null;
                        controller.ClothingState  = null;
                        controller.AccessoryState = null;

                        var heroine = __instance.GetHeroine();

                        if (heroine != null)
                        {
                            // If leaving a special scene (e.g. lunch), maintain clothes from scene.
                            if (heroine.charaBase is NPC npc && npc.IsExitingScene())
                            {
                                return(false);
                            }
                            else
                            {
                                SkinEffectGameController.SavePersistData(heroine, controller);
                            }
                        }
                    }

                    return(true);
                }
Example #3
0
        public void ChangeOutfit(bool reset = false)
        {
            if (!_initialized)
            {
                ChaControl chaCtrl = ChaCtrl;

                kkabmx = chaCtrl.GetComponent <BoneController>();
                kcox   = chaCtrl.GetComponent <KoiClothesOverlayController>();
                ksox   = chaCtrl.GetComponent <KoiSkinOverlayController>();

                _initialized = true;
            }

            _lastRedressLocation = CharaBase.mapNo;
            ChangeOutfit_Internal(reset);
        }
Example #4
0
 public static void Apply(ChaControl character)
 {
     if (character != null)
     {
         var bc = character.GetComponent <BoneController>();
         bc?.AddBoneEffect(_instance);
     }
 }
Example #5
0
 public static void ChangeValuePost(ChaControl __instance)
 {
     if (__instance != null)
     {
         var controller = __instance.GetComponent <BoneController>();
         if (controller != null)
         {
             controller.NeedsBaselineUpdate = true;
         }
     }
 }
            public CharaData(ChaControl chaControl, HParticleCtrl particleCtrl, HandCtrl procHand)
            {
                ChaControl    = chaControl ? chaControl : throw new ArgumentNullException(nameof(chaControl));
                _procHand     = procHand ? procHand : throw new ArgumentNullException(nameof(procHand));
                _particleCtrl = particleCtrl ? particleCtrl : throw new ArgumentNullException(nameof(particleCtrl));

                var controller = chaControl.GetComponent <PregnancyCharaController>();

                MaxMilk     = GetMilkAmount(controller);
                CurrentMilk = MaxMilk;
            }
Example #7
0
        public static KKAnimeFaceController Install(ChaControl chara)
        {
            KKAnimeFaceController kkanimeFaceController = chara.GetComponent <KKAnimeFaceController>();

            if (kkanimeFaceController == null)
            {
                kkanimeFaceController = chara.gameObject.AddComponent <KKAnimeFaceController>();
                kkanimeFaceController.Init(chara);
            }
            return(kkanimeFaceController);
        }
            public static void ChangeCustomClothesPostHook(ChaControl __instance, bool main, int kind)
            {
                var controller = __instance.GetComponent <KoiClothesOverlayController>();

                if (controller == null)
                {
                    return;
                }

                var clothesCtrl = GetCustomClothesComponent(__instance, main, kind);

                if (clothesCtrl == null)
                {
                    return;
                }

                // Clean up no longer used textures when switching between top clothes with 3 parts and 1 part
                if (MakerAPI.InsideMaker && controller.CurrentOverlayTextures != null)
                {
                    List <KeyValuePair <string, ClothesTexData> > toRemoveList = null;
                    if (main && kind == 0)
                    {
                        toRemoveList = controller.CurrentOverlayTextures.Where(x => KoiClothesOverlayMgr.SubClothesNames.Contains(x.Key) && x.Value.IsEmpty()).ToList();
                    }
                    else if (!main)
                    {
                        toRemoveList = controller.CurrentOverlayTextures.Where(x => KoiClothesOverlayMgr.MainClothesNames[0] == x.Key && x.Value.IsEmpty()).ToList();
                    }

                    if (toRemoveList != null && toRemoveList.Count > 0)
                    {
                        var removedTextures = toRemoveList.Count(x => x.Value.TextureBytes != null);
                        if (removedTextures > 0)
                        {
                            KoiSkinOverlayMgr.Logger.LogMessage($"Removing {removedTextures} no longer used overlay texture(s)");
                        }

                        foreach (var toRemove in toRemoveList)
                        {
                            controller.GetOverlayTex(toRemove.Key, false)?.Clear();
                        }

                        controller.CleanupTextureList();
                    }
                }

                controller.ApplyOverlays(clothesCtrl);
            }
        internal static void BeforeTamaCharacterReload(object __instance)
        {
            ChaControl chaControl = (ChaControl)__instance.GetPrivateProperty("ChaControl");

            if (chaControl == null)
            {
                return;
            }

            var controller = chaControl.GetComponent <BetterPenetrationController>();

            if (controller != null)
            {
                controller.ClearTama();
            }
        }
Example #10
0
        internal static void AfterDanCharacterReload(object __instance)
        {
            ChaControl chaControl = (ChaControl)__instance.GetPrivateProperty("ChaControl");

            if (chaControl == null)
            {
                return;
            }

            var controller = chaControl.GetComponent <BetterPenetrationController>();

            if (controller != null)
            {
                controller.InitializeDanAgent();
            }
        }
            public static void ChangeCustomClothesPostHook(ChaControl __instance, bool main, int kind)
            {
                var controller = __instance.GetComponent <KoiClothesOverlayController>();

                if (controller == null)
                {
                    return;
                }

                var clothesCtrl = GetCustomClothesComponent(__instance, main, kind);

                if (clothesCtrl == null)
                {
                    return;
                }

                // Clean up no longer used textures when switching between top clothes with 3 parts and 1 part
                if (MakerAPI.InsideMaker && controller.CurrentOverlayTextures != null)
                {
                    List <KeyValuePair <string, ClothesTexData> > toRemoveList = null;
                    if (main && kind == 0)
                    {
                        toRemoveList = controller.CurrentOverlayTextures.Where(x => KoiClothesOverlayMgr.SubClothesNames.Contains(x.Key)).ToList();
                    }
                    else if (!main)
                    {
                        toRemoveList = controller.CurrentOverlayTextures.Where(x => KoiClothesOverlayMgr.MainClothesNames[0] == x.Key).ToList();
                    }

                    if (toRemoveList != null && toRemoveList.Count > 0)
                    {
                        Logger.Log(LogLevel.Warning | LogLevel.Message, $"[KCOX] Removing {toRemoveList.Count} no longer used Top overlay(s)");
                        foreach (var toRemove in toRemoveList)
                        {
                            controller.SetOverlayTex(null, toRemove.Key);
                        }
                    }
                }

                controller.ApplyOverlays(clothesCtrl);
            }
Example #12
0
        public static bool PatchPrefix_ChaControl_ChangeBustInert(ChaControl __instance, bool h)
        {
            BoobController controller = __instance.GetComponent <BoobController>();

            if (controller == null ||
                !controller.boolData[BoobController.OVERRIDE_PHYSICS])
            {
                return(true);
            }

            float inert = controller.floatData[BoobController.INERT];

            Util.UpdateBustInert(
                __instance.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.BreastL),
                inert
                );
            Util.UpdateBustInert(
                __instance.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.BreastR),
                inert
                );

            return(false);
        }
Example #13
0
 public static LewdCrestXController GetCrestController(this ChaControl chaCtrl)
 {
     return(chaCtrl != null?chaCtrl.GetComponent <LewdCrestXController>() : null);
 }
Example #14
0
            private static void SetAnimatorPost2(ChaControl __instance)
            {
                var ctrl = __instance.GetComponent <ReverseTrapController>();

                ctrl?.RefreshOverrideAnimations();
            }
 public static ColliderController GetController(ChaControl chaControl) => chaControl.GetComponent <ColliderController>();
 public static HCharaAdjustmentController GetController(ChaControl chaControl) => chaControl.GetComponent <HCharaAdjustmentController>();
Example #17
0
        public static bool PatchPrefix_BustGravity_ReCalc(ChaControl ___chaCtrl, ChaInfo ___info, int[] changePtn)
        {
            if (___chaCtrl == null ||
                ___info == null ||
                changePtn.Length == 0)
            {
                return(false);
            }

            BoobController controller = ___chaCtrl.GetComponent <BoobController>();

            if (controller == null)
            {
                return(true);
            }

            bool flag = true;

            if (controller.boolData[BoobController.OVERRIDE_GRAVITY])
            {
                flag = false;
                Vector3 gravity = new Vector3(
                    controller.floatData[BoobController.GRAVITY_X],
                    controller.floatData[BoobController.GRAVITY_Y],
                    controller.floatData[BoobController.GRAVITY_Z]
                    );

                Util.UpdateBustGravity(
                    ___chaCtrl.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.BreastL),
                    changePtn,
                    gravity
                    );
                Util.UpdateBustGravity(
                    ___chaCtrl.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.BreastR),
                    changePtn,
                    gravity
                    );
            }


            // Butt

            if (controller.boolData[BoobController.BUTT + BoobController.OVERRIDE_GRAVITY])
            {
                Vector3 gravity = new Vector3(
                    controller.floatData[BoobController.BUTT + BoobController.GRAVITY_X],
                    controller.floatData[BoobController.BUTT + BoobController.GRAVITY_Y],
                    controller.floatData[BoobController.BUTT + BoobController.GRAVITY_Z]
                    );

                Util.UpdateButtGravity(
                    ___chaCtrl.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.HipL),
                    gravity
                    );
                Util.UpdateButtGravity(
                    ___chaCtrl.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.HipR),
                    gravity
                    );
            }

            return(flag);
        }
Example #18
0
        public static bool PatchPrefix_BustSoft_ReCalc(ChaControl ___chaCtrl, ChaInfo ___info, int[] changePtn)
        {
            if (___chaCtrl == null ||
                ___info == null ||
                changePtn.Length == 0)
            {
                return(false);
            }

            BoobController controller = ___chaCtrl.GetComponent <BoobController>();

            if (controller == null)
            {
                return(true);
            }

            bool flag = true;

            if (controller.boolData[BoobController.OVERRIDE_PHYSICS])
            {
                flag = false;

                float damping    = controller.floatData[BoobController.DAMPING];
                float elasticity = controller.floatData[BoobController.ELASTICITY];
                float stiffness  = controller.floatData[BoobController.STIFFNESS];

                Util.UpdateBustSoftness(
                    ___chaCtrl.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.BreastL),
                    changePtn,
                    damping,
                    elasticity,
                    stiffness
                    );
                Util.UpdateBustSoftness(
                    ___chaCtrl.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.BreastR),
                    changePtn,
                    damping,
                    elasticity,
                    stiffness
                    );
                // Inert rarely gets updated. This makes sure it does.
                ___chaCtrl.ChangeBustInert(false);
            }

            if (controller.boolData[BoobController.BUTT + BoobController.OVERRIDE_PHYSICS])
            {
                float damping    = controller.floatData[BoobController.BUTT + BoobController.DAMPING];
                float elasticity = controller.floatData[BoobController.BUTT + BoobController.ELASTICITY];
                float stiffness  = controller.floatData[BoobController.BUTT + BoobController.STIFFNESS];
                float inert      = controller.floatData[BoobController.BUTT + BoobController.INERT];

                Util.UpdateButtPhysics(
                    ___chaCtrl.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.HipL),
                    damping,
                    elasticity,
                    stiffness,
                    inert
                    );
                Util.UpdateButtPhysics(
                    ___chaCtrl.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.HipR),
                    damping,
                    elasticity,
                    stiffness,
                    inert
                    );
            }

            return(flag);
        }