mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
[AvatarScaleMod] Mod Network attempt 2.
I lost the first attempt when switching branches. Lot of this still needs to be redone, as it is just quickly slapped together atm.
This commit is contained in:
parent
69cb3b7804
commit
d599f57973
13 changed files with 850 additions and 544 deletions
|
@ -1,23 +1,37 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
using HarmonyLib;
|
||||
using NAK.AvatarScaleMod.AvatarScaling;
|
||||
using NAK.AvatarScaleMod.GestureReconizer;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using ABI_RC.Systems.IK;
|
||||
using RootMotion.FinalIK;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace NAK.AvatarScaleMod.HarmonyPatches;
|
||||
|
||||
internal class PlayerSetupPatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.Start))]
|
||||
private static void Postfix_PlayerSetup_Start()
|
||||
{
|
||||
try
|
||||
{
|
||||
GameObject scaleManager = new(nameof(AvatarScaleManager), typeof(AvatarScaleManager));
|
||||
Object.DontDestroyOnLoad(scaleManager);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AvatarScaleMod.Logger.Error($"Error during the patched method {nameof(Postfix_PlayerSetup_Start)}");
|
||||
AvatarScaleMod.Logger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.SetupAvatar))]
|
||||
private static void Postfix_PlayerSetup_SetupAvatar(ref PlayerSetup __instance)
|
||||
{
|
||||
try
|
||||
{
|
||||
__instance._avatar.AddComponent<AvatarScaleManager>().Initialize(__instance._initialAvatarHeight, __instance.initialScale, true);
|
||||
|
||||
AvatarScaleManager.Instance.OnAvatarInstantiated(__instance);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -35,11 +49,12 @@ internal class PuppetMasterPatches
|
|||
{
|
||||
try
|
||||
{
|
||||
__instance.avatarObject.AddComponent<AvatarScaleManager>().Initialize(__instance._initialAvatarHeight, __instance.initialAvatarScale, false);
|
||||
AvatarScaleManager.Instance.OnNetworkAvatarInstantiated(__instance);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AvatarScaleMod.Logger.Error($"Error during the patched method {nameof(Postfix_PuppetMaster_AvatarInstantiated)}");
|
||||
AvatarScaleMod.Logger.Error(
|
||||
$"Error during the patched method {nameof(Postfix_PuppetMaster_AvatarInstantiated)}");
|
||||
AvatarScaleMod.Logger.Error(e);
|
||||
}
|
||||
}
|
||||
|
@ -54,45 +69,7 @@ internal class GesturePlaneTestPatches
|
|||
try
|
||||
{
|
||||
// nicked from Kafe >:))))
|
||||
|
||||
// This requires arms far outward- pull inward with fist and triggers.
|
||||
// Release triggers while still holding fist to readjust.
|
||||
|
||||
var gesture = new CVRGesture
|
||||
{
|
||||
name = "avatarScaleIn",
|
||||
type = CVRGesture.GestureType.Hold,
|
||||
};
|
||||
gesture.steps.Add(new CVRGestureStep
|
||||
{
|
||||
firstGesture = CVRGestureStep.Gesture.Fist,
|
||||
secondGesture = CVRGestureStep.Gesture.Fist,
|
||||
startDistance = 1f,
|
||||
endDistance = 0.25f,
|
||||
direction = CVRGestureStep.GestureDirection.MovingIn,
|
||||
});
|
||||
gesture.onStart.AddListener(new UnityAction<float, Transform, Transform>(AvatarScaleGesture.OnScaleStart));
|
||||
gesture.onStay.AddListener(new UnityAction<float, Transform, Transform>(AvatarScaleGesture.OnScaleStay));
|
||||
gesture.onEnd.AddListener(new UnityAction<float, Transform, Transform>(AvatarScaleGesture.OnScaleEnd));
|
||||
CVRGestureRecognizer.Instance.gestures.Add(gesture);
|
||||
|
||||
gesture = new CVRGesture
|
||||
{
|
||||
name = "avatarScaleOut",
|
||||
type = CVRGesture.GestureType.Hold,
|
||||
};
|
||||
gesture.steps.Add(new CVRGestureStep
|
||||
{
|
||||
firstGesture = CVRGestureStep.Gesture.Fist,
|
||||
secondGesture = CVRGestureStep.Gesture.Fist,
|
||||
startDistance = 0.25f,
|
||||
endDistance = 1f,
|
||||
direction = CVRGestureStep.GestureDirection.MovingOut,
|
||||
});
|
||||
gesture.onStart.AddListener(new UnityAction<float, Transform, Transform>(AvatarScaleGesture.OnScaleStart));
|
||||
gesture.onStay.AddListener(new UnityAction<float, Transform, Transform>(AvatarScaleGesture.OnScaleStay));
|
||||
gesture.onEnd.AddListener(new UnityAction<float, Transform, Transform>(AvatarScaleGesture.OnScaleEnd));
|
||||
CVRGestureRecognizer.Instance.gestures.Add(gesture);
|
||||
ScaleReconizer.Initialize();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue