[AASBufferFix] Fix error when animator is null

This commit is contained in:
NotAKidoS 2023-06-06 10:52:39 -05:00
parent 6e262bac1b
commit d04f505d88
5 changed files with 16 additions and 9 deletions

View file

@ -27,6 +27,13 @@ public class AASBufferHelper : MonoBehaviour
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>();

View file

@ -21,15 +21,17 @@ internal class HarmonyPatches
private static void Postfix_PuppetMaster_AvatarInstantiated(ref PuppetMaster __instance, ref Animator ____animator)
{
AASBufferHelper externalBuffer = __instance.GetComponent<AASBufferHelper>();
if (externalBuffer != null) externalBuffer.OnAvatarInstantiated(____animator);
}
externalBuffer?.OnAvatarInstantiated(____animator);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PuppetMaster), "AvatarDestroyed")]
private static void Postfix_PuppetMaster_AvatarDestroyed(ref PuppetMaster __instance)
{
AASBufferHelper externalBuffer = __instance.GetComponent<AASBufferHelper>();
if (externalBuffer != null) externalBuffer.OnAvatarDestroyed();
externalBuffer?.OnAvatarDestroyed();
}
[HarmonyPrefix]

View file

@ -24,6 +24,6 @@ using System.Reflection;
namespace NAK.AASBufferFix.Properties;
internal static class AssemblyInfoParams
{
public const string Version = "1.0.5";
public const string Version = "1.0.6";
public const string Author = "NotAKidoS";
}

View file

@ -20,8 +20,6 @@ public class Utils
case AnimatorControllerParameterType.Float:
avatarFloatCount++;
break;
case (AnimatorControllerParameterType)2:
break;
case AnimatorControllerParameterType.Int:
avatarIntCount++;
break;

View file

@ -1,7 +1,7 @@
{
"_id": 126,
"name": "AASBufferFix",
"modversion": "1.0.5",
"modversion": "1.0.6",
"gameversion": "2022r170",
"loaderversion": "0.5.7",
"modtype": "Mod",
@ -16,8 +16,8 @@
"requirements": [
"None"
],
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r3/AASBufferFix.dll",
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r9/AASBufferFix.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/AASBufferFix/",
"changelog": "",
"changelog": "Fixed an error when a remote avatar does not have an Animator component.",
"embedcolor": "9b59b6"
}