void ILoadable.OnPostModsLoad() { if (Main.dedServ) { return; } LoadHooks.AddPostModLoadHook(() => { Menus.InitializeDebugModeMenuInfo(); }); }
//////////////// internal RecipeHack() { LoadHooks.AddPostModLoadHook(() => { for (int i = 0; i < Recipe.maxRecipes; i++) { if (Main.recipe[i].createItem.type == 0) { break; } RecipeHack.BindRecipeItem(i); } }); }
public static void OnPostModsLoad() { if (Main.dedServ) { return; } LoadHooks.AddPostModLoadHook(() => { Menus.InitializeOpenConfigButton(); Menus.InitializeDebugModeMenuInfo(); ModTagsEditorMenuContext.Initialize(true); ModTagsModBrowserMenuContext.Initialize(true); ModUpdatesMenuContext.Initialize(); MenuTweaksMenuContext.Initialize(); //if( AprilFoolsMenuContext.IsAprilFools() ) { // AprilFoolsMenuContext.Initialize(); //} }); }
internal void OnModLoad() { LoadHooks.AddPostModLoadHook(() => { var hook = new CustomTimerAction(delegate() { if (Main.netMode == 1) { return; } this.ExpireCurrentWorldInSession(ResetModeMod.Instance); }); TimeLimitAPI.AddCustomAction("reset", hook); this.Load(); this.LoadRewards(); }); LoadHooks.AddPostWorldLoadEachHook(delegate { var mymod = ResetModeMod.Instance; if (mymod.Config.AutoStartSession) { if (Main.netMode == 0 || Main.netMode == 2) { this.StartSession(); } } this.IsWorldInPlay = true; }); LoadHooks.AddWorldUnloadEachHook(() => { this.IsWorldInPlay = false; }); LoadHooks.AddPostWorldUnloadEachHook(() => { var mymod = ResetModeMod.Instance; if (mymod.Config.DebugModeInfo) { LogHelpers.Alert("(In promise) - Unloading world..."); } this.IsExiting = false; if (mymod.CurrentNetMode == 0 || mymod.CurrentNetMode == 2) { if (mymod.Config.DeleteAllWorldsBetweenGames) { if (this.Data.AwaitingNextWorld) { this.ClearAllWorlds(); } } this.Save(); } CustomLoadHooks.TriggerHook(ResetModeMod.WorldExitValidator, ResetModeMod.MyValidatorKey); }); }
//////////////// internal EntityGroups() { LoadHooks.AddPostModLoadHook(() => { if (!this.IsEnabled) { return; } this.GetItemPool(); this.GetNPCPool(); this.GetProjPool(); ThreadPool.QueueUserWorkItem(_ => { int _check = 0; try { IList <EntityGroupMatcherDefinition <Item> > itemMatchers; IList <EntityGroupMatcherDefinition <NPC> > npcMatchers; IList <EntityGroupMatcherDefinition <Projectile> > projMatchers; lock (EntityGroups.MyLock) { itemMatchers = EntityGroups.DefineItemGroups(); _check++; npcMatchers = EntityGroups.DefineNPCGroups(); _check++; projMatchers = EntityGroups.DefineProjectileGroups(); _check++; } this.ComputeGroups <Item>(itemMatchers, ref this.ItemGroups, ref this.GroupsPerItem); _check++; this.ComputeGroups <NPC>(npcMatchers, ref this.NPCGroups, ref this.GroupsPerNPC); _check++; this.ComputeGroups <Projectile>(projMatchers, ref this.ProjGroups, ref this.GroupsPerProj); _check++; this.ComputeGroups <Item>(this.CustomItemMatchers, ref this.ItemGroups, ref this.GroupsPerItem); _check++; this.ComputeGroups <NPC>(this.CustomNPCMatchers, ref this.NPCGroups, ref this.GroupsPerNPC); _check++; this.ComputeGroups <Projectile>(this.CustomProjMatchers, ref this.ProjGroups, ref this.GroupsPerProj); _check++; lock (EntityGroups.MyLock) { this.CustomItemMatchers = null; this.CustomNPCMatchers = null; this.CustomProjMatchers = null; this.ItemPool = null; this.NPCPool = null; this.ProjPool = null; } CustomLoadHooks.TriggerHook(EntityGroups.LoadedAllValidator, EntityGroups.MyValidatorKey); _check++; } catch (Exception e) { LogHelpers.Warn("Initialization failed (at #" + _check + "): " + e.ToString()); } }); }); //LoadHooks.AddModUnloadHook( () => { // lock( EntityGroups.MyLock ) { } //} ); }