Skip to content

Commit

Permalink
Merge pull request #63 from Sauceke/fuck_blending
Browse files Browse the repository at this point in the history
Add setting to disable animation blending
  • Loading branch information
Sauceke authored Sep 19, 2021
2 parents e681967 + dd9751b commit c69f62b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
2 changes: 2 additions & 0 deletions LoveMachine.KK/Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ private static class HSceneTriggers
[HarmonyPatch(typeof(HFlag), nameof(HFlag.Start))]
public static void Start(HFlag __instance)
{
Chainloader.ManagerObject.GetComponent<KoikatsuButtplugAnimationController>()
.OnStartH(__instance);
Chainloader.ManagerObject.GetComponent<KoikatsuButtplugVibrationController>()
.OnStartH(__instance);
Chainloader.ManagerObject.GetComponent<KoikatsuButtplugStrokerController>()
Expand Down
17 changes: 17 additions & 0 deletions LoveMachine.KK/KKLoveMachine.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using BepInEx;
using BepInEx.Configuration;
using LoveMachine.Core;

namespace LoveMachine.KK
{
[BepInPlugin(CoreConfig.GUID, "LoveMachine", CoreConfig.Version)]
public class KKLoveMachine : BaseUnityPlugin
{
public static ConfigEntry<bool> ReduceAnimationSpeeds;
public static ConfigEntry<bool> SuppressAnimationBlending;

private void Start()
{
var girls = new string[] { "First girl", "Second girl", "Off" };
Expand All @@ -20,8 +24,21 @@ private void Start()
girlMappingOptions: girls,
actionMappingHeader: "Action Mapping",
actionMappingOptions: actions,
typeof(KoikatsuButtplugAnimationController),
typeof(KoikatsuButtplugStrokerController),
typeof(KoikatsuButtplugVibrationController));
string animationSettingsTitle = "Animation Settings";
ReduceAnimationSpeeds = Config.Bind(
section: animationSettingsTitle,
key: "Reduce animation speeds",
defaultValue: true,
"Whether to slow down animations to a speed your stroker can handle");
SuppressAnimationBlending = Config.Bind(
section: animationSettingsTitle,
key: "Simplify animations",
defaultValue: true,
"Some animations are too complex and cannot be tracked precisely.\n" +
"This setting will make such animations simpler for better immersion.");
Hooks.InstallHooks();
}
}
Expand Down
33 changes: 27 additions & 6 deletions LoveMachine.KK/KoikatsuButtplugController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,31 @@ protected override IEnumerator UntilReady()
}
}

public class KoikatsuButtplugAnimationController : KoikatsuButtplugController
{
protected override IEnumerator Run(int girlIndex)
{
var animator = GetFemaleAnimator(girlIndex);
var playerAnimator = GetMaleAnimator();
while (!flags.isHSceneEnd)
{
var info = animator.GetCurrentAnimatorStateInfo(0);
if (KKLoveMachine.ReduceAnimationSpeeds.Value)
{
// nerf the animation speed so the device can keep up with it
// OLoop is faster than the rest, about 280ms per stroke at its original speed
NerfAnimationSpeeds(info.IsName("OLoop") ? 0.28f : 0.375f,
animator, playerAnimator);
}
if (KKLoveMachine.SuppressAnimationBlending.Value)
{
flags.curveMotion = new AnimationCurve(new Keyframe[] { new Keyframe() });
}
yield return new WaitForSeconds(.5f);
}
}
}

public class KoikatsuButtplugVibrationController : KoikatsuButtplugController
{
private static readonly List<HFlag.EMode> supportedMaleModes = new List<HFlag.EMode>
Expand Down Expand Up @@ -260,8 +285,8 @@ public class KoikatsuButtplugStrokerController : KoikatsuButtplugController
protected override IEnumerator Run(int girlIndex)
{
HandleCoroutine(RunAibu(girlIndex));
var animator = flags.lstHeroine[girlIndex].chaCtrl.animBody;
var playerAnimator = flags.player.chaCtrl.animBody;
var animator = GetFemaleAnimator(girlIndex);
var playerAnimator = GetMaleAnimator();
while (!flags.isHSceneEnd)
{
if (!supportedModes.Contains(flags.mode)
Expand All @@ -272,10 +297,6 @@ protected override IEnumerator Run(int girlIndex)
continue;
}
AnimatorStateInfo info() => animator.GetCurrentAnimatorStateInfo(0);
// nerf the animation speed so the device can keep up with it
// OLoop is faster than the rest, about 280ms per stroke at its original speed
NerfAnimationSpeeds(
info().IsName("OLoop") ? 0.28f : 0.375f, animator, playerAnimator);
yield return HandleCoroutine(WaitForUpStroke(info, girlIndex));
float strokeTimeSecs = GetStrokeTimeSecs(info());
if (info().IsName("OLoop"))
Expand Down

0 comments on commit c69f62b

Please sign in to comment.