NAK_CVR_Mods/AASBufferFix/Utils.cs
NotAKidoS 9332b06d06 Don't send AAS while switching avatar.
Don't send AAS while switching avatar. This should mean I am less likely to load into the wrong states while switching if others load me faster.

This does mean though that it is more likely that remote users will apply null buffers forcing all 0/false instead of garbage aas, but its at least kind of a mitigation.

There is a possibility syncing garbage data is better than syncing nothing at all, as that does give the chance to apply settings that don't immediatly load in naked. This just requires testing...
2023-02-12 04:42:07 -06:00

60 lines
1.8 KiB
C#

using UnityEngine;
namespace NAK.Melons.AASBufferFix;
public class Utils
{
public static int GenerateAnimatorAASFootprint(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++;
break;
case (AnimatorControllerParameterType)2:
break;
case AnimatorControllerParameterType.Int:
avatarIntCount++;
break;
case AnimatorControllerParameterType.Bool:
avatarBoolCount++;
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 HashSet<string> coreParameters = new HashSet<string>
{
"MovementX",
"MovementY",
"Grounded",
"Emote",
"GestureLeft",
"GestureRight",
"Toggle",
"Sitting",
"Crouching",
"CancelEmote",
"Prone",
"Flying"
};
}