mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-04 02:49:23 +00:00
Update to build 2024r174ex2
This commit is contained in:
parent
d537cab9ba
commit
4eda3ff4e4
7 changed files with 579 additions and 592 deletions
|
@ -63,15 +63,10 @@
|
||||||
<Private>false</Private>
|
<Private>false</Private>
|
||||||
<SpecificVersion>false</SpecificVersion>
|
<SpecificVersion>false</SpecificVersion>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="EasyCharacterMovement.CharacterMovement">
|
<Reference Include="ECM2">
|
||||||
<HintPath>D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\EasyCharacterMovement.CharacterMovement.dll</HintPath>
|
<HintPath>D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\ECM2.dll</HintPath>
|
||||||
<Private>false</Private>
|
|
||||||
<SpecificVersion>false</SpecificVersion>
|
<SpecificVersion>false</SpecificVersion>
|
||||||
</Reference>
|
|
||||||
<Reference Include="EasyCharacterMovement.Characters">
|
|
||||||
<HintPath>D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\EasyCharacterMovement.Characters.dll</HintPath>
|
|
||||||
<Private>false</Private>
|
<Private>false</Private>
|
||||||
<SpecificVersion>false</SpecificVersion>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="MelonLoader">
|
<Reference Include="MelonLoader">
|
||||||
<HintPath>D:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\MelonLoader.dll</HintPath>
|
<HintPath>D:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\MelonLoader.dll</HintPath>
|
||||||
|
|
342
ml_pmc/Main.cs
342
ml_pmc/Main.cs
|
@ -1,171 +1,171 @@
|
||||||
using ABI_RC.Core.Networking.IO.Social;
|
using ABI_RC.Core.Networking.IO.Social;
|
||||||
using ABI_RC.Core.Player;
|
using ABI_RC.Core.Player;
|
||||||
using ABI_RC.Systems.IK;
|
using ABI_RC.Systems.IK;
|
||||||
using ABI_RC.Systems.Movement;
|
using ABI_RC.Systems.Movement;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace ml_pmc
|
namespace ml_pmc
|
||||||
{
|
{
|
||||||
public class PlayerMovementCopycat : MelonLoader.MelonMod
|
public class PlayerMovementCopycat : MelonLoader.MelonMod
|
||||||
{
|
{
|
||||||
static PlayerMovementCopycat ms_instance = null;
|
static PlayerMovementCopycat ms_instance = null;
|
||||||
|
|
||||||
PoseCopycat m_localCopycat = null;
|
PoseCopycat m_localCopycat = null;
|
||||||
|
|
||||||
public override void OnInitializeMelon()
|
public override void OnInitializeMelon()
|
||||||
{
|
{
|
||||||
if(ms_instance == null)
|
if(ms_instance == null)
|
||||||
ms_instance = this;
|
ms_instance = this;
|
||||||
|
|
||||||
Settings.Init();
|
Settings.Init();
|
||||||
ModUi.Init();
|
ModUi.Init();
|
||||||
|
|
||||||
HarmonyInstance.Patch(
|
HarmonyInstance.Patch(
|
||||||
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar)),
|
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar)),
|
||||||
null,
|
null,
|
||||||
new HarmonyLib.HarmonyMethod(typeof(PlayerMovementCopycat).GetMethod(nameof(OnAvatarClear_Postfix), BindingFlags.NonPublic | BindingFlags.Static))
|
new HarmonyLib.HarmonyMethod(typeof(PlayerMovementCopycat).GetMethod(nameof(OnAvatarClear_Postfix), BindingFlags.NonPublic | BindingFlags.Static))
|
||||||
);
|
);
|
||||||
HarmonyInstance.Patch(
|
HarmonyInstance.Patch(
|
||||||
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupAvatar)),
|
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupAvatar)),
|
||||||
null,
|
null,
|
||||||
new HarmonyLib.HarmonyMethod(typeof(PlayerMovementCopycat).GetMethod(nameof(OnSetupAvatar_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
|
new HarmonyLib.HarmonyMethod(typeof(PlayerMovementCopycat).GetMethod(nameof(OnSetupAvatar_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
|
||||||
);
|
);
|
||||||
HarmonyInstance.Patch(
|
HarmonyInstance.Patch(
|
||||||
typeof(IKSystem).GetMethod(nameof(IKSystem.ReinitializeAvatar), BindingFlags.Instance | BindingFlags.Public),
|
typeof(IKSystem).GetMethod(nameof(IKSystem.ReinitializeAvatar), BindingFlags.Instance | BindingFlags.Public),
|
||||||
new HarmonyLib.HarmonyMethod(typeof(PlayerMovementCopycat).GetMethod(nameof(OnAvatarReinitialize_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
|
new HarmonyLib.HarmonyMethod(typeof(PlayerMovementCopycat).GetMethod(nameof(OnAvatarReinitialize_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
|
||||||
new HarmonyLib.HarmonyMethod(typeof(PlayerMovementCopycat).GetMethod(nameof(OnAvatarReinitialize_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
|
new HarmonyLib.HarmonyMethod(typeof(PlayerMovementCopycat).GetMethod(nameof(OnAvatarReinitialize_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
|
||||||
);
|
);
|
||||||
|
|
||||||
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
|
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDeinitializeMelon()
|
public override void OnDeinitializeMelon()
|
||||||
{
|
{
|
||||||
if(ms_instance == this)
|
if(ms_instance == this)
|
||||||
ms_instance = null;
|
ms_instance = null;
|
||||||
|
|
||||||
ModUi.CopySwitch -= this.OnTargetSelect;
|
ModUi.CopySwitch -= this.OnTargetSelect;
|
||||||
|
|
||||||
if(m_localCopycat != null)
|
if(m_localCopycat != null)
|
||||||
UnityEngine.Object.Destroy(m_localCopycat);
|
UnityEngine.Object.Destroy(m_localCopycat);
|
||||||
m_localCopycat = null;
|
m_localCopycat = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.Collections.IEnumerator WaitForLocalPlayer()
|
System.Collections.IEnumerator WaitForLocalPlayer()
|
||||||
{
|
{
|
||||||
while(PlayerSetup.Instance == null)
|
while(PlayerSetup.Instance == null)
|
||||||
yield return null;
|
yield return null;
|
||||||
|
|
||||||
m_localCopycat = PlayerSetup.Instance.gameObject.AddComponent<PoseCopycat>();
|
m_localCopycat = PlayerSetup.Instance.gameObject.AddComponent<PoseCopycat>();
|
||||||
ModUi.CopySwitch += this.OnTargetSelect;
|
ModUi.CopySwitch += this.OnTargetSelect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnTargetSelect(string p_id)
|
void OnTargetSelect(string p_id)
|
||||||
{
|
{
|
||||||
if(m_localCopycat != null)
|
if(m_localCopycat != null)
|
||||||
{
|
{
|
||||||
if(m_localCopycat.IsActive())
|
if(m_localCopycat.IsActive())
|
||||||
m_localCopycat.SetTarget(null);
|
m_localCopycat.SetTarget(null);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(Friends.FriendsWith(p_id))
|
if(Friends.FriendsWith(p_id))
|
||||||
{
|
{
|
||||||
if(CVRPlayerManager.Instance.GetPlayerPuppetMaster(p_id, out PuppetMaster l_puppetMaster))
|
if(CVRPlayerManager.Instance.GetPlayerPuppetMaster(p_id, out PuppetMaster l_puppetMaster))
|
||||||
{
|
{
|
||||||
if(IsInSight(BetterBetterCharacterController.Instance.KinematicTriggerProxy.Collider, l_puppetMaster.GetComponent<CapsuleCollider>(), Utils.GetWorldMovementLimit()))
|
if(IsInSight(BetterBetterCharacterController.Instance.KinematicTriggerProxy.Collider, l_puppetMaster.GetComponent<CapsuleCollider>(), Utils.GetWorldMovementLimit()))
|
||||||
m_localCopycat.SetTarget(l_puppetMaster);
|
m_localCopycat.SetTarget(l_puppetMaster);
|
||||||
else
|
else
|
||||||
ModUi.ShowAlert("Selected player is too far away or obstructed");
|
ModUi.ShowAlert("Selected player is too far away or obstructed");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ModUi.ShowAlert("Selected player isn't connected or ready yet");
|
ModUi.ShowAlert("Selected player isn't connected or ready yet");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ModUi.ShowAlert("Selected player isn't your friend");
|
ModUi.ShowAlert("Selected player isn't your friend");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsInSight(CapsuleCollider p_source, CapsuleCollider p_target, float p_limit)
|
static bool IsInSight(CapsuleCollider p_source, CapsuleCollider p_target, float p_limit)
|
||||||
{
|
{
|
||||||
bool l_result = false;
|
bool l_result = false;
|
||||||
if((p_source != null) && (p_target != null))
|
if((p_source != null) && (p_target != null))
|
||||||
{
|
{
|
||||||
Ray l_ray = new Ray();
|
Ray l_ray = new Ray();
|
||||||
l_ray.origin = p_source.bounds.center;
|
l_ray.origin = p_source.bounds.center;
|
||||||
l_ray.direction = p_target.bounds.center - l_ray.origin;
|
l_ray.direction = p_target.bounds.center - l_ray.origin;
|
||||||
List<RaycastHit> l_hits = Physics.RaycastAll(l_ray, p_limit).ToList();
|
List<RaycastHit> l_hits = Physics.RaycastAll(l_ray, p_limit).ToList();
|
||||||
if(l_hits.Count > 0)
|
if(l_hits.Count > 0)
|
||||||
{
|
{
|
||||||
l_hits.RemoveAll(hit => hit.collider.gameObject.layer == LayerMask.NameToLayer("UI Internal")); // Somehow layer mask in RaycastAll just ignores players entirely
|
l_hits.RemoveAll(hit => hit.collider.gameObject.layer == LayerMask.NameToLayer("UI Internal")); // Somehow layer mask in RaycastAll just ignores players entirely
|
||||||
l_hits.RemoveAll(hit => hit.collider.gameObject.layer == LayerMask.NameToLayer("PlayerLocal"));
|
l_hits.RemoveAll(hit => hit.collider.gameObject.layer == LayerMask.NameToLayer("PlayerLocal"));
|
||||||
l_hits.RemoveAll(hit => hit.collider.gameObject.layer == LayerMask.NameToLayer("PlayerClone"));
|
l_hits.RemoveAll(hit => hit.collider.gameObject.layer == LayerMask.NameToLayer("PlayerClone"));
|
||||||
l_hits.Sort((a, b) => ((a.distance < b.distance) ? -1 : 1));
|
l_hits.Sort((a, b) => ((a.distance < b.distance) ? -1 : 1));
|
||||||
l_result = (l_hits.First().collider.gameObject.transform.root == p_target.transform.root);
|
l_result = (l_hits.First().collider.gameObject.transform.root == p_target.transform.root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return l_result;
|
return l_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patches
|
// Patches
|
||||||
static void OnAvatarClear_Postfix() => ms_instance?.OnAvatarClear();
|
static void OnAvatarClear_Postfix() => ms_instance?.OnAvatarClear();
|
||||||
void OnAvatarClear()
|
void OnAvatarClear()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(m_localCopycat != null)
|
if(m_localCopycat != null)
|
||||||
m_localCopycat.OnAvatarClear();
|
m_localCopycat.OnAvatarClear();
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
MelonLoader.MelonLogger.Error(e);
|
MelonLoader.MelonLogger.Error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OnSetupAvatar_Postfix() => ms_instance?.OnSetupAvatar();
|
static void OnSetupAvatar_Postfix() => ms_instance?.OnSetupAvatar();
|
||||||
void OnSetupAvatar()
|
void OnSetupAvatar()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(m_localCopycat != null)
|
if(m_localCopycat != null)
|
||||||
m_localCopycat.OnAvatarSetup();
|
m_localCopycat.OnAvatarSetup();
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
MelonLoader.MelonLogger.Error(e);
|
MelonLoader.MelonLogger.Error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OnAvatarReinitialize_Prefix() => ms_instance?.OnPreAvatarReinitialize();
|
static void OnAvatarReinitialize_Prefix() => ms_instance?.OnPreAvatarReinitialize();
|
||||||
void OnPreAvatarReinitialize()
|
void OnPreAvatarReinitialize()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(m_localCopycat != null)
|
if(m_localCopycat != null)
|
||||||
m_localCopycat.OnPreAvatarReinitialize();
|
m_localCopycat.OnPreAvatarReinitialize();
|
||||||
}
|
}
|
||||||
catch(System.Exception e)
|
catch(System.Exception e)
|
||||||
{
|
{
|
||||||
MelonLoader.MelonLogger.Error(e);
|
MelonLoader.MelonLogger.Error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OnAvatarReinitialize_Postfix() => ms_instance?.OnPostAvatarReinitialize();
|
static void OnAvatarReinitialize_Postfix() => ms_instance?.OnPostAvatarReinitialize();
|
||||||
void OnPostAvatarReinitialize()
|
void OnPostAvatarReinitialize()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(m_localCopycat != null)
|
if(m_localCopycat != null)
|
||||||
m_localCopycat.OnPostAvatarReinitialize();
|
m_localCopycat.OnPostAvatarReinitialize();
|
||||||
}
|
}
|
||||||
catch(System.Exception e)
|
catch(System.Exception e)
|
||||||
{
|
{
|
||||||
MelonLoader.MelonLogger.Error(e);
|
MelonLoader.MelonLogger.Error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,368 +1,368 @@
|
||||||
using ABI_RC.Core.Player;
|
using ABI_RC.Core.Player;
|
||||||
using ABI_RC.Systems.IK;
|
using ABI_RC.Systems.IK;
|
||||||
using ABI_RC.Systems.IK.SubSystems;
|
using ABI_RC.Systems.IK.SubSystems;
|
||||||
using ABI_RC.Systems.InputManagement;
|
using ABI_RC.Systems.InputManagement;
|
||||||
using ABI_RC.Systems.Movement;
|
using ABI_RC.Systems.Movement;
|
||||||
using ABI_RC.Systems.VRModeSwitch;
|
using ABI_RC.Systems.VRModeSwitch;
|
||||||
using RootMotion.FinalIK;
|
using RootMotion.FinalIK;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace ml_pmc
|
namespace ml_pmc
|
||||||
{
|
{
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
public class PoseCopycat : MonoBehaviour
|
public class PoseCopycat : MonoBehaviour
|
||||||
{
|
{
|
||||||
static readonly Vector4 ms_pointVector = new Vector4(0f, 0f, 0f, 1f);
|
static readonly Vector4 ms_pointVector = new Vector4(0f, 0f, 0f, 1f);
|
||||||
|
|
||||||
static public PoseCopycat Instance { get; private set; } = null;
|
static public PoseCopycat Instance { get; private set; } = null;
|
||||||
static internal System.Action<bool> OnActivityChange;
|
static internal System.Action<bool> OnActivityChange;
|
||||||
|
|
||||||
Animator m_animator = null;
|
Animator m_animator = null;
|
||||||
VRIK m_vrIk = null;
|
VRIK m_vrIk = null;
|
||||||
float m_ikWeight = 1f;
|
float m_ikWeight = 1f;
|
||||||
LookAtIK m_lookAtIk = null;
|
LookAtIK m_lookAtIk = null;
|
||||||
float m_lookIkWeight = 1f;
|
float m_lookIkWeight = 1f;
|
||||||
bool m_sitting = false;
|
bool m_sitting = false;
|
||||||
bool m_inVr = false;
|
bool m_inVr = false;
|
||||||
|
|
||||||
bool m_active = false;
|
bool m_active = false;
|
||||||
float m_distanceLimit = float.MaxValue;
|
float m_distanceLimit = float.MaxValue;
|
||||||
bool m_fingerTracking = false;
|
bool m_fingerTracking = false;
|
||||||
|
|
||||||
HumanPoseHandler m_poseHandler = null;
|
HumanPoseHandler m_poseHandler = null;
|
||||||
HumanPose m_pose;
|
HumanPose m_pose;
|
||||||
PuppetParser m_puppetParser = null;
|
PuppetParser m_puppetParser = null;
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
if(Instance == null)
|
if(Instance == null)
|
||||||
Instance = this;
|
Instance = this;
|
||||||
}
|
}
|
||||||
void OnDestroy()
|
void OnDestroy()
|
||||||
{
|
{
|
||||||
if(Instance == this)
|
if(Instance == this)
|
||||||
Instance = null;
|
Instance = null;
|
||||||
|
|
||||||
m_poseHandler?.Dispose();
|
m_poseHandler?.Dispose();
|
||||||
m_poseHandler = null;
|
m_poseHandler = null;
|
||||||
|
|
||||||
if(m_puppetParser != null)
|
if(m_puppetParser != null)
|
||||||
Object.Destroy(m_puppetParser);
|
Object.Destroy(m_puppetParser);
|
||||||
m_puppetParser = null;
|
m_puppetParser = null;
|
||||||
|
|
||||||
m_animator = null;
|
m_animator = null;
|
||||||
m_vrIk = null;
|
m_vrIk = null;
|
||||||
m_lookAtIk = null;
|
m_lookAtIk = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unity events
|
// Unity events
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
m_sitting = BetterBetterCharacterController.Instance.IsSitting();
|
m_sitting = BetterBetterCharacterController.Instance.IsSitting();
|
||||||
|
|
||||||
if(m_active)
|
if(m_active)
|
||||||
{
|
{
|
||||||
if(m_puppetParser != null)
|
if(m_puppetParser != null)
|
||||||
{
|
{
|
||||||
OverrideIK();
|
OverrideIK();
|
||||||
|
|
||||||
bool l_mirror = Settings.MirrorPose;
|
bool l_mirror = Settings.MirrorPose;
|
||||||
|
|
||||||
if(Settings.Gestures)
|
if(Settings.Gestures)
|
||||||
{
|
{
|
||||||
CVRInputManager.Instance.gestureLeft = (l_mirror ? m_puppetParser.GetRightGesture() : m_puppetParser.GetLeftGesture());
|
CVRInputManager.Instance.gestureLeft = (l_mirror ? m_puppetParser.GetRightGesture() : m_puppetParser.GetLeftGesture());
|
||||||
CVRInputManager.Instance.gestureRight = (l_mirror ? m_puppetParser.GetLeftGesture() : m_puppetParser.GetRightGesture());
|
CVRInputManager.Instance.gestureRight = (l_mirror ? m_puppetParser.GetLeftGesture() : m_puppetParser.GetRightGesture());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_puppetParser.HasFingerTracking())
|
if(m_puppetParser.HasFingerTracking())
|
||||||
{
|
{
|
||||||
m_fingerTracking = true;
|
m_fingerTracking = true;
|
||||||
|
|
||||||
CVRInputManager.Instance.individualFingerTracking = true;
|
CVRInputManager.Instance.individualFingerTracking = true;
|
||||||
IKSystem.Instance.FingerSystem.controlActive = true;
|
IKSystem.Instance.FingerSystem.controlActive = true;
|
||||||
|
|
||||||
ref readonly float[] l_curls = ref m_puppetParser.GetFingerCurls();
|
ref readonly float[] l_curls = ref m_puppetParser.GetFingerCurls();
|
||||||
ref readonly float[] l_spreads = ref m_puppetParser.GetFingerSpreads();
|
ref readonly float[] l_spreads = ref m_puppetParser.GetFingerSpreads();
|
||||||
|
|
||||||
CVRInputManager.Instance.fingerCurlLeftThumb = l_curls[l_mirror ? 5 : 0];
|
CVRInputManager.Instance.fingerCurlLeftThumb = l_curls[l_mirror ? 5 : 0];
|
||||||
CVRInputManager.Instance.fingerCurlLeftIndex = l_curls[l_mirror ? 6 : 1];
|
CVRInputManager.Instance.fingerCurlLeftIndex = l_curls[l_mirror ? 6 : 1];
|
||||||
CVRInputManager.Instance.fingerCurlLeftMiddle = l_curls[l_mirror ? 7 : 2];
|
CVRInputManager.Instance.fingerCurlLeftMiddle = l_curls[l_mirror ? 7 : 2];
|
||||||
CVRInputManager.Instance.fingerCurlLeftRing = l_curls[l_mirror ? 8 : 3];
|
CVRInputManager.Instance.fingerCurlLeftRing = l_curls[l_mirror ? 8 : 3];
|
||||||
CVRInputManager.Instance.fingerCurlLeftPinky = l_curls[l_mirror ? 9 : 4];
|
CVRInputManager.Instance.fingerCurlLeftPinky = l_curls[l_mirror ? 9 : 4];
|
||||||
CVRInputManager.Instance.fingerCurlRightThumb = l_curls[l_mirror ? 0 : 5];
|
CVRInputManager.Instance.fingerCurlRightThumb = l_curls[l_mirror ? 0 : 5];
|
||||||
CVRInputManager.Instance.fingerCurlRightIndex = l_curls[l_mirror ? 1 : 6];
|
CVRInputManager.Instance.fingerCurlRightIndex = l_curls[l_mirror ? 1 : 6];
|
||||||
CVRInputManager.Instance.fingerCurlRightMiddle = l_curls[l_mirror ? 2 : 7];
|
CVRInputManager.Instance.fingerCurlRightMiddle = l_curls[l_mirror ? 2 : 7];
|
||||||
CVRInputManager.Instance.fingerCurlRightRing = l_curls[l_mirror ? 3 : 8];
|
CVRInputManager.Instance.fingerCurlRightRing = l_curls[l_mirror ? 3 : 8];
|
||||||
CVRInputManager.Instance.fingerCurlRightPinky = l_curls[l_mirror ? 4 : 9];
|
CVRInputManager.Instance.fingerCurlRightPinky = l_curls[l_mirror ? 4 : 9];
|
||||||
|
|
||||||
CVRInputManager.Instance.fingerSpreadLeftThumb = l_spreads[l_mirror ? 5 : 0];
|
CVRInputManager.Instance.fingerSpreadLeftThumb = l_spreads[l_mirror ? 5 : 0];
|
||||||
CVRInputManager.Instance.fingerSpreadLeftIndex = l_spreads[l_mirror ? 6 : 1];
|
CVRInputManager.Instance.fingerSpreadLeftIndex = l_spreads[l_mirror ? 6 : 1];
|
||||||
CVRInputManager.Instance.fingerSpreadLeftMiddle = l_spreads[l_mirror ? 7 : 2];
|
CVRInputManager.Instance.fingerSpreadLeftMiddle = l_spreads[l_mirror ? 7 : 2];
|
||||||
CVRInputManager.Instance.fingerSpreadLeftRing = l_spreads[l_mirror ? 8 : 3];
|
CVRInputManager.Instance.fingerSpreadLeftRing = l_spreads[l_mirror ? 8 : 3];
|
||||||
CVRInputManager.Instance.fingerSpreadLeftPinky = l_spreads[l_mirror ? 9 : 4];
|
CVRInputManager.Instance.fingerSpreadLeftPinky = l_spreads[l_mirror ? 9 : 4];
|
||||||
CVRInputManager.Instance.fingerSpreadRightThumb = l_spreads[l_mirror ? 0 : 5];
|
CVRInputManager.Instance.fingerSpreadRightThumb = l_spreads[l_mirror ? 0 : 5];
|
||||||
CVRInputManager.Instance.fingerSpreadRightIndex = l_spreads[l_mirror ? 1 : 6];
|
CVRInputManager.Instance.fingerSpreadRightIndex = l_spreads[l_mirror ? 1 : 6];
|
||||||
CVRInputManager.Instance.fingerSpreadRightMiddle = l_spreads[l_mirror ? 2 : 7];
|
CVRInputManager.Instance.fingerSpreadRightMiddle = l_spreads[l_mirror ? 2 : 7];
|
||||||
CVRInputManager.Instance.fingerSpreadRightRing = l_spreads[l_mirror ? 3 : 8];
|
CVRInputManager.Instance.fingerSpreadRightRing = l_spreads[l_mirror ? 3 : 8];
|
||||||
CVRInputManager.Instance.fingerSpreadRightPinky = l_spreads[l_mirror ? 4 : 9];
|
CVRInputManager.Instance.fingerSpreadRightPinky = l_spreads[l_mirror ? 4 : 9];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(m_fingerTracking)
|
if(m_fingerTracking)
|
||||||
{
|
{
|
||||||
RestoreFingerTracking();
|
RestoreFingerTracking();
|
||||||
m_fingerTracking = false;
|
m_fingerTracking = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4 l_offset = m_puppetParser.GetLastOffset();
|
Matrix4x4 l_offset = m_puppetParser.GetLastOffset();
|
||||||
Vector3 l_pos = l_offset * ms_pointVector;
|
Vector3 l_pos = l_offset * ms_pointVector;
|
||||||
Quaternion l_rot = l_offset.rotation;
|
Quaternion l_rot = l_offset.rotation;
|
||||||
|
|
||||||
l_pos.y = 0f;
|
l_pos.y = 0f;
|
||||||
if(Settings.MirrorPosition)
|
if(Settings.MirrorPosition)
|
||||||
l_pos.x *= -1f;
|
l_pos.x *= -1f;
|
||||||
l_pos = Vector3.ClampMagnitude(l_pos, m_distanceLimit);
|
l_pos = Vector3.ClampMagnitude(l_pos, m_distanceLimit);
|
||||||
|
|
||||||
l_rot = Quaternion.Euler(0f, l_rot.eulerAngles.y * (Settings.MirrorRotation ? -1f : 1f), 0f);
|
l_rot = Quaternion.Euler(0f, l_rot.eulerAngles.y * (Settings.MirrorRotation ? -1f : 1f), 0f);
|
||||||
|
|
||||||
Matrix4x4 l_result = PlayerSetup.Instance.transform.GetMatrix() * Matrix4x4.TRS(l_pos, l_rot, Vector3.one);
|
Matrix4x4 l_result = PlayerSetup.Instance.transform.GetMatrix() * Matrix4x4.TRS(l_pos, l_rot, Vector3.one);
|
||||||
|
|
||||||
if(Settings.Position && !m_sitting && !m_puppetParser.IsSitting() && Utils.IsWorldSafe() && Utils.IsCombatSafe())
|
if(Settings.Position && !m_sitting && !m_puppetParser.IsSitting() && Utils.IsWorldSafe() && Utils.IsCombatSafe())
|
||||||
PlayerSetup.Instance.transform.position = l_result * ms_pointVector;
|
PlayerSetup.Instance.transform.position = l_result * ms_pointVector;
|
||||||
|
|
||||||
if(Settings.Rotation && !m_sitting && !m_puppetParser.IsSitting() && Utils.IsCombatSafe())
|
if(Settings.Rotation && !m_sitting && !m_puppetParser.IsSitting() && Utils.IsCombatSafe())
|
||||||
{
|
{
|
||||||
if(m_inVr)
|
if(m_inVr)
|
||||||
{
|
{
|
||||||
Vector3 l_avatarPos = PlayerSetup.Instance._avatar.transform.position;
|
Vector3 l_avatarPos = PlayerSetup.Instance._avatar.transform.position;
|
||||||
PlayerSetup.Instance.transform.rotation = l_result.rotation;
|
PlayerSetup.Instance.transform.rotation = l_result.rotation;
|
||||||
Vector3 l_dif = l_avatarPos - PlayerSetup.Instance._avatar.transform.position;
|
Vector3 l_dif = l_avatarPos - PlayerSetup.Instance._avatar.transform.position;
|
||||||
PlayerSetup.Instance.transform.position += l_dif;
|
PlayerSetup.Instance.transform.position += l_dif;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
PlayerSetup.Instance.transform.rotation = l_result.rotation;
|
PlayerSetup.Instance.transform.rotation = l_result.rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Vector3.Distance(this.transform.position, m_puppetParser.transform.position) > m_distanceLimit)
|
if(Vector3.Distance(this.transform.position, m_puppetParser.transform.position) > m_distanceLimit)
|
||||||
SetTarget(null);
|
SetTarget(null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SetTarget(null);
|
SetTarget(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LateUpdate()
|
void LateUpdate()
|
||||||
{
|
{
|
||||||
if(m_active && (m_animator != null) && (m_puppetParser != null))
|
if(m_active && (m_animator != null) && (m_puppetParser != null))
|
||||||
{
|
{
|
||||||
OverrideIK();
|
OverrideIK();
|
||||||
|
|
||||||
m_puppetParser.GetPose().CopyTo(ref m_pose);
|
m_puppetParser.GetPose().CopyTo(ref m_pose);
|
||||||
|
|
||||||
if(Settings.MirrorPose)
|
if(Settings.MirrorPose)
|
||||||
Utils.MirrorPose(ref m_pose);
|
Utils.MirrorPose(ref m_pose);
|
||||||
|
|
||||||
m_poseHandler.SetHumanPose(ref m_pose);
|
m_poseHandler.SetHumanPose(ref m_pose);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patches
|
// Patches
|
||||||
internal void OnAvatarClear()
|
internal void OnAvatarClear()
|
||||||
{
|
{
|
||||||
if(m_active)
|
if(m_active)
|
||||||
{
|
{
|
||||||
RestoreIK();
|
RestoreIK();
|
||||||
RestoreFingerTracking();
|
RestoreFingerTracking();
|
||||||
OnActivityChange?.Invoke(false);
|
OnActivityChange?.Invoke(false);
|
||||||
}
|
}
|
||||||
m_active = false;
|
m_active = false;
|
||||||
|
|
||||||
if(m_puppetParser != null)
|
if(m_puppetParser != null)
|
||||||
Object.Destroy(m_puppetParser);
|
Object.Destroy(m_puppetParser);
|
||||||
m_puppetParser = null;
|
m_puppetParser = null;
|
||||||
|
|
||||||
m_animator = null;
|
m_animator = null;
|
||||||
m_vrIk = null;
|
m_vrIk = null;
|
||||||
m_lookAtIk = null;
|
m_lookAtIk = null;
|
||||||
|
|
||||||
m_poseHandler?.Dispose();
|
m_poseHandler?.Dispose();
|
||||||
m_poseHandler = null;
|
m_poseHandler = null;
|
||||||
|
|
||||||
m_distanceLimit = float.MaxValue;
|
m_distanceLimit = float.MaxValue;
|
||||||
m_fingerTracking = false;
|
m_fingerTracking = false;
|
||||||
m_pose = new HumanPose();
|
m_pose = new HumanPose();
|
||||||
}
|
}
|
||||||
internal void OnAvatarSetup()
|
internal void OnAvatarSetup()
|
||||||
{
|
{
|
||||||
m_inVr = Utils.IsInVR();
|
m_inVr = Utils.IsInVR();
|
||||||
m_animator = PlayerSetup.Instance._animator;
|
m_animator = PlayerSetup.Instance._animator;
|
||||||
m_vrIk = PlayerSetup.Instance._avatar.GetComponent<VRIK>();
|
m_vrIk = PlayerSetup.Instance._avatar.GetComponent<VRIK>();
|
||||||
m_lookAtIk = PlayerSetup.Instance._avatar.GetComponent<LookAtIK>();
|
m_lookAtIk = PlayerSetup.Instance._avatar.GetComponent<LookAtIK>();
|
||||||
|
|
||||||
if((m_animator != null) && m_animator.isHuman)
|
if((m_animator != null) && m_animator.isHuman)
|
||||||
{
|
{
|
||||||
m_poseHandler = new HumanPoseHandler(m_animator.avatar, m_animator.transform);
|
m_poseHandler = new HumanPoseHandler(m_animator.avatar, m_animator.transform);
|
||||||
m_poseHandler.GetHumanPose(ref m_pose);
|
m_poseHandler.GetHumanPose(ref m_pose);
|
||||||
|
|
||||||
if(m_vrIk != null)
|
if(m_vrIk != null)
|
||||||
{
|
{
|
||||||
m_vrIk.onPreSolverUpdate.AddListener(this.OnVRIKPreUpdate);
|
m_vrIk.onPreSolverUpdate.AddListener(this.OnVRIKPreUpdate);
|
||||||
m_vrIk.onPostSolverUpdate.AddListener(this.OnVRIKPostUpdate);
|
m_vrIk.onPostSolverUpdate.AddListener(this.OnVRIKPostUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_lookAtIk != null)
|
if(m_lookAtIk != null)
|
||||||
{
|
{
|
||||||
m_lookAtIk.onPreSolverUpdate.AddListener(this.OnLookAtIKPreUpdate);
|
m_lookAtIk.onPreSolverUpdate.AddListener(this.OnLookAtIKPreUpdate);
|
||||||
m_lookAtIk.onPostSolverUpdate.AddListener(this.OnLookAtIKPostUpdate);
|
m_lookAtIk.onPostSolverUpdate.AddListener(this.OnLookAtIKPostUpdate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_animator = null;
|
m_animator = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void OnPreAvatarReinitialize()
|
internal void OnPreAvatarReinitialize()
|
||||||
{
|
{
|
||||||
if(m_active)
|
if(m_active)
|
||||||
SetTarget(null);
|
SetTarget(null);
|
||||||
}
|
}
|
||||||
internal void OnPostAvatarReinitialize()
|
internal void OnPostAvatarReinitialize()
|
||||||
{
|
{
|
||||||
m_inVr = Utils.IsInVR();
|
m_inVr = Utils.IsInVR();
|
||||||
|
|
||||||
// Old VRIK and LookAtIK are destroyed by game
|
// Old VRIK and LookAtIK are destroyed by game
|
||||||
m_vrIk = PlayerSetup.Instance._avatar.GetComponent<VRIK>();
|
m_vrIk = PlayerSetup.Instance._avatar.GetComponent<VRIK>();
|
||||||
m_lookAtIk = PlayerSetup.Instance._avatar.GetComponent<LookAtIK>();
|
m_lookAtIk = PlayerSetup.Instance._avatar.GetComponent<LookAtIK>();
|
||||||
|
|
||||||
if(m_vrIk != null)
|
if(m_vrIk != null)
|
||||||
{
|
{
|
||||||
m_vrIk.onPreSolverUpdate.AddListener(this.OnVRIKPreUpdate);
|
m_vrIk.onPreSolverUpdate.AddListener(this.OnVRIKPreUpdate);
|
||||||
m_vrIk.onPostSolverUpdate.AddListener(this.OnVRIKPostUpdate);
|
m_vrIk.onPostSolverUpdate.AddListener(this.OnVRIKPostUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_lookAtIk != null)
|
if(m_lookAtIk != null)
|
||||||
{
|
{
|
||||||
m_lookAtIk.onPreSolverUpdate.AddListener(this.OnLookAtIKPreUpdate);
|
m_lookAtIk.onPreSolverUpdate.AddListener(this.OnLookAtIKPreUpdate);
|
||||||
m_lookAtIk.onPostSolverUpdate.AddListener(this.OnLookAtIKPostUpdate);
|
m_lookAtIk.onPostSolverUpdate.AddListener(this.OnLookAtIKPostUpdate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IK updates
|
// IK updates
|
||||||
void OnVRIKPreUpdate()
|
void OnVRIKPreUpdate()
|
||||||
{
|
{
|
||||||
if(m_active)
|
if(m_active)
|
||||||
{
|
{
|
||||||
m_ikWeight = m_vrIk.solver.IKPositionWeight;
|
m_ikWeight = m_vrIk.solver.IKPositionWeight;
|
||||||
m_vrIk.solver.IKPositionWeight = 0f;
|
m_vrIk.solver.IKPositionWeight = 0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void OnVRIKPostUpdate()
|
void OnVRIKPostUpdate()
|
||||||
{
|
{
|
||||||
if(m_active)
|
if(m_active)
|
||||||
m_vrIk.solver.IKPositionWeight = m_ikWeight;
|
m_vrIk.solver.IKPositionWeight = m_ikWeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnLookAtIKPreUpdate()
|
void OnLookAtIKPreUpdate()
|
||||||
{
|
{
|
||||||
if(m_active && !Settings.LookAtMix)
|
if(m_active && !Settings.LookAtMix)
|
||||||
{
|
{
|
||||||
m_lookIkWeight = m_lookAtIk.solver.IKPositionWeight;
|
m_lookIkWeight = m_lookAtIk.solver.IKPositionWeight;
|
||||||
m_lookAtIk.solver.IKPositionWeight = 0f;
|
m_lookAtIk.solver.IKPositionWeight = 0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void OnLookAtIKPostUpdate()
|
void OnLookAtIKPostUpdate()
|
||||||
{
|
{
|
||||||
if(m_active && !Settings.LookAtMix)
|
if(m_active && !Settings.LookAtMix)
|
||||||
m_lookAtIk.solver.IKPositionWeight = m_lookIkWeight;
|
m_lookAtIk.solver.IKPositionWeight = m_lookIkWeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arbitrary
|
// Arbitrary
|
||||||
public void SetTarget(PuppetMaster p_target)
|
public void SetTarget(PuppetMaster p_target)
|
||||||
{
|
{
|
||||||
if(m_animator != null)
|
if(m_animator != null)
|
||||||
{
|
{
|
||||||
if(!m_active)
|
if(!m_active)
|
||||||
{
|
{
|
||||||
if((p_target != null) && (p_target.animatorManager != null) && (p_target.animatorManager.animator != null) && p_target.animatorManager.animator.isHuman)
|
if((p_target != null) && (p_target.animatorManager != null) && (p_target.animatorManager.animator != null) && p_target.animatorManager.animator.isHuman)
|
||||||
{
|
{
|
||||||
m_puppetParser = p_target.animatorManager.animator.gameObject.AddComponent<PuppetParser>();
|
m_puppetParser = p_target.animatorManager.animator.gameObject.AddComponent<PuppetParser>();
|
||||||
m_puppetParser.m_puppetMaster = p_target;
|
m_puppetParser.m_puppetMaster = p_target;
|
||||||
m_distanceLimit = Utils.GetWorldMovementLimit();
|
m_distanceLimit = Utils.GetWorldMovementLimit();
|
||||||
|
|
||||||
m_active = true;
|
m_active = true;
|
||||||
OnActivityChange?.Invoke(m_active);
|
OnActivityChange?.Invoke(m_active);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(p_target == null)
|
if(p_target == null)
|
||||||
{
|
{
|
||||||
if(m_puppetParser != null)
|
if(m_puppetParser != null)
|
||||||
Object.Destroy(m_puppetParser);
|
Object.Destroy(m_puppetParser);
|
||||||
m_puppetParser = null;
|
m_puppetParser = null;
|
||||||
|
|
||||||
if(!m_sitting)
|
if(!m_sitting)
|
||||||
{
|
{
|
||||||
Quaternion l_rot = PlayerSetup.Instance.transform.rotation;
|
Quaternion l_rot = PlayerSetup.Instance.transform.rotation;
|
||||||
PlayerSetup.Instance.transform.rotation = Quaternion.Euler(0f, l_rot.eulerAngles.y, 0f);
|
PlayerSetup.Instance.transform.rotation = Quaternion.Euler(0f, l_rot.eulerAngles.y, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
RestoreIK();
|
RestoreIK();
|
||||||
RestoreFingerTracking();
|
RestoreFingerTracking();
|
||||||
m_fingerTracking = false;
|
m_fingerTracking = false;
|
||||||
|
|
||||||
m_active = false;
|
m_active = false;
|
||||||
OnActivityChange?.Invoke(m_active);
|
OnActivityChange?.Invoke(m_active);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsActive() => m_active;
|
public bool IsActive() => m_active;
|
||||||
public bool IsFingerTrackingActive() => m_fingerTracking;
|
public bool IsFingerTrackingActive() => m_fingerTracking;
|
||||||
|
|
||||||
void OverrideIK()
|
void OverrideIK()
|
||||||
{
|
{
|
||||||
if(!BodySystem.isCalibrating)
|
if(!BodySystem.isCalibrating)
|
||||||
BodySystem.TrackingPositionWeight = 0f;
|
BodySystem.TrackingPositionWeight = 0f;
|
||||||
}
|
}
|
||||||
void RestoreIK()
|
void RestoreIK()
|
||||||
{
|
{
|
||||||
if(!BodySystem.isCalibrating)
|
if(!BodySystem.isCalibrating)
|
||||||
BodySystem.TrackingPositionWeight = 1f;
|
BodySystem.TrackingPositionWeight = 1f;
|
||||||
|
|
||||||
if(m_vrIk != null)
|
if(m_vrIk != null)
|
||||||
m_vrIk.solver.Reset();
|
m_vrIk.solver.Reset();
|
||||||
}
|
}
|
||||||
void RestoreFingerTracking()
|
void RestoreFingerTracking()
|
||||||
{
|
{
|
||||||
CVRInputManager.Instance.individualFingerTracking = (m_inVr && Utils.AreKnucklesInUse() && !CVRInputManager._moduleXR.GestureToggleValue);
|
CVRInputManager.Instance.individualFingerTracking = (m_inVr && Utils.AreKnucklesInUse() && !CVRInputManager._moduleXR.GestureToggleValue);
|
||||||
IKSystem.Instance.FingerSystem.controlActive = CVRInputManager.Instance.individualFingerTracking;
|
IKSystem.Instance.FingerSystem.controlActive = CVRInputManager.Instance.individualFingerTracking;
|
||||||
|
|
||||||
if(!CVRInputManager.Instance.individualFingerTracking)
|
if(!CVRInputManager.Instance.individualFingerTracking)
|
||||||
{
|
{
|
||||||
CVRInputManager.Instance.fingerCurlLeftThumb = 0f;
|
CVRInputManager.Instance.fingerCurlLeftThumb = 0f;
|
||||||
CVRInputManager.Instance.fingerCurlLeftIndex = 0f;
|
CVRInputManager.Instance.fingerCurlLeftIndex = 0f;
|
||||||
CVRInputManager.Instance.fingerCurlLeftMiddle = 0f;
|
CVRInputManager.Instance.fingerCurlLeftMiddle = 0f;
|
||||||
CVRInputManager.Instance.fingerCurlLeftRing = 0f;
|
CVRInputManager.Instance.fingerCurlLeftRing = 0f;
|
||||||
CVRInputManager.Instance.fingerCurlLeftPinky = 0f;
|
CVRInputManager.Instance.fingerCurlLeftPinky = 0f;
|
||||||
CVRInputManager.Instance.fingerCurlRightThumb = 0f;
|
CVRInputManager.Instance.fingerCurlRightThumb = 0f;
|
||||||
CVRInputManager.Instance.fingerCurlRightIndex = 0f;
|
CVRInputManager.Instance.fingerCurlRightIndex = 0f;
|
||||||
CVRInputManager.Instance.fingerCurlRightMiddle = 0f;
|
CVRInputManager.Instance.fingerCurlRightMiddle = 0f;
|
||||||
CVRInputManager.Instance.fingerCurlRightRing = 0f;
|
CVRInputManager.Instance.fingerCurlRightRing = 0f;
|
||||||
CVRInputManager.Instance.fingerCurlRightPinky = 0f;
|
CVRInputManager.Instance.fingerCurlRightPinky = 0f;
|
||||||
|
|
||||||
CVRInputManager.Instance.fingerSpreadLeftThumb = 0.5f;
|
CVRInputManager.Instance.fingerSpreadLeftThumb = 0.5f;
|
||||||
CVRInputManager.Instance.fingerSpreadLeftIndex = 0.5f;
|
CVRInputManager.Instance.fingerSpreadLeftIndex = 0.5f;
|
||||||
CVRInputManager.Instance.fingerSpreadLeftMiddle = 0.5f;
|
CVRInputManager.Instance.fingerSpreadLeftMiddle = 0.5f;
|
||||||
CVRInputManager.Instance.fingerSpreadLeftRing = 0.5f;
|
CVRInputManager.Instance.fingerSpreadLeftRing = 0.5f;
|
||||||
CVRInputManager.Instance.fingerSpreadLeftPinky = 0.5f;
|
CVRInputManager.Instance.fingerSpreadLeftPinky = 0.5f;
|
||||||
CVRInputManager.Instance.fingerSpreadRightThumb = 0.5f;
|
CVRInputManager.Instance.fingerSpreadRightThumb = 0.5f;
|
||||||
CVRInputManager.Instance.fingerSpreadRightIndex = 0.5f;
|
CVRInputManager.Instance.fingerSpreadRightIndex = 0.5f;
|
||||||
CVRInputManager.Instance.fingerSpreadRightMiddle = 0.5f;
|
CVRInputManager.Instance.fingerSpreadRightMiddle = 0.5f;
|
||||||
CVRInputManager.Instance.fingerSpreadRightRing = 0.5f;
|
CVRInputManager.Instance.fingerSpreadRightRing = 0.5f;
|
||||||
CVRInputManager.Instance.fingerSpreadRightPinky = 0.5f;
|
CVRInputManager.Instance.fingerSpreadRightPinky = 0.5f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,15 +45,10 @@
|
||||||
<Private>false</Private>
|
<Private>false</Private>
|
||||||
<SpecificVersion>false</SpecificVersion>
|
<SpecificVersion>false</SpecificVersion>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="EasyCharacterMovement.CharacterMovement">
|
<Reference Include="ECM2">
|
||||||
<HintPath>D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\EasyCharacterMovement.CharacterMovement.dll</HintPath>
|
<HintPath>D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\ECM2.dll</HintPath>
|
||||||
<Private>false</Private>
|
|
||||||
<SpecificVersion>false</SpecificVersion>
|
<SpecificVersion>false</SpecificVersion>
|
||||||
</Reference>
|
|
||||||
<Reference Include="EasyCharacterMovement.Characters">
|
|
||||||
<HintPath>D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\EasyCharacterMovement.Characters.dll</HintPath>
|
|
||||||
<Private>false</Private>
|
<Private>false</Private>
|
||||||
<SpecificVersion>false</SpecificVersion>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="MelonLoader">
|
<Reference Include="MelonLoader">
|
||||||
<HintPath>D:\games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\MelonLoader.dll</HintPath>
|
<HintPath>D:\games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\MelonLoader.dll</HintPath>
|
||||||
|
|
|
@ -1,29 +1,30 @@
|
||||||
using ABI.CCK.Components;
|
using ABI.CCK.Components;
|
||||||
using ABI_RC.Systems.Movement;
|
using ABI_RC.Systems.Gravity;
|
||||||
using UnityEngine;
|
using ABI_RC.Systems.Movement;
|
||||||
|
using UnityEngine;
|
||||||
namespace ml_prm
|
|
||||||
{
|
namespace ml_prm
|
||||||
[DisallowMultipleComponent]
|
{
|
||||||
class GravityInfluencer : MonoBehaviour
|
[DisallowMultipleComponent]
|
||||||
{
|
class GravityInfluencer : MonoBehaviour
|
||||||
Rigidbody m_rigidBody = null;
|
{
|
||||||
PhysicsInfluencer m_physicsInfluencer = null;
|
Rigidbody m_rigidBody = null;
|
||||||
bool m_activeGravity = true;
|
PhysicsInfluencer m_physicsInfluencer = null;
|
||||||
|
bool m_activeGravity = true;
|
||||||
void Start()
|
|
||||||
{
|
void Start()
|
||||||
m_rigidBody = this.GetComponent<Rigidbody>();
|
{
|
||||||
m_physicsInfluencer = this.GetComponent<PhysicsInfluencer>();
|
m_rigidBody = this.GetComponent<Rigidbody>();
|
||||||
}
|
m_physicsInfluencer = this.GetComponent<PhysicsInfluencer>();
|
||||||
|
}
|
||||||
void FixedUpdate()
|
|
||||||
{
|
void FixedUpdate()
|
||||||
m_rigidBody.useGravity = false;
|
{
|
||||||
if(m_activeGravity && ((m_physicsInfluencer == null) || !m_physicsInfluencer.enableInfluence || !m_physicsInfluencer.GetSubmerged()))
|
m_rigidBody.useGravity = false;
|
||||||
m_rigidBody.AddForce(BetterBetterCharacterController.Instance.GravityResult.AppliedGravity * m_rigidBody.mass);
|
if(m_activeGravity && ((m_physicsInfluencer == null) || !m_physicsInfluencer.enableInfluence || !m_physicsInfluencer.GetSubmerged()))
|
||||||
}
|
m_rigidBody.AddForce(BetterBetterCharacterController.Instance.GravityResult.AppliedGravity * m_rigidBody.mass);
|
||||||
|
}
|
||||||
public void SetActiveGravity(bool p_state) => m_activeGravity = p_state;
|
|
||||||
}
|
public void SetActiveGravity(bool p_state) => m_activeGravity = p_state;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -381,6 +381,7 @@ namespace ml_prm
|
||||||
l_physicsInfluencer.fluidAngularDrag = 1f;
|
l_physicsInfluencer.fluidAngularDrag = 1f;
|
||||||
l_physicsInfluencer.enableBuoyancy = true;
|
l_physicsInfluencer.enableBuoyancy = true;
|
||||||
l_physicsInfluencer.enableInfluence = false;
|
l_physicsInfluencer.enableInfluence = false;
|
||||||
|
l_physicsInfluencer.forceAlignUpright = false;
|
||||||
float mass = l_body.mass;
|
float mass = l_body.mass;
|
||||||
l_physicsInfluencer.UpdateDensity();
|
l_physicsInfluencer.UpdateDensity();
|
||||||
l_body.mass = mass;
|
l_body.mass = mass;
|
||||||
|
@ -715,7 +716,7 @@ namespace ml_prm
|
||||||
|
|
||||||
// Restore movement if was ragdolled in water and left it
|
// Restore movement if was ragdolled in water and left it
|
||||||
if(m_wasSwimming)
|
if(m_wasSwimming)
|
||||||
BetterBetterCharacterController.Instance.SetMovementMode(EasyCharacterMovement.MovementMode.Swimming);
|
BetterBetterCharacterController.Instance.SetMovementMode(ECM2.Character.MovementMode.Swimming);
|
||||||
|
|
||||||
m_enabled = false;
|
m_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,15 +41,10 @@
|
||||||
<Private>false</Private>
|
<Private>false</Private>
|
||||||
<SpecificVersion>false</SpecificVersion>
|
<SpecificVersion>false</SpecificVersion>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="EasyCharacterMovement.CharacterMovement">
|
<Reference Include="ECM2">
|
||||||
<HintPath>D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\EasyCharacterMovement.CharacterMovement.dll</HintPath>
|
<HintPath>D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\ECM2.dll</HintPath>
|
||||||
<Private>false</Private>
|
<SpecificVersion>false</SpecificVersion>
|
||||||
<SpecificVersion>false</SpecificVersion>
|
<Private>false</Private>
|
||||||
</Reference>
|
|
||||||
<Reference Include="EasyCharacterMovement.Characters">
|
|
||||||
<HintPath>D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\EasyCharacterMovement.Characters.dll</HintPath>
|
|
||||||
<Private>false</Private>
|
|
||||||
<SpecificVersion>false</SpecificVersion>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="MelonLoader">
|
<Reference Include="MelonLoader">
|
||||||
<HintPath>D:\games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\MelonLoader.dll</HintPath>
|
<HintPath>D:\games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\MelonLoader.dll</HintPath>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue