diff --git a/README.md b/README.md index 6a67095..57fc010 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ Merged set of MelonLoader mods for ChilloutVR. **State table for game build 2022r165:** | Full name | Short name | Latest version | Available in [CVRMA](https://github.com/knah/CVRMelonAssistant) | Current Status | Notes | |-----------|------------|----------------|-----------------------------------------------------------------|----------------|-------| -| Additional Avatar Parameters | ml_aap | 1.0.1 | Pending approval | Working | | Avatar Change Info | ml_aci | 1.0.1 | Pending approval | Working | | Desktop Reticle Switch | ml_drs | 1.0.0 | Yes | Working | | Four Point Tracking | ml_fpt | 1.0.0 | Pending approval | Working | diff --git a/ml_aap/Main.cs b/ml_aap/Main.cs deleted file mode 100644 index 502c58d..0000000 --- a/ml_aap/Main.cs +++ /dev/null @@ -1,57 +0,0 @@ -using ABI_RC.Core.Player; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ml_aap -{ - public class AdditionalAvatarParameters : MelonLoader.MelonMod - { - static AdditionalAvatarParameters ms_instance = null; - - ParametersHandler m_localHandler = null; - - public override void OnApplicationStart() - { - ms_instance = this; - - HarmonyInstance.Patch( - typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar)), - null, - new HarmonyLib.HarmonyMethod(typeof(AdditionalAvatarParameters).GetMethod(nameof(OnLocalAvatarClear_Postfix), System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)) - ); - - HarmonyInstance.Patch( - typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupAvatar)), - null, - new HarmonyLib.HarmonyMethod(typeof(AdditionalAvatarParameters).GetMethod(nameof(OnLocalAvatarSetup_Postfix), System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)) - ); - - MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer()); - } - - System.Collections.IEnumerator WaitForLocalPlayer() - { - while(PlayerSetup.Instance == null) - yield return null; - - m_localHandler = PlayerSetup.Instance.gameObject.AddComponent(); - } - - static void OnLocalAvatarClear_Postfix() => ms_instance?.OnLocalAvatarClear(); - void OnLocalAvatarClear() - { - if(m_localHandler != null) - m_localHandler.OnAvatarClear(); - } - - static void OnLocalAvatarSetup_Postfix() => ms_instance?.OnLocalAvatarSetup(); - void OnLocalAvatarSetup() - { - if((m_localHandler != null) && !PlayerSetup.Instance._inVr) - m_localHandler.OnAvatarSetup(); - } - } -} diff --git a/ml_aap/ParametersHandler.cs b/ml_aap/ParametersHandler.cs deleted file mode 100644 index 67e7fbc..0000000 --- a/ml_aap/ParametersHandler.cs +++ /dev/null @@ -1,235 +0,0 @@ -using ABI_RC.Core; -using ABI_RC.Core.Player; -using System; -using System.Collections.Generic; -using UnityEngine; - -namespace ml_aap -{ - class ParametersHandler : MonoBehaviour - { - enum AdditionalParameter - { - Upright, - Viseme, - Voice, - Muted, - InVR, - InHmd, - InFBT, - Zoom - } - enum AdditionalParameterSync - { - Local, - Synced - } - - struct AdditionalParameterInfo - { - public AdditionalParameter m_type; - public AdditionalParameterSync m_sync; - public string m_name; - public int m_hash; // For local only - } - - static readonly Vector4 ms_pointVector = new Vector4(0f, 0f, 0f, 1f); - static readonly System.Reflection.FieldInfo ms_visemeWeights = typeof(CVRVisemeController).GetField("visemeWeights", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); - - readonly List m_parameters = null; - bool m_active = false; - - CVRVisemeController m_visemeController = null; - - public ParametersHandler() - { - m_parameters = new List(); - } - - void Start() - { - if(PlayerSetup.Instance._inVr) - PlayerSetup.Instance.avatarSetupCompleted.AddListener(this.OnAvatarSetup); - } - - void Update() - { - if(m_active) - { - foreach(AdditionalParameterInfo l_param in m_parameters) - { - switch(l_param.m_type) - { - case AdditionalParameter.Upright: - { - Matrix4x4 l_hmdMatrix = PlayerSetup.Instance.transform.GetMatrix().inverse * (PlayerSetup.Instance._inVr ? PlayerSetup.Instance.vrHeadTracker.transform.GetMatrix() : PlayerSetup.Instance.desktopCameraRig.transform.GetMatrix()); - float l_currentHeight = Mathf.Clamp((l_hmdMatrix * ms_pointVector).y, 0f, float.MaxValue); - float l_avatarViewHeight = Mathf.Clamp(PlayerSetup.Instance.GetViewPointHeight() * PlayerSetup.Instance.GetAvatarScale().y, 0f, float.MaxValue); - float l_currentUpright = Mathf.Clamp((((l_currentHeight > 0f) && (l_avatarViewHeight > 0f)) ? (l_currentHeight / l_avatarViewHeight) : 0f), 0f, 1f); - - switch(l_param.m_sync) - { - case AdditionalParameterSync.Local: - PlayerSetup.Instance._animator.SetFloat(l_param.m_hash, l_currentUpright); - break; - case AdditionalParameterSync.Synced: - PlayerSetup.Instance.changeAnimatorParam(l_param.m_name, l_currentUpright); - break; - } - } - break; - - case AdditionalParameter.Viseme: - { - float[] l_weights = (float[])ms_visemeWeights?.GetValue(m_visemeController); - if(l_weights != null) - { - int l_index = 0; - float l_maxWeight = 0f; - - for(int i = 0; i < l_weights.Length; i++) - { - if(l_maxWeight < l_weights[i]) - { - l_maxWeight = l_weights[i]; - l_index = i; - } - } - - switch(l_param.m_sync) - { - case AdditionalParameterSync.Local: - PlayerSetup.Instance._animator.SetInteger(l_param.m_hash, l_index); - break; - case AdditionalParameterSync.Synced: - PlayerSetup.Instance.changeAnimatorParam(l_param.m_name, l_index); - break; - } - } - } - break; - - case AdditionalParameter.Voice: - { - switch(l_param.m_sync) - { - case AdditionalParameterSync.Local: - PlayerSetup.Instance._animator.SetFloat(l_param.m_hash, m_visemeController.visemeLoudness); - break; - case AdditionalParameterSync.Synced: - PlayerSetup.Instance.changeAnimatorParam(l_param.m_name, m_visemeController.visemeLoudness); - break; - } - } - break; - - case AdditionalParameter.InVR: - { - switch(l_param.m_sync) - { - case AdditionalParameterSync.Local: - PlayerSetup.Instance._animator.SetBool(l_param.m_hash, PlayerSetup.Instance._inVr); - break; - case AdditionalParameterSync.Synced: - PlayerSetup.Instance.changeAnimatorParam(l_param.m_name, PlayerSetup.Instance._inVr ? 1f : 0f); - break; - } - } - break; - - case AdditionalParameter.InHmd: - { - switch(l_param.m_sync) - { - case AdditionalParameterSync.Local: - PlayerSetup.Instance._animator.SetBool(l_param.m_hash, PlayerSetup.Instance._trackerManager.headsetOnHead); - break; - case AdditionalParameterSync.Synced: - PlayerSetup.Instance.changeAnimatorParam(l_param.m_name, PlayerSetup.Instance._trackerManager.headsetOnHead ? 1f : 0f); - break; - } - } break; - - case AdditionalParameter.InFBT: - { - switch(l_param.m_sync) - { - case AdditionalParameterSync.Local: - PlayerSetup.Instance._animator.SetBool(l_param.m_hash, PlayerSetup.Instance.fullBodyActive); - break; - case AdditionalParameterSync.Synced: - PlayerSetup.Instance.changeAnimatorParam(l_param.m_name, PlayerSetup.Instance.fullBodyActive ? 1f : 0f); - break; - } - } break; - - case AdditionalParameter.Muted: - { - switch(l_param.m_sync) - { - case AdditionalParameterSync.Local: - PlayerSetup.Instance._animator.SetBool(l_param.m_hash, RootLogic.Instance.comms.IsMuted); - break; - case AdditionalParameterSync.Synced: - PlayerSetup.Instance.changeAnimatorParam(l_param.m_name, RootLogic.Instance.comms.IsMuted ? 1f : 0f); - break; - } - } - break; - - case AdditionalParameter.Zoom: - { - switch(l_param.m_sync) - { - case AdditionalParameterSync.Local: - PlayerSetup.Instance._animator.SetFloat(l_param.m_hash, CVR_DesktopCameraController.currentZoomProgress); - break; - case AdditionalParameterSync.Synced: - PlayerSetup.Instance.changeAnimatorParam(l_param.m_name, CVR_DesktopCameraController.currentZoomProgress); - break; - } - } break; - } - } - } - } - - public void OnAvatarClear() - { - m_parameters.Clear(); - m_active = false; - m_visemeController = null; - } - - public void OnAvatarSetup() - { - m_visemeController = PlayerSetup.Instance._animator.GetComponent(); - - AnimatorControllerParameter[] l_params = PlayerSetup.Instance._animator.parameters; - AdditionalParameter[] l_enumParams = (AdditionalParameter[])Enum.GetValues(typeof(AdditionalParameter)); - - foreach(var l_param in l_params) - { - foreach(var l_enumParam in l_enumParams) - { - if(l_param.name.Contains(l_enumParam.ToString()) && (m_parameters.FindIndex(p => p.m_type == l_enumParam) == -1)) - { - bool l_local = (l_param.name[0] == '#'); - - m_parameters.Add(new AdditionalParameterInfo - { - m_type = l_enumParam, - m_sync = (l_local ? AdditionalParameterSync.Local : AdditionalParameterSync.Synced), - m_name = l_param.name, - m_hash = (l_local ? l_param.nameHash : 0) - }); - - break; - } - } - } - - m_active = (m_parameters.Count > 0); - } - } -} diff --git a/ml_aap/Properties/AssemblyInfo.cs b/ml_aap/Properties/AssemblyInfo.cs deleted file mode 100644 index 2e5b04e..0000000 --- a/ml_aap/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Reflection; - -[assembly: AssemblyTitle("AdditionalAvatarParameters")] -[assembly: AssemblyVersion("1.0.1")] -[assembly: AssemblyFileVersion("1.0.1")] - -[assembly: MelonLoader.MelonInfo(typeof(ml_aap.AdditionalAvatarParameters), "AdditionalAvatarParameters", "1.0.1", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] -[assembly: MelonLoader.MelonGame(null, "ChilloutVR")] -[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] -[assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)] \ No newline at end of file diff --git a/ml_aap/README.md b/ml_aap/README.md deleted file mode 100644 index 5f0288e..0000000 --- a/ml_aap/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# Additional Avatar Parameters -This mod adds additional paramaters for usage in avatar's animator. - -# Installation -* Install [latest MelonLoader](https://github.com/LavaGang/MelonLoader) -* Get [latest release DLL](../../../releases/latest): - * Put `ml_aap.dll` in `Mods` folder of game - -# Usage -List of new parameters that can be added to your AAS animator: -| Name | Type | Note | -|------|------|------| -| Upright | float | Proportion value between avatar's viewpoint height and floor, ranged in [0,1] | -| Viseme | int | Most active viseme index, ranged in [0,14], doesn't update in offline rooms | -| Voice | float | Voice level, ranged in [0,1], doesn't update in offline rooms | -| Muted | bool | Indicates if microphone is muted or unmuted | -| InVR | bool | Indicates if player is in VR | -| InHmd | bool | Indicates if players' headset is on head, can vary between different VR headsets | -| InFBT | bool | Indicates if player is in full body tracking mode | -| Zoom | float | Zoom level of camera, ranged in [0,1], desktop only | - -# Notes -* All new parameters use additional sync data besides listed in avatar's advanced settings. - * If character `#` is added at start of parameter's name it will be interpreted as local-only, won't be synced over network and won't use additional sync data. diff --git a/ml_aap/Utils.cs b/ml_aap/Utils.cs deleted file mode 100644 index 19c654e..0000000 --- a/ml_aap/Utils.cs +++ /dev/null @@ -1,13 +0,0 @@ -using UnityEngine; - -namespace ml_aap -{ - static class Utils - { - // Extensions - public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false) - { - return Matrix4x4.TRS(p_pos ? p_transform.position : Vector3.zero, p_rot ? p_transform.rotation : Quaternion.identity, p_scl ? p_transform.localScale : Vector3.one); - } - } -} diff --git a/ml_aap/ml_aap.csproj b/ml_aap/ml_aap.csproj deleted file mode 100644 index 13d6f7f..0000000 --- a/ml_aap/ml_aap.csproj +++ /dev/null @@ -1,74 +0,0 @@ - - - - - Debug - AnyCPU - {96D1D71A-23A4-4A0F-9736-25E711BA48F9} - Library - Properties - ml_aap - ml_aap - v4.7.2 - 512 - true - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - prompt - MinimumRecommendedRules.ruleset - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - prompt - MinimumRecommendedRules.ruleset - - - - F:\games\Steam\common\ChilloutVR\MelonLoader\0Harmony.dll - False - - - F:\games\Steam\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll - False - - - False - - - F:\games\Steam\common\ChilloutVR\MelonLoader\MelonLoader.dll - False - - - - - - - - - - False - - - False - - - - - - - - - - - copy /y "$(TargetPath)" "C:\Games\Steam\common\ChilloutVR\Mods\" - - \ No newline at end of file diff --git a/ml_aap/ml_aap.csproj.user b/ml_aap/ml_aap.csproj.user deleted file mode 100644 index 2539084..0000000 --- a/ml_aap/ml_aap.csproj.user +++ /dev/null @@ -1,6 +0,0 @@ - - - - C:\Games\Steam\common\ChilloutVR\MelonLoader\;C:\Games\Steam\common\ChilloutVR\ChilloutVR_Data\Managed\ - - \ No newline at end of file