Move many mods to Deprecated folder, fix spelling

This commit is contained in:
NotAKidoS 2025-04-03 02:57:35 -05:00
parent 5e822cec8d
commit 0042590aa6
539 changed files with 7475 additions and 3120 deletions

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk"/>

View file

@ -0,0 +1,140 @@
using ABI.CCK.Components;
using ABI_RC.Core.Player;
using UnityEngine;
namespace NAK.AASBufferFix;
public class AASBufferHelper : MonoBehaviour
{
///public bool DebuggingFlag = false;
//public stuff
public bool GameHandlesAAS { get; private set; }
//internal references
private PuppetMaster _puppetMaster;
//outside aas buffers
private float[] _aasBufferFloat = new float[0];
private int[] _aasBufferInt = new int[0];
private byte[] _aasBufferByte = new byte[0];
//calculated footprints
private int _aasFootprint = -1;
private int _avatarFootprint = 0;
private void Start() => _puppetMaster = GetComponent<PuppetMaster>();
public void OnAvatarInstantiated(Animator animator)
{
// have never run into an avatar without an animator until today
if (animator == null)
{
GameHandlesAAS = true;
return;
}
//check if avatar uses Avatar Advanced Settings
///SendDebug("[OnInit] Remote avatar initialized. Checking for AAS...");
CVRAvatar avatar = animator.GetComponent<CVRAvatar>();
if (avatar != null && !avatar.avatarUsesAdvancedSettings)
{
GameHandlesAAS = true;
return;
}
//check if AAS footprint is valid
///SendDebug("[OnInit] Avatar uses AAS. Generating AAS footprint...");
_avatarFootprint = Utils.GenerateAnimatorAASFootprint(animator);
if (_avatarFootprint == 1)
{
// we will let the game handle this by setting GameHandlesAAS to true
///SendDebug("[OnInit] Avatar does not contain valid AAS. It is likely hidden or blocked.");
GameHandlesAAS = true;
return;
}
///SendDebug($"[OnInit] Avatar footprint is : {_avatarFootprint}");
//check if we received expected AAS while we loaded the avatar, and if so, apply it now
if (SyncDataMatchesExpected())
{
///SendDebug("[OnInit] Valid buffered AAS found. Applying buffer...");
ApplyExternalAASBuffer();
return;
}
//we loaded avatar faster than wearer
///SendDebug("[OnInit] Remote avatar initialized faster than wearer. Waiting on valid AAS...");
}
public void OnAvatarDestroyed()
{
GameHandlesAAS = false;
_aasFootprint = -1;
_avatarFootprint = 0;
}
public void OnReceiveAAS(float[] settingsFloat, int[] settingsInt, byte[] settingsByte)
{
// Calculate AAS footprint to compare against.
_aasFootprint = (settingsFloat.Length + 1) * (settingsInt.Length + 1) * (settingsByte.Length + 1);
//if it matches, apply the settings and let game take over
if (SyncDataMatchesExpected())
{
///SendDebug("[OnSync] Avatar values matched and have been applied.");
ApplyExternalAAS(settingsFloat, settingsInt, settingsByte);
return;
}
//avatar is still loading on our side, we must assume AAS data is correct and store it until we load
//there is also a chance it errored
//if (_avatarFootprint == 0)
//{
// ///SendDebug("[OnSync] Avatar is still loading on our end.");
// StoreExternalAASBuffer(settingsFloat, settingsInt, settingsByte);
// return;
//}
//avatar is loaded on our end, and is not blocked by filter
//this does run if it is manually hidden or distance hidden
///SendDebug("[OnSync] Avatar is loaded on our side and is not blocked. Comparing for expected values.");
///SendDebug($"[OnSync] Avatar Footprint is : {_avatarFootprint}");
//if it did not match, that means the avatar we see on our side is different than what the remote user is wearing and syncing
///SendDebug("[OnSync] Avatar loaded is different than wearer. The wearer is likely still loading the avatar!");
StoreExternalAASBuffer(settingsFloat, settingsInt, settingsByte);
}
private void ApplyExternalAASBuffer()
{
GameHandlesAAS = true;
_puppetMaster?.ApplyAdvancedAvatarSettings(_aasBufferFloat, _aasBufferInt, _aasBufferByte);
}
private void ApplyExternalAAS(float[] settingsFloat, int[] settingsInt, byte[] settingsByte)
{
GameHandlesAAS = true;
_puppetMaster?.ApplyAdvancedAvatarSettings(settingsFloat, settingsInt, settingsByte);
}
private void StoreExternalAASBuffer(float[] settingsFloat, int[] settingsInt, byte[] settingsByte)
{
Array.Resize(ref _aasBufferFloat, settingsFloat.Length);
Array.Resize(ref _aasBufferInt, settingsInt.Length);
Array.Resize(ref _aasBufferByte, settingsByte.Length);
Array.Copy(settingsFloat, _aasBufferFloat, settingsFloat.Length);
Array.Copy(settingsInt, _aasBufferInt, settingsInt.Length);
Array.Copy(settingsByte, _aasBufferByte, settingsByte.Length);
}
private bool SyncDataMatchesExpected() => _aasFootprint == _avatarFootprint;
///private void SendDebug(string message)
///{
/// if (!DebuggingFlag) return;
/// AASBufferFix.Logger.Msg(message);
///}
}

View file

@ -0,0 +1,70 @@
using ABI_RC.Core;
using ABI_RC.Core.Base;
using ABI_RC.Core.Player;
using HarmonyLib;
using UnityEngine;
namespace NAK.AASBufferFix.HarmonyPatches;
[HarmonyPatch]
internal class HarmonyPatches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(PuppetMaster), "Start")]
private static void Postfix_PuppetMaster_Start(ref PuppetMaster __instance)
{
__instance.AddComponentIfMissing<AASBufferHelper>();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PuppetMaster), "AvatarInstantiated")]
private static void Postfix_PuppetMaster_AvatarInstantiated(ref PuppetMaster __instance, ref Animator ____animator)
{
AASBufferHelper externalBuffer = __instance.GetComponent<AASBufferHelper>();
externalBuffer?.OnAvatarInstantiated(____animator);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PuppetMaster), "AvatarDestroyed")]
private static void Postfix_PuppetMaster_AvatarDestroyed(ref PuppetMaster __instance)
{
AASBufferHelper externalBuffer = __instance.GetComponent<AASBufferHelper>();
externalBuffer?.OnAvatarDestroyed();
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PuppetMaster), "ApplyAdvancedAvatarSettings")]
private static bool Prefix_PuppetMaster_ApplyAdvancedAvatarSettings(float[] settingsFloat, int[] settingsInt, byte[] settingsByte, ref PuppetMaster __instance)
{
AASBufferHelper externalBuffer = __instance.GetComponent<AASBufferHelper>();
if (externalBuffer != null && !externalBuffer.GameHandlesAAS)
{
externalBuffer.OnReceiveAAS(settingsFloat, settingsInt, settingsByte);
return false;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(CVRAnimatorManager), "ApplyAdvancedAvatarSettingsFromBuffer")]
private static bool Prefix_CVRAnimatorManager_ApplyAdvancedAvatarSettingsFromBuffer(ref Animator ____animator)
{
AASBufferHelper externalBuffer = ____animator.GetComponentInParent<AASBufferHelper>();
if (externalBuffer != null && !externalBuffer.GameHandlesAAS)
{
//dont apply if stable buffer no exist
return false;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerSetup), "SendAdvancedAvatarSettings")]
private static bool Prefix_PlayerSetup_SendAdvancedAvatarSettings(ref PlayerSetup __instance)
{
//dont sync wrong settings to remote users
return !__instance.avatarIsLoading;
}
}

View file

@ -0,0 +1,12 @@
using MelonLoader;
namespace NAK.AASBufferFix;
public class AASBufferFix : MelonMod
{
///public static MelonLogger.Instance Logger;
public override void OnInitializeMelon()
{
///Logger = LoggerInstance;
}
}

View file

@ -0,0 +1,29 @@
using MelonLoader;
using NAK.AASBufferFix.Properties;
using System.Reflection;
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyTitle(nameof(NAK.AASBufferFix))]
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
[assembly: AssemblyProduct(nameof(NAK.AASBufferFix))]
[assembly: MelonInfo(
typeof(NAK.AASBufferFix.AASBufferFix),
nameof(NAK.AASBufferFix),
AssemblyInfoParams.Version,
AssemblyInfoParams.Author,
downloadLink: "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/AASBufferFix"
)]
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
namespace NAK.AASBufferFix.Properties;
internal static class AssemblyInfoParams
{
public const string Version = "1.0.7";
public const string Author = "NotAKidoS";
}

View file

@ -0,0 +1,26 @@
# AASBufferFix
Fixes two issues with the Avatar Advanced Settings buffers when loading remote avatars:
https://feedback.abinteractive.net/p/aas-is-still-synced-while-loading-an-avatar
https://feedback.abinteractive.net/p/aas-buffer-is-nuked-on-remote-load
Avatars will no longer load in naked or transition to the wrong state on load.
AAS will also not be updated unless the expected data matches what is received.
The avatar will stay in the default animator state until AAS data is received that is deemed correct.
You will no longer sync garbage AAS while switching avatar.
---
Here is the block of text where I tell you this mod is not affiliated or endorsed by ABI.
https://documentation.abinteractive.net/official/legal/tos/#7-modding-our-games
> This mod is an independent creation and is not affiliated with, supported by or approved by Alpha Blend Interactive.
> Use of this mod is done so at the user's own risk and the creator cannot be held responsible for any issues arising from its use.
> To the best of my knowledge, I have adhered to the Modding Guidelines established by Alpha Blend Interactive.

View file

@ -0,0 +1,67 @@
using UnityEngine;
namespace NAK.AASBufferFix;
public class Utils
{
public static int GenerateAnimatorAASFootprint(Animator animator)
{
int avatarFloatCount = 0;
int avatarIntCount = 0;
int avatarBoolCount = 0;
int bitCount = 0;
foreach (AnimatorControllerParameter animatorControllerParameter in animator.parameters)
{
// Do not count above bit limit
if (!(bitCount <= 3200))
break;
if (animatorControllerParameter.name.Length > 0 && animatorControllerParameter.name[0] != '#' && !coreParameters.Contains(animatorControllerParameter.name))
{
AnimatorControllerParameterType type = animatorControllerParameter.type;
switch (type)
{
case AnimatorControllerParameterType.Float:
avatarFloatCount++;
bitCount += 32;
break;
case AnimatorControllerParameterType.Int:
avatarIntCount++;
bitCount += 32;
break;
case AnimatorControllerParameterType.Bool:
avatarBoolCount++;
bitCount++;
break;
default:
//we dont count triggers
break;
}
}
}
//bool to byte
avatarBoolCount = ((int)Math.Ceiling((double)avatarBoolCount / 8));
//create the footprint
return (avatarFloatCount + 1) * (avatarIntCount + 1) * (avatarBoolCount + 1);
}
private static readonly HashSet<string> coreParameters = new HashSet<string>
{
"MovementX",
"MovementY",
"Grounded",
"Emote",
"GestureLeft",
"GestureRight",
"Toggle",
"Sitting",
"Crouching",
"CancelEmote",
"Prone",
"Flying"
};
}

View file

@ -0,0 +1,23 @@
{
"_id": 126,
"name": "AASBufferFix",
"modversion": "1.0.7",
"gameversion": "2022r170p1",
"loaderversion": "0.6.1",
"modtype": "Mod",
"author": "NotAKidoS",
"description": "Fixes two issues with the Avatar Advanced Settings buffers when loading remote avatars. In simple terms, it means 'fewer wardrobe malfunctions'.\n\nEmpty buffer (all 0/false) will no longer be applied on load.\nReceived AAS data is ignored until the wearer has loaded into the expected avatar.\n(The avatar will sit in its default state until the wearer has loaded and started syncing correct AAS)\nAAS will no longer be sent while switching avatar.\n\nPlease view the GitHub README for links to relevant feedback posts.",
"searchtags": [
"aas",
"sync",
"naked",
"buffer"
],
"requirements": [
"None"
],
"downloadlink": "https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r13/AASBufferFix.dll",
"sourcelink": "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/AASBufferFix/",
"changelog": "- Fixed an issue with the avatar footprint being calculated with values that exceed the 3200 AAS bit limit.",
"embedcolor": "9b59b6"
}