mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-01 22:09:23 +00:00
bruh
This commit is contained in:
parent
6a488abde8
commit
b5fb7bdac6
7 changed files with 328 additions and 0 deletions
126
AASBufferFix/AASBufferFix.cs
Normal file
126
AASBufferFix/AASBufferFix.cs
Normal file
|
@ -0,0 +1,126 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.Melons.AASBufferFix;
|
||||
|
||||
public class AASBufferFix : MonoBehaviour
|
||||
{
|
||||
public PuppetMaster puppetMaster;
|
||||
|
||||
public bool isAcceptingAAS = false;
|
||||
|
||||
public float[] aasBufferFloat = new float[0];
|
||||
public int[] aasBufferInt = new int[0];
|
||||
public byte[] aasBufferByte = new byte[0];
|
||||
|
||||
public int aasFootprint = -1;
|
||||
public int avatarFootprint = -1;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
puppetMaster = GetComponent<PuppetMaster>();
|
||||
}
|
||||
|
||||
public void StoreExternalAASBuffer(float[] settingsFloat, int[] settingsInt, byte[] settingsByte)
|
||||
{
|
||||
//resize buffer if size changed, only should happen on first new avatar load
|
||||
if (aasBufferFloat.Length == settingsFloat.Length)
|
||||
aasBufferFloat = new float[settingsFloat.Length];
|
||||
|
||||
if (aasBufferInt.Length == settingsInt.Length)
|
||||
aasBufferInt = new int[settingsInt.Length];
|
||||
|
||||
if (aasBufferByte.Length == settingsByte.Length)
|
||||
aasBufferByte = new byte[settingsByte.Length];
|
||||
|
||||
aasBufferFloat = settingsFloat;
|
||||
aasBufferInt = settingsInt;
|
||||
aasBufferByte = settingsByte;
|
||||
|
||||
//haha shit lazy implementation
|
||||
aasFootprint = ((aasBufferFloat.Length * 32) + 1) * ((aasBufferInt.Length * 32) + 1) * ((aasBufferByte.Length * 8) + 1);
|
||||
|
||||
CheckForFootprintMatch();
|
||||
}
|
||||
|
||||
public void OnAvatarInstantiated(Animator animator)
|
||||
{
|
||||
avatarFootprint = GenerateAvatarFootprint(animator);
|
||||
CheckForFootprintMatch();
|
||||
}
|
||||
|
||||
public void OnAvatarDestroyed()
|
||||
{
|
||||
isAcceptingAAS = false;
|
||||
//clear buffer
|
||||
aasBufferFloat = new float[0];
|
||||
aasBufferInt = new int[0];
|
||||
aasBufferByte = new byte[0];
|
||||
avatarFootprint = 0;
|
||||
aasFootprint = -1;
|
||||
}
|
||||
|
||||
public void CheckForFootprintMatch()
|
||||
{
|
||||
//only apply if avatar footprints match
|
||||
if (aasFootprint == avatarFootprint)
|
||||
{
|
||||
isAcceptingAAS = true;
|
||||
puppetMaster?.ApplyAdvancedAvatarSettings(aasBufferFloat, aasBufferInt, aasBufferByte);
|
||||
}
|
||||
}
|
||||
|
||||
public int GenerateAvatarFootprint(Animator animator)
|
||||
{
|
||||
int avatarFloatCount = 0;
|
||||
int avatarIntCount = 0;
|
||||
int avatarBoolCount = 0;
|
||||
|
||||
foreach (AnimatorControllerParameter animatorControllerParameter in animator.parameters)
|
||||
{
|
||||
if (animatorControllerParameter.name.Length > 0 && animatorControllerParameter.name[0] != '#' && !coreParameters.Contains(animatorControllerParameter.name))
|
||||
{
|
||||
AnimatorControllerParameterType type = animatorControllerParameter.type;
|
||||
switch (type)
|
||||
{
|
||||
case AnimatorControllerParameterType.Float:
|
||||
avatarFloatCount += 32;
|
||||
break;
|
||||
case (AnimatorControllerParameterType)2:
|
||||
break;
|
||||
case AnimatorControllerParameterType.Int:
|
||||
avatarIntCount += 32;
|
||||
break;
|
||||
case AnimatorControllerParameterType.Bool:
|
||||
avatarBoolCount++;
|
||||
break;
|
||||
default:
|
||||
//we dont count triggers
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//bool to byte
|
||||
avatarBoolCount = ((int)Math.Ceiling((double)avatarBoolCount / 8) * 8);
|
||||
|
||||
//create the footprint
|
||||
return (avatarFloatCount + 1) * (avatarIntCount + 1) * (avatarBoolCount + 1);
|
||||
}
|
||||
|
||||
private static HashSet<string> coreParameters = new HashSet<string>
|
||||
{
|
||||
"MovementX",
|
||||
"MovementY",
|
||||
"Grounded",
|
||||
"Emote",
|
||||
"GestureLeft",
|
||||
"GestureRight",
|
||||
"Toggle",
|
||||
"Sitting",
|
||||
"Crouching",
|
||||
"CancelEmote",
|
||||
"Prone",
|
||||
"Flying"
|
||||
};
|
||||
}
|
52
AASBufferFix/AASBufferFix.csproj
Normal file
52
AASBufferFix/AASBufferFix.csproj
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="0Harmony">
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\0Harmony.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp-firstpass">
|
||||
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BTKUILib">
|
||||
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\Mods\BTKUILib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Cohtml.Runtime">
|
||||
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MelonLoader">
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.AnimationModule">
|
||||
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.AnimationModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.AssetBundleModule">
|
||||
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.AssetBundleModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.InputLegacyModule">
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.PhysicsModule">
|
||||
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="Deploy" AfterTargets="Build">
|
||||
<Copy SourceFiles="$(TargetPath)" DestinationFolder="C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\Mods\" />
|
||||
<Message Text="Copied $(TargetPath) to C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\Mods\" Importance="high" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
25
AASBufferFix/AASBufferFix.sln
Normal file
25
AASBufferFix/AASBufferFix.sln
Normal file
|
@ -0,0 +1,25 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.2.32630.192
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AASBufferFix", "AASBufferFix.csproj", "{9C6339E8-657C-4A1F-9324-12BFB2558BBB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9C6339E8-657C-4A1F-9324-12BFB2558BBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9C6339E8-657C-4A1F-9324-12BFB2558BBB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9C6339E8-657C-4A1F-9324-12BFB2558BBB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9C6339E8-657C-4A1F-9324-12BFB2558BBB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {D2EEA814-859D-4EE4-ADC8-DDDD36383310}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
61
AASBufferFix/HarmonyPatches.cs
Normal file
61
AASBufferFix/HarmonyPatches.cs
Normal file
|
@ -0,0 +1,61 @@
|
|||
using ABI_RC.Core;
|
||||
using ABI_RC.Core.Base;
|
||||
using ABI_RC.Core.Player;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.Melons.AASBufferFix.HarmonyPatches;
|
||||
|
||||
[HarmonyPatch]
|
||||
internal class HarmonyPatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PuppetMaster), "Start")]
|
||||
private static void Postfix_PuppetMaster_Start(ref PuppetMaster __instance)
|
||||
{
|
||||
AASBufferFix externalBuffer = __instance.AddComponentIfMissing<AASBufferFix>();
|
||||
externalBuffer.puppetMaster = __instance;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PuppetMaster), "AvatarInstantiated")]
|
||||
private static void Postfix_PuppetMaster_AvatarInstantiated(ref PuppetMaster __instance, ref Animator ____animator)
|
||||
{
|
||||
AASBufferFix externalBuffer = __instance.GetComponent<AASBufferFix>();
|
||||
if (externalBuffer != null) externalBuffer.OnAvatarInstantiated(____animator);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PuppetMaster), "AvatarDestroyed")]
|
||||
private static void Postfix_PuppetMaster_AvatarDestroyed(ref PuppetMaster __instance)
|
||||
{
|
||||
AASBufferFix externalBuffer = __instance.GetComponent<AASBufferFix>();
|
||||
if (externalBuffer != null) externalBuffer.OnAvatarDestroyed();
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(PuppetMaster), "ApplyAdvancedAvatarSettings")]
|
||||
private static bool Prefix_PuppetMaster_ApplyAdvancedAvatarSettings(float[] settingsFloat, int[] settingsInt, byte[] settingsByte, ref PuppetMaster __instance)
|
||||
{
|
||||
AASBufferFix externalBuffer = __instance.GetComponent<AASBufferFix>();
|
||||
if (externalBuffer != null && !externalBuffer.isAcceptingAAS)
|
||||
{
|
||||
externalBuffer.StoreExternalAASBuffer(settingsFloat, settingsInt, settingsByte);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(CVRAnimatorManager), "ApplyAdvancedAvatarSettingsFromBuffer")]
|
||||
private static bool Prefix_PuppetMaster_ApplyAdvancedAvatarSettingsFromBuffer(ref Animator ____animator)
|
||||
{
|
||||
AASBufferFix externalBuffer = ____animator.GetComponentInParent<AASBufferFix>();
|
||||
if (externalBuffer != null && !externalBuffer.isAcceptingAAS)
|
||||
{
|
||||
//dont apply if stable buffer no exist
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
11
AASBufferFix/Main.cs
Normal file
11
AASBufferFix/Main.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
using MelonLoader;
|
||||
|
||||
namespace NAK.Melons.AASBufferFix;
|
||||
|
||||
public class AASBufferFixMod : MelonMod
|
||||
{
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
30
AASBufferFix/Properties/AssemblyInfo.cs
Normal file
30
AASBufferFix/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using AASBufferFix.Properties;
|
||||
using MelonLoader;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyTitle(nameof(NAK.Melons.AASBufferFix))]
|
||||
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
|
||||
[assembly: AssemblyProduct(nameof(NAK.Melons.AASBufferFix))]
|
||||
|
||||
[assembly: MelonInfo(
|
||||
typeof(NAK.Melons.AASBufferFix.AASBufferFixMod),
|
||||
nameof(NAK.Melons.AASBufferFix),
|
||||
AssemblyInfoParams.Version,
|
||||
AssemblyInfoParams.Author,
|
||||
downloadLink: "https://github.com/NotAKidOnSteam/AASBufferFix"
|
||||
)]
|
||||
|
||||
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||
|
||||
namespace AASBufferFix.Properties;
|
||||
internal static class AssemblyInfoParams
|
||||
{
|
||||
public const string Version = "1.0.0";
|
||||
public const string Author = "NotAKidoS";
|
||||
}
|
23
AASBufferFix/format.json
Normal file
23
AASBufferFix/format.json
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"_id": -1,
|
||||
"name": "AASBufferFix",
|
||||
"modversion": "1.0.0",
|
||||
"gameversion": "2022r170",
|
||||
"loaderversion": "0.5.7",
|
||||
"modtype": "Mod",
|
||||
"author": "NotAKidoS",
|
||||
"description": "Fixes two AAS buffer issues. Remote avatars with AAS will no longer experience wardrobe malfunctions on initialization.\n\nAAS will not be applied unless the synced data matches what is expected of the loaded avatar.",
|
||||
"searchtags": [
|
||||
"aas",
|
||||
"sync",
|
||||
"naked",
|
||||
"buffer"
|
||||
],
|
||||
"requirements": [
|
||||
"None"
|
||||
],
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/AASBufferFix/releases/download/v1.0.0/AASBufferFix.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/AASBufferFix/",
|
||||
"changelog": "- Initial Release",
|
||||
"embedcolor": "9b59b6"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue