Skip to content

Commit

Permalink
Fix skirt FK on scene load
Browse files Browse the repository at this point in the history
  • Loading branch information
DeathWeasel1337 committed Dec 1, 2021
1 parent 0161bfa commit 83777a0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
30 changes: 24 additions & 6 deletions src/FKIK.Core/Core.FKIK.Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,50 @@ private static void Apply(PauseCtrl.FileInfo __instance, OCIChar _char)
/// Enable simultaneous kinematics on character load. Pass the FK/IK state to the postfix
/// </summary>
[HarmonyPrefix, HarmonyPatch(typeof(AddObjectFemale), nameof(AddObjectFemale.Add), typeof(ChaControl), typeof(OICharInfo), typeof(ObjectCtrlInfo), typeof(TreeNodeObject), typeof(bool), typeof(int))]
private static void AddObjectFemalePrefix(OICharInfo _info, ref bool __state) => __state = _info.enableFK && _info.enableIK;
private static void AddObjectFemalePrefix(OICharInfo _info, ref bool[] __state)
{
__state = new bool[2];
__state[0] = _info.enableFK && _info.enableIK;
__state[1] = _info.activeFK[6];
}

/// <summary>
/// FK/IK state has been overwritten, check against the FK/IK state from prefix
/// </summary>
[HarmonyPostfix, HarmonyPatch(typeof(AddObjectFemale), nameof(AddObjectFemale.Add), typeof(ChaControl), typeof(OICharInfo), typeof(ObjectCtrlInfo), typeof(TreeNodeObject), typeof(bool), typeof(int))]
private static void AddObjectFemalePostfix(ChaControl _female, ref bool __state)
private static void AddObjectFemalePostfix(OICharInfo _info, ChaControl _female, ref bool[] __state)
{
if (__state)
if (__state[0])
{
EnableFKIK(_female);
if (__state[1])
_info.activeFK[6] = true;
}
}

/// <summary>
/// Enable simultaneous kinematics on character load. Pass the FK/IK state to the postfix
/// </summary>
[HarmonyPrefix, HarmonyPatch(typeof(AddObjectMale), nameof(AddObjectMale.Add), typeof(ChaControl), typeof(OICharInfo), typeof(ObjectCtrlInfo), typeof(TreeNodeObject), typeof(bool), typeof(int))]
private static void AddObjectMalePrefix(OICharInfo _info, ref bool __state) => __state = _info.enableFK && _info.enableIK;
private static void AddObjectMalePrefix(OICharInfo _info, ref bool[] __state)
{
__state = new bool[2];
__state[0] = _info.enableFK && _info.enableIK;
__state[1] = _info.activeFK[6];
}

/// <summary>
/// FK/IK state has been overwritten, check against the FK/IK state from prefix
/// </summary>
[HarmonyPostfix, HarmonyPatch(typeof(AddObjectMale), nameof(AddObjectMale.Add), typeof(ChaControl), typeof(OICharInfo), typeof(ObjectCtrlInfo), typeof(TreeNodeObject), typeof(bool), typeof(int))]
private static void AddObjectMalePostfix(ChaControl _male, ref bool __state)
private static void AddObjectMalePostfix(OICharInfo _info, ChaControl _male, ref bool[] __state)
{
if (__state)
if (__state[0])
{
EnableFKIK(_male);
if (__state[1])
_info.activeFK[6] = true;
}
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/FKIK.Core/Core.FKIK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public partial class FKIK : BaseUnityPlugin
public const string GUID = "com.deathweasel.bepinex.fkik";
public const string PluginName = "FK and IK";
public const string PluginNameInternal = Constants.Prefix + "_FKIK";
public const string Version = "1.1.2";
public const string Version = "1.1.3";
internal static new ManualLogSource Logger;
internal static FKIK Instance;

Expand Down

0 comments on commit 83777a0

Please sign in to comment.