コード例 #1
0
        public static bool ApiSnifferStatic(IntPtr @this, IntPtr dictionary, IntPtr someRef, IntPtr methodInfo)
        {
            var result = ourOriginalApiPopulate(@this, dictionary, someRef, methodInfo);

            try
            {
                var apiModel = new ApiModel(@this);
                if (!apiModel.Populated)
                {
                    return(result);
                }

                var maybeUser = apiModel.TryCast <APIUser>();
                if (maybeUser != null)
                {
                    FavCatMod.Database?.UpdateStoredPlayer(maybeUser);
                }
                var maybeAvatar = apiModel.TryCast <Avatar>();
                if (maybeAvatar != null)
                {
                    FavCatMod.Database?.UpdateStoredAvatar(maybeAvatar);
                }
                var maybeWorld = apiModel.TryCast <ApiWorld>();
                if (maybeWorld != null)
                {
                    FavCatMod.Database?.UpdateStoredWorld(maybeWorld);
                }
            }
            catch (Exception ex)
            {
                MelonLogger.LogError($"Exception in API sniffer patch: {ex}");
            }

            return(result);
        }
コード例 #2
0
ファイル: FavCatMod.cs プロジェクト: knah/VRCMods
        private static void ApiSnifferBody(IntPtr @this)
        {
            try
            {
                var apiModel = new ApiModel(@this);
                if (!apiModel.Populated)
                {
                    return;
                }

                var maybeUser = apiModel.TryCast <APIUser>();
                if (maybeUser != null)
                {
                    FavCatMod.Database?.UpdateStoredPlayer(maybeUser);
                }
                var maybeWorld = apiModel.TryCast <ApiWorld>();
                if (maybeWorld != null)
                {
                    FavCatMod.Database?.UpdateStoredWorld(maybeWorld);
                }
            }
            catch (Exception ex)
            {
                MelonLogger.Error($"Exception in API sniffer patch: {ex}");
            }
        }