internal static void OverworldShowerFix(AI __instance, ActionControl.ResultInfo result)
 {
     try
     {
         if (result.actionNo == 2) //shower
         {
             var chaControl = Traverse.Create(__instance).Property("npc").Property <ChaControl>("chaCtrl").Value;
             FixAccessoryState(chaControl);
         }
     }
     catch (Exception ex)
     {
         UnityEngine.Debug.LogException(ex);
     }
 }
            public static void AfterResult(AI __instance, ActionControl.ResultInfo result)
            {
                if (result == null)
                {
                    return;
                }

                // Add sweat if the character is doing running workout. Checks need to be in postfix
                if ((result.actionNo == 6 || result.actionNo == 18) && result.point != null && result.point.transform.childCount > 0)
                {
                    var heroine = __instance.GetNPC()?.heroine;
                    var c       = GetEffectController(heroine);
                    if (c != null)
                    {
                        c.OnRunning();
                    }
                }
            }
Exemple #3
0
            public static void AfterResult(AI __instance, ActionControl.ResultInfo result)
            {
                var actionHistory = __instance.GetLastActions().ToArray();
                var actionCount   = actionHistory.Length;

                if (actionCount < 2)
                {
                    return;
                }

                // The result gives the action that is currently being carried out, same as this
                int currentAction = actionHistory[actionCount - 1];
                // This is the action that we just finished, this is the important one to compare against
                int previousAction = actionHistory[actionCount - 2];

                // 17 (change mind) seems to happen when interrupted, 23 is making them follow you, 25 is being embarassed
                // In all cases the original task was not finished and will be attempted again
                if (currentAction == 23 || currentAction == 17 || currentAction == 25)
                {
                    return;
                }

                var replaceClothesActions = new HashSet <int>(new[]
                {
                    0,  // Change Clothes
                    1,  // Toilet
                    2,  // Shower
                    4,  // H m********e
                    25, // Embarrassment
                    26, // Lez
                    27, // Lez Partner
                });

                // Multiple change clothes actions can be queued up.
                // Put clothes on when the latest action is not in the set.
                if (previousAction != currentAction && replaceClothesActions.Contains(previousAction))
                {
                    var npc = __instance.GetNPC();
                    var effectsController = GetEffectController(npc.heroine);
                    if (effectsController == null)
                    {
                        return;
                    }

                    if (previousAction == 2)
                    {
                        // After shower clear everything
                        effectsController.ClearCharaState(true);
                        SkinEffectGameController.SavePersistData(npc.heroine, effectsController);
                    }
                    else if (currentAction == 2)
                    {
                        if (previousAction == 0)
                        {
                            // Going to shower now after changing clothes
                            // Make the character naked (set all clothing states to fully off)
                            effectsController.ClothingState = Enumerable.Repeat((byte)3, Enum.GetValues(typeof(ChaFileDefine.ClothesKind)).Length).ToArray();
                            // Non public setter. Needed to prevent the state from being reset in RandomChangeOfClothesLowPolyEnd hook
                            Traverse.Create(effectsController.ChaControl).Property(nameof(effectsController.ChaControl.isChangeOfClothesRandom)).SetValue(false);
                        }
                    }
                    else
                    {
                        // Otherwise do a partial clear
                        effectsController.ClothingState  = null;
                        effectsController.AccessoryState = null;
                        effectsController.SiruState      = null;
                        effectsController.TearLevel      = 0;
                        effectsController.DroolLevel     = 0;
                        SkinEffectGameController.SavePersistData(npc.heroine, effectsController);
                    }
                }
            }