Пример #1
0
        private static void CacheAllModInfoAsync()
        {
            var mymod       = ModHelpersMod.Instance;
            var modInfoArgs = new ModInfoListPromiseArguments();

            GetModInfo.RetrieveAllModInfoAsync((modInfo, found) => {
                modInfoArgs.ModInfo = modInfo;
                modInfoArgs.Found   = found;

                Promises.TriggerValidatedPromise(GetModInfo.ModInfoListPromiseValidator, GetModInfo.PromiseValidatorKey, modInfoArgs);
            });

            Promises.AddValidatedPromise <ModInfoListPromiseArguments>(GetModInfo.ModInfoListPromiseValidator, (modInfoArgs2) => {
                if (modInfoArgs2.Found)
                {
                    GetModInfo.RetrieveBadModsAsync((badMods, found) => {
                        if (found)
                        {
                            GetModInfo.RegisterBadMods(modInfoArgs2, badMods);
                        }

                        Promises.TriggerValidatedPromise(GetModInfo.BadModsListPromiseValidator, GetModInfo.PromiseValidatorKey, modInfoArgs2);
                    });
                }

                return(true);
            });
        }
Пример #2
0
        private static void CacheAllModInfoAsync()
        {
            var mymod       = ModHelpersMod.Instance;
            var modInfoArgs = new ModInfoListLoadHookArguments();

            GetModInfo.RetrieveAllModInfoAsync((found, modInfo) => {
                modInfoArgs.ModInfo = modInfo;
                modInfoArgs.Found   = found;

                Timers.SetTimer("CacheAllModInfoAsyncFailsafe", 2, () => {
                    if (GetModInfo.ModInfoListLoadHookValidator == null)
                    {
                        return(true);
                    }

                    CustomLoadHooks.TriggerHook(
                        GetModInfo.ModInfoListLoadHookValidator,
                        GetModInfo.LoadHookValidatorKey,
                        modInfoArgs
                        );
                    return(false);
                });
            });

            CustomLoadHooks.AddHook(GetModInfo.ModInfoListLoadHookValidator, (modInfoArgs2) => {
                Thread.Sleep(2000);

                if (modInfoArgs2.Found)
                {
                    GetModInfo.RetrieveBadModsAsync((found, badMods) => {
                        if (found)
                        {
                            GetModInfo.RegisterBadMods(modInfoArgs2, badMods);
                        }

                        CustomLoadHooks.TriggerHook(
                            GetModInfo.BadModsListLoadHookValidator,
                            GetModInfo.LoadHookValidatorKey,
                            modInfoArgs2
                            );
                    });
                }

                return(true);
            });
        }