Removal of AdditionalAvatarParameters

This commit is contained in:
SDraw 2022-08-09 19:50:40 +03:00
parent 95817db6f2
commit 47298675e0
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
8 changed files with 0 additions and 420 deletions

View file

@ -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 |

View file

@ -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<ParametersHandler>();
}
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();
}
}
}

View file

@ -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<AdditionalParameterInfo> m_parameters = null;
bool m_active = false;
CVRVisemeController m_visemeController = null;
public ParametersHandler()
{
m_parameters = new List<AdditionalParameterInfo>();
}
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<CVRVisemeController>();
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);
}
}
}

View file

@ -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)]

View file

@ -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.

View file

@ -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);
}
}
}

View file

@ -1,74 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{96D1D71A-23A4-4A0F-9736-25E711BA48F9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ml_aap</RootNamespace>
<AssemblyName>ml_aap</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>F:\games\Steam\common\ChilloutVR\MelonLoader\0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>F:\games\Steam\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="DissonanceVoip">
<Private>False</Private>
</Reference>
<Reference Include="MelonLoader">
<HintPath>F:\games\Steam\common\ChilloutVR\MelonLoader\MelonLoader.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine.AnimationModule">
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="ParametersHandler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy /y "$(TargetPath)" "C:\Games\Steam\common\ChilloutVR\Mods\"</PostBuildEvent>
</PropertyGroup>
</Project>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ReferencePath>C:\Games\Steam\common\ChilloutVR\MelonLoader\;C:\Games\Steam\common\ChilloutVR\ChilloutVR_Data\Managed\</ReferencePath>
</PropertyGroup>
</Project>