Skip to content

Commit

Permalink
Fix for inflation not triggering in KKS Hscenes
Browse files Browse the repository at this point in the history
  • Loading branch information
thojmr committed Jun 6, 2022
1 parent 22979c9 commit 725118b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ private static void InflationChangePatch(int amount, ref CharaCustomFunctionCont
var inflationEnabled = (ConfigEntry<bool>) inflationEnabledObj;
if (!inflationEnabled.Value) return;

var inflationSpeedObj = pregnancyPlugin.GetProperty("InflationSpeed").GetValue(pregnancyPlugin, null);
if (inflationSpeedObj == null) return;
var inflationSpeed = (ConfigEntry<int>) inflationSpeedObj;

var maxInflationSizeObj = pregnancyPlugin.GetProperty("InflationMaxCount").GetValue(pregnancyPlugin, null);
if (maxInflationSizeObj == null) return;
var maxInflationSize = (ConfigEntry<int>) maxInflationSizeObj;
Expand All @@ -116,7 +120,7 @@ private static void InflationChangePatch(int amount, ref CharaCustomFunctionCont
if (controller == null) return;

//Set the inflation amount on the characters controller
controller.OnInflationChanged(inflationAmount, maxInflationSize.Value);
controller.OnInflationChanged(inflationAmount, maxInflationSize.Value, inflationSpeed.Value);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void HS2Inflation(bool deflate = false)
_currentInflationLevel = Math.Max(0, Math.Min(_nextInflationLevel, PregnancyPlusPlugin.HS2InflationMaxLevel.Value));

//Re-use the kk pregnancy inflation code here to smooth the inflation animation
OnInflationChanged(_currentInflationLevel, PregnancyPlusPlugin.HS2InflationMaxLevel.Value);
OnInflationChanged(_currentInflationLevel, PregnancyPlusPlugin.HS2InflationMaxLevel.Value, 0);
}

}
Expand Down
19 changes: 17 additions & 2 deletions PregnancyPlus/PregnancyPlus.Core/PPCharaController.KK_Pregnancy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public partial class PregnancyPlusCharaController: CharaCustomFunctionController
internal float _inflationStartSize = 0;
internal float _inflationChange = 0f;//The current inflation size
internal float _targetPregPlusSize = 0f;//The final desired inflation size
internal int inflationSpeed = 3;//The KK_Pregnancy config speed value
internal int currentWeeks = 0;

//The final size to inflate to (since it can be done in increments)
Expand Down Expand Up @@ -88,8 +89,11 @@ internal void GetWeeksAndSetBellySize(bool checkNewMesh = false, bool slidersCha
/// </summary>
/// <param name="inflationCount">TThe KK_Pregnancy inflation count, or number of times inflated</param>
/// <param name="maxInflationCount">The Max number of inflations it takes to get to max size</param>
public void OnInflationChanged(float inflationCount, int maxInflationCount)
public void OnInflationChanged(float inflationCount, int maxInflationCount, int _inflationSpeed)
{
//Store the config value for later in ComputeInflationChange()
inflationSpeed = _inflationSpeed;

//Convert the inflationCount into a usable number
var kkInflationSize = inflationCount/maxInflationCount * 40;
if (PregnancyPlusPlugin.DebugLog.Value)
Expand Down Expand Up @@ -149,7 +153,7 @@ public void ComputeInflationChange()
}

//Lerp the change in size over x seconds
_inflationChange = Mathf.Lerp(_inflationStartSize, TargetPregPlusSize, timeElapsed / PregnancyPlusPlugin.HS2InflationSpeed.Value);
_inflationChange = Mathf.Lerp(_inflationStartSize, TargetPregPlusSize, timeElapsed / GetInflationSpeed());
timeElapsed += Time.deltaTime;

//Snap the value at the end, in case the lerp never quite reaches 100%
Expand All @@ -160,6 +164,17 @@ public void ComputeInflationChange()
}


public int GetInflationSpeed()
{
#if HS2
return PregnancyPlusPlugin.HS2InflationSpeed.Value;
#else
//The value configured in the KK_Pregnancy plugin
return inflationSpeed;
#endif
}


/// <summary>
/// Set the weights of any blendShapeControllers to allow quick and frequent mesh blendshape changes
/// </summary>
Expand Down

0 comments on commit 725118b

Please sign in to comment.