Skip to content

Commit

Permalink
Patch mouth patterns on each ChangeFace call if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Sauceke committed Dec 1, 2023
1 parent 34d3aec commit 9624299
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 24 deletions.
30 changes: 25 additions & 5 deletions KK_SexFaces/FBSExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,27 @@ namespace SexFaces
{
internal static class FBSExtensions
{
public static void AddAhegao(this FBSCtrlMouth mouthCtrl, MouthPattern basePtn,
public static void PatchPatternSet(this FBSCtrlMouth mouth)
{
if (mouth.FBSTarget[0].PtnSet.Length >= Enum.GetValues(typeof(MouthPattern)).Length)
{
// already patched, nothing to do
return;
}
mouth.AddAhegao(MouthPattern.HappyBroad, MouthPattern.Ahegao1);
mouth.AddAhegao(MouthPattern.Serious2, MouthPattern.Ahegao2);
mouth.AddAhegao(MouthPattern.CartoonySmile, MouthPattern.Ahegao3);
mouth.AddLopsided(MouthPattern.Hate, leanRight: false, MouthPattern.SneerL);
mouth.AddLopsided(MouthPattern.Hate, leanRight: true, MouthPattern.SneerR);
mouth.AddLopsided(MouthPattern.SmallI, leanRight: false, MouthPattern.Smirk1L);
mouth.AddLopsided(MouthPattern.SmallI, leanRight: true, MouthPattern.Smirk1R);
mouth.AddLopsided(MouthPattern.BigI, leanRight: false, MouthPattern.Smirk2L);
mouth.AddLopsided(MouthPattern.BigI, leanRight: true, MouthPattern.Smirk2R);
mouth.AddClosedTeeth(MouthPattern.Smug, MouthPattern.SmugGrin);
mouth.AddClosedTeeth(MouthPattern.Catlike, MouthPattern.CatGrin);
}

private static void AddAhegao(this FBSCtrlMouth mouthCtrl, MouthPattern basePtn,
MouthPattern newPtn)
{
var ptns = new Dictionary<FBSIndex, MouthPattern>()
Expand All @@ -20,8 +40,8 @@ public static void AddAhegao(this FBSCtrlMouth mouthCtrl, MouthPattern basePtn,
};
AddMixed(mouthCtrl, ptns, keepOpen: true, newPtn);
}
public static void AddClosedTeeth(this FBSCtrlMouth mouthCtrl, MouthPattern basePtn,

private static void AddClosedTeeth(this FBSCtrlMouth mouthCtrl, MouthPattern basePtn,
MouthPattern newPtn)
{
var ptns = new Dictionary<FBSIndex, MouthPattern>()
Expand All @@ -34,8 +54,8 @@ public static void AddClosedTeeth(this FBSCtrlMouth mouthCtrl, MouthPattern base
};
AddMixed(mouthCtrl, ptns, keepOpen: false, newPtn);
}
public static void AddLopsided(this FBSCtrlMouth mouthCtrl, MouthPattern basePtn,

private static void AddLopsided(this FBSCtrlMouth mouthCtrl, MouthPattern basePtn,
bool leanRight, MouthPattern newPtn)
{
for (int fbsIndex = 0; fbsIndex < mouthCtrl.FBSTarget.Length; fbsIndex++)
Expand Down
10 changes: 10 additions & 0 deletions KK_SexFaces/Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ private static bool CanChange(ChaControl __instance) =>
[HarmonyPatch(typeof(ChaControl), nameof(ChaControl.ChangeMouthPtn))]
private static bool CanChangeMouth(ChaControl __instance, int ptn) =>
exemptMouthPatterns.Contains(ptn) || !lockedControls.Contains(__instance);

[HarmonyPrefix]
[HarmonyPatch(typeof(FBSBase), nameof(FBSBase.ChangeFace))]
private static void PatchMouth(FBSBase __instance)
{
if (__instance is FBSCtrlMouth mouth)
{
mouth.PatchPatternSet();
}
}
}

public static class EyeDirectionLock
Expand Down
19 changes: 0 additions & 19 deletions KK_SexFaces/SexFacesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,6 @@ internal class SexFacesController : CharaCustomFunctionController

private System.Random random = new System.Random();

private IEnumerator PatchFaces()
{
// TODO: why the fuck does this not work immediately
yield return new WaitForSecondsRealtime(1);
var mouth = ChaControl.mouthCtrl;
mouth.AddAhegao(MouthPattern.HappyBroad, MouthPattern.Ahegao1);
mouth.AddAhegao(MouthPattern.Serious2, MouthPattern.Ahegao2);
mouth.AddAhegao(MouthPattern.CartoonySmile, MouthPattern.Ahegao3);
mouth.AddLopsided(MouthPattern.Hate, leanRight: false, MouthPattern.SneerL);
mouth.AddLopsided(MouthPattern.Hate, leanRight: true, MouthPattern.SneerR);
mouth.AddLopsided(MouthPattern.SmallI, leanRight: false, MouthPattern.Smirk1L);
mouth.AddLopsided(MouthPattern.SmallI, leanRight: true, MouthPattern.Smirk1R);
mouth.AddLopsided(MouthPattern.BigI, leanRight: false, MouthPattern.Smirk2L);
mouth.AddLopsided(MouthPattern.BigI, leanRight: true, MouthPattern.Smirk2R);
mouth.AddClosedTeeth(MouthPattern.Smug, MouthPattern.SmugGrin);
mouth.AddClosedTeeth(MouthPattern.Catlike, MouthPattern.CatGrin);
}

private void OnForeplay(SaveData.Heroine.HExperienceKind experience) =>
ApplyRandomSexFace(Trigger.OnForeplay, experience);

Expand Down Expand Up @@ -141,7 +123,6 @@ protected override void OnReload(GameMode currentGameMode, bool maintainState)
{
return;
}
StartCoroutine(PatchFaces());
if (!MakerAPI.InsideAndLoaded || MakerAPI.GetCharacterLoadFlags().Parameters)
{
sexFaces.Clear();
Expand Down

0 comments on commit 9624299

Please sign in to comment.