mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
AvatarScaleMod
This commit is contained in:
parent
c8cf2afd87
commit
214b05ff8e
7 changed files with 250 additions and 90 deletions
38
AvatarScale/HarmonyPatches.cs
Normal file
38
AvatarScale/HarmonyPatches.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace NAK.AvatarScaleMod.HarmonyPatches;
|
||||
|
||||
class PlayerSetupPatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.SetupAvatarGeneral))]
|
||||
static void Postfix_PlayerSetup_SetupAvatarGeneral(ref PlayerSetup __instance, ref float ____initialAvatarHeight)
|
||||
{
|
||||
if (!AvatarScaleMod.EntryEnabled.Value) return;
|
||||
|
||||
if (AvatarScaleMod.HiddenAvatarScale.Value > 0)
|
||||
{
|
||||
__instance.changeAnimatorParam(AvatarScaleMod.ParameterName, AvatarScaleMod.HiddenAvatarScale.Value);
|
||||
return;
|
||||
}
|
||||
|
||||
// User has cleared MelonPrefs, store a default value.
|
||||
AvatarScaleMod.HiddenAvatarScale.Value = CalculateParameterValue(____initialAvatarHeight);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.ClearAvatar))]
|
||||
static void Prefix_PlayerSetup_ClearAvatar(ref float ____avatarHeight)
|
||||
{
|
||||
if (!AvatarScaleMod.EntryEnabled.Value) return;
|
||||
|
||||
AvatarScaleMod.HiddenAvatarScale.Value = CalculateParameterValue(____avatarHeight);
|
||||
}
|
||||
|
||||
public static float CalculateParameterValue(float lastAvatarHeight)
|
||||
{
|
||||
float t = (lastAvatarHeight - AvatarScaleMod.MinimumHeight) / (AvatarScaleMod.MaximumHeight - AvatarScaleMod.MinimumHeight);
|
||||
return t;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue