Exemple #1
0
        private static bool CanUseCustomAvatarPatch(IntPtr thisPtr, IntPtr apiUserPtr, ref int denyReason)
        {
            var result = ourCanUseCustomAvatarDelegate(thisPtr, apiUserPtr, ref denyReason);

            try
            {
                if (!SwitchAvatarCookie.ourInSwitch || SwitchAvatarCookie.ourApiAvatar == null)
                {
                    return(result);
                }

                var apiAvatar     = SwitchAvatarCookie.ourApiAvatar;
                var avatarManager = SwitchAvatarCookie.ourAvatarManager;

                var vrcPlayer = avatarManager.field_Private_VRCPlayer_0;
                if (vrcPlayer == null)
                {
                    return(result);
                }

                if (vrcPlayer == VRCPlayer.field_Internal_Static_VRCPlayer_0) // never apply to self
                {
                    return(result);
                }

                var apiUser = vrcPlayer.prop_Player_0?.prop_APIUser_0;
                if (apiUser == null)
                {
                    return(result);
                }

                var userId = apiUser.id;
                if (!AdvancedSafetySettings.IncludeFriendsInHides && APIUser.IsFriendsWith(userId))
                {
                    return(result);
                }

                if (AdvancedSafetySettings.HidesAbideByShowAvatar &&
                    AdvancedSafetyMod.IsAvatarExplicitlyShown(userId))
                {
                    return(result);
                }

                if (ourBlockedAvatarAuthors.ContainsKey(apiAvatar.authorId) ||
                    ourBlockedAvatars.ContainsKey(apiAvatar.id))
                {
                    MelonLogger.Log(
                        $"Hiding avatar on {apiUser.displayName} because it or its author is hidden");
                    denyReason = 3;
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MelonLogger.LogError($"Exception in CanUseCustomAvatarPatch: {ex}");
            }

            return(result);
        }
Exemple #2
0
        private static void CanUseCustomAvatarPostfix(ref bool __result)
        {
            try
            {
                if (!SwitchAvatarCookie.ourInSwitch || SwitchAvatarCookie.ourApiAvatar == null)
                {
                    return;
                }

                var apiAvatar     = SwitchAvatarCookie.ourApiAvatar;
                var avatarManager = SwitchAvatarCookie.ourAvatarManager;

                var vrcPlayer = avatarManager.field_Private_VRCPlayer_0;
                if (vrcPlayer == null)
                {
                    return;
                }

                if (vrcPlayer == VRCPlayer.field_Internal_Static_VRCPlayer_0) // never apply to self
                {
                    return;
                }

                var apiUser = vrcPlayer.prop_Player_0?.prop_APIUser_0;
                if (apiUser == null)
                {
                    return;
                }

                var userId = apiUser.id;
                if (!AdvancedSafetySettings.IncludeFriendsInHides.Value && APIUser.IsFriendsWith(userId))
                {
                    return;
                }

                if (AdvancedSafetySettings.HidesAbideByShowAvatar.Value &&
                    AdvancedSafetyMod.IsAvatarExplicitlyShown(userId))
                {
                    return;
                }

                if (ourBlockedAvatarAuthors.ContainsKey(apiAvatar.authorId) ||
                    ourBlockedAvatars.ContainsKey(apiAvatar.id))
                {
                    MelonLogger.Msg(
                        $"Hiding avatar on {apiUser.displayName} because it or its author is hidden");
                    // denyReason = 3;
                    __result = false;
                }
            }
            catch (Exception ex)
            {
                MelonLogger.Error($"Exception in CanUseCustomAvatarPatch: {ex}");
            }
        }