mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-03 06:49:22 +00:00
update max height
This commit is contained in:
parent
214b05ff8e
commit
7187d3acf3
2 changed files with 28 additions and 7 deletions
|
@ -1,4 +1,5 @@
|
||||||
using ABI_RC.Core.Player;
|
using ABI_RC.Core;
|
||||||
|
using ABI_RC.Core.Player;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
namespace NAK.AvatarScaleMod.HarmonyPatches;
|
namespace NAK.AvatarScaleMod.HarmonyPatches;
|
||||||
|
@ -6,12 +7,12 @@ namespace NAK.AvatarScaleMod.HarmonyPatches;
|
||||||
class PlayerSetupPatches
|
class PlayerSetupPatches
|
||||||
{
|
{
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.SetupAvatarGeneral))]
|
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.SetupAvatar))]
|
||||||
static void Postfix_PlayerSetup_SetupAvatarGeneral(ref PlayerSetup __instance, ref float ____initialAvatarHeight)
|
static void Postfix_PlayerSetup_SetupAvatar(ref PlayerSetup __instance, ref float ____initialAvatarHeight)
|
||||||
{
|
{
|
||||||
if (!AvatarScaleMod.EntryEnabled.Value) return;
|
if (!AvatarScaleMod.EntryEnabled.Value) return;
|
||||||
|
|
||||||
if (AvatarScaleMod.HiddenAvatarScale.Value > 0)
|
if (AvatarScaleMod.HiddenAvatarScale.Value > 0f)
|
||||||
{
|
{
|
||||||
__instance.changeAnimatorParam(AvatarScaleMod.ParameterName, AvatarScaleMod.HiddenAvatarScale.Value);
|
__instance.changeAnimatorParam(AvatarScaleMod.ParameterName, AvatarScaleMod.HiddenAvatarScale.Value);
|
||||||
return;
|
return;
|
||||||
|
@ -23,10 +24,15 @@ class PlayerSetupPatches
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.ClearAvatar))]
|
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.ClearAvatar))]
|
||||||
static void Prefix_PlayerSetup_ClearAvatar(ref float ____avatarHeight)
|
static void Prefix_PlayerSetup_ClearAvatar(ref PlayerSetup __instance, ref float ____avatarHeight)
|
||||||
{
|
{
|
||||||
if (!AvatarScaleMod.EntryEnabled.Value) return;
|
if (!AvatarScaleMod.EntryEnabled.Value) return;
|
||||||
|
|
||||||
|
if (!IsSupportedAvatar(__instance.animatorManager) && !AvatarScaleMod.EntryPersistAnyways.Value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
AvatarScaleMod.HiddenAvatarScale.Value = CalculateParameterValue(____avatarHeight);
|
AvatarScaleMod.HiddenAvatarScale.Value = CalculateParameterValue(____avatarHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,4 +41,16 @@ class PlayerSetupPatches
|
||||||
float t = (lastAvatarHeight - AvatarScaleMod.MinimumHeight) / (AvatarScaleMod.MaximumHeight - AvatarScaleMod.MinimumHeight);
|
float t = (lastAvatarHeight - AvatarScaleMod.MinimumHeight) / (AvatarScaleMod.MaximumHeight - AvatarScaleMod.MinimumHeight);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsSupportedAvatar(CVRAnimatorManager manager)
|
||||||
|
{
|
||||||
|
if (manager.animatorParameterFloatList.Contains(AvatarScaleMod.ParameterName) && manager._animator != null)
|
||||||
|
{
|
||||||
|
if (manager._advancedAvatarIndicesFloat.TryGetValue(AvatarScaleMod.ParameterName, out int index))
|
||||||
|
{
|
||||||
|
return index < manager._advancedAvatarCacheFloat.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -6,13 +6,16 @@ public class AvatarScaleMod : MelonMod
|
||||||
{
|
{
|
||||||
internal const string ParameterName = "AvatarScale";
|
internal const string ParameterName = "AvatarScale";
|
||||||
internal const float MinimumHeight = 0.25f;
|
internal const float MinimumHeight = 0.25f;
|
||||||
internal const float MaximumHeight = 2f;
|
internal const float MaximumHeight = 2.5f;
|
||||||
|
|
||||||
public static readonly MelonPreferences_Category Category =
|
public static readonly MelonPreferences_Category Category =
|
||||||
MelonPreferences.CreateCategory(nameof(AvatarScaleMod));
|
MelonPreferences.CreateCategory(nameof(AvatarScaleMod));
|
||||||
|
|
||||||
public static readonly MelonPreferences_Entry<bool> EntryEnabled =
|
public static readonly MelonPreferences_Entry<bool> EntryEnabled =
|
||||||
Category.CreateEntry("Enabled", true, description: "Should there be persistant avatar scaling? This only works properly on supported avatars.");
|
Category.CreateEntry("Enabled", true, description: "Should there be persistant avatar scaling? This only works properly across supported avatars.");
|
||||||
|
|
||||||
|
public static readonly MelonPreferences_Entry<bool> EntryPersistAnyways =
|
||||||
|
Category.CreateEntry("Persist From Unsupported", true, description: "Should avatar scale persist even from unsupported avatars?");
|
||||||
|
|
||||||
public static readonly MelonPreferences_Entry<float> HiddenAvatarScale =
|
public static readonly MelonPreferences_Entry<float> HiddenAvatarScale =
|
||||||
Category.CreateEntry("Last Avatar Scale", -1f, is_hidden: true);
|
Category.CreateEntry("Last Avatar Scale", -1f, is_hidden: true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue