//////////////// private static void CacheAllModTagsAsync() { ThreadPool.QueueUserWorkItem(_ => { lock (GetModTags.MyLock) { var mymod = ModHelpersMod.Instance; var args = new ModTagsLoadHookArguments { Found = false }; GetModTags.RetrieveAllModTagsAsync((success, modTags) => { try { if (success) { args.SetTagMods(modTags); } args.Found = success; CustomLoadHooks.TriggerHook(GetModTags.TagsReceivedHookValidator, GetModTags.TagsReceivedHookValidatorKey, args); } catch (Exception e) { LogHelpers.Alert(e.ToString()); } }); } }); }
//////////////// private void ApplyDefaultFiltersAsync(UIState modBrowserUi) { CustomLoadHooks.AddHook(GetModTags.TagsReceivedHookValidator, (args) => { Timers.SetTimer("ModBrowserDefaultTagStates", 15, () => { bool isLoading; if (!ReflectionHelpers.Get(modBrowserUi, "loading", out isLoading)) { LogHelpers.Warn("ModBrowserTagsMenuContext - No 'loading'."); return(false); } if (isLoading) { return(true); } else { //UITagButton button = this.TagButtons["Misleading Info"]; //button.SetTagState( -1 ); return(false); } }); return(true); }); }
//////////////// /// <summary> /// Checks if the mod has new versions available from the mod browser, then updates it's overlay accordingly. /// </summary> public void CheckForNewVersionAsync() { CustomLoadHooks.AddHook(GetModInfo.ModInfoListLoadHookValidator, (args) => { if (args.Found && args.ModInfo.ContainsKey(this.Mod.Name)) { this.LatestAvailableVersion = args.ModInfo[this.Mod.Name].Version; } else { if (ModHelpersMod.Config.DebugModeNetInfo) { LogHelpers.Log("Error retrieving version number of '" + this.Mod.DisplayName + "'"); //+ "': " + reason ); } } return(false); }); /*Action<Version> onSuccess = delegate ( Version vers ) { * this.LatestAvailableVersion = vers; * }; * Action<string> onFail = delegate ( string reason ) { * if( ModHelpersMod.Instance.Config.DebugModeNetInfo ) { * LogHelpers.Log( "Error retrieving version number of '" + this.Mod.DisplayName + "': " + reason ); * } * }; * * GetModVersion.GetLatestKnownVersionAsync( this.Mod, onSuccess, onFail );*/ }
internal void PostOnEnterWorld() { CustomLoadHooks.TriggerHook(LicensesPlayer.EnterWorldValidator, LicensesPlayer.MyValidatorKey); LoadHooks.AddWorldUnloadOnceHook(() => { CustomLoadHooks.ClearHook(LicensesPlayer.EnterWorldValidator, LicensesPlayer.MyValidatorKey); }); }
private void OnFinishPlayerEnterWorldForAny() { CustomLoadHooks.TriggerHook(RewardsPlayer.EnterWorldValidator, RewardsPlayer.MyValidatorKey); LoadHooks.AddWorldUnloadOnceHook(() => { CustomLoadHooks.ClearHook(RewardsPlayer.EnterWorldValidator, RewardsPlayer.MyValidatorKey); }); }
private void PostLoadGameMode() { CustomLoadHooks.TriggerHook( LicensesMod.GameModeLoadValidator, LicensesMod.MyValidatorKey ); LoadHooks.AddWorldUnloadEachHook( () => { CustomLoadHooks.ClearHook( LicensesMod.GameModeLoadValidator, LicensesMod.MyValidatorKey ); LoadHooks.AddWorldLoadOnceHook( () => { CustomLoadHooks.TriggerHook( LicensesMod.GameModeLoadValidator, LicensesMod.MyValidatorKey ); // Whee! } ); } ); }
public void OnServerConnect(Player player) { var mymod = ModHelpersMod.Instance; this.HasSyncedWorldData = true; this.IsSynced = true; // Technically this should only be set upon sync receipt of player's 'old' uid... CustomLoadHooks.TriggerHook(PlayerLogic.ServerConnectHookValidator, PlayerLogic.MyValidatorKey, player.whoAmI); PlayerOldIdProtocol.QuickRequestToClient(player.whoAmI); PlayerNewIdProtocol.QuickRequestToClient(player.whoAmI); }
//////////////// internal void UpdateMode(bool isEditing) { if (!isEditing) { return; } CustomLoadHooks.AddHook(GetModInfo.BadModsListLoadHookValidator, (modInfoArgs) => { this.ApplyDefaultEditModeTags(modInfoArgs.ModInfo); return(false); }); }
//////////////// public void SetCurrentModAsync(string modName) { CustomLoadHooks.AddHook(GetModTags.TagsReceivedHookValidator, (args) => { if (!args.Found) { LogHelpers.Warn(); return(false); } this.SetCurrentMod(modName, args.Found, args.ModTags); return(false); }); }
public void UnloadModules() { this.Loadables.OnModsUnload(); this.Loadables = null; this.ReflectionHelpers = null; this.PacketProtocolMngr = null; this.ExceptionMngr = null; this.Timers = null; this.LogHelpers = null; this.ModFeaturesHelpers = null; this.BuffHelpers = null; this.NetHelpers = null; this.NPCAttributeHelpers = null; this.ProjectileAttributeHelpers = null; this.BuffIdentityHelpers = null; this.NPCBannerHelpers = null; this.RecipeFinderHelpers = null; this.RecipeGroupHelpers = null; this.PlayerHooks = null; this.LoadHelpers = null; this.GetModInfo = null; this.GetModTags = null; this.WorldStateHelpers = null; this.ModLock = null; this.EntityGroups = null; this.AnimatedColors = null; this.AnimatedTextures = null; this.PlayerMessages = null; this.Inbox = null; this.ControlPanel = null; this.MenuItemMngr = null; this.MenuContextMngr = null; this.MusicHelpers = null; this.PlayerIdentityHelpers = null; this.LoadHooks = null; this.CustomLoadHooks = null; this.DataStore = null; this.CustomHotkeys = null; this.XnaHelpers = null; this.Server = null; //this.PlayerDataMngr = null; this.SupportInfo = null; this.RecipeHack = null; this.ModListHelpers = null; this.ItemAttributeHelpers = null; this.WorldTimeHooks = null; this.ControlPanelHotkey = null; this.DataDumpHotkey = null; }
//////////////// private void FilterModsAsync(UIState _menuUi, IList <string> modNames, FilteredModsHandler callback) { CustomLoadHooks.AddHook(GetModTags.TagsReceivedHookValidator, (args) => { if (!args.Found) { this.SetInfoText("Could not acquire mod data."); callback(_menuUi, false, new List <string>(), 0, 0); return(false); } this.FilterMods(_menuUi, modNames, args.ModTags, callback); return(false); }); }
/// <param name="theme">Visual appearance.</param> /// <param name="idx">ID number assigned to this element in its list.</param> /// <param name="mod">Mod represented by this element.</param> /// <param name="willDrawOwnHoverElements">Indicates if this element draws its own mouse-hover elements.</param> public UIModData(UITheme theme, int?idx, Mod mod, bool willDrawOwnHoverElements = true) : base(theme, true) { this.InitializeMe(idx, mod, willDrawOwnHoverElements); CustomLoadHooks.AddHook(GetModTags.TagsReceivedHookValidator, (args) => { ISet <string> modTags = args.ModTags?.GetOrDefault(mod.Name); this.ModTags = modTags ?? this.ModTags; return(false); }); this.RefreshTheme(); }
//////////////// public override void Show(UIState ui) { base.Show(ui); Timers.SetTimer("ModHelpersUpdatesLoaderPause", 5, () => { CustomLoadHooks.AddHook(GetModInfo.ModInfoListLoadHookValidator, (args) => { if (args != null) { this.DisplayModListVersions(ui, args.ModInfo); } return(false); }); return(false); }); }
private void LoadModules() { this.Loadables.OnModsLoad(); this.ReflectionHelpers = new ReflectionHelpers(); this.DataStore = new DataStore(); this.LoadHooks = new LoadHooks(); this.CustomLoadHooks = new CustomLoadHooks(); this.LoadHelpers = new LoadHelpers(); this.Timers = new Timers(); this.LogHelpers = new LogHelpers(); this.ModFeaturesHelpers = new ModFeaturesHelpers(); this.PacketProtocolMngr = new PacketProtocolManager(); this.BuffHelpers = new BuffHelpers(); this.NetHelpers = new NetPlayHelpers(); this.NPCAttributeHelpers = new NPCAttributeHelpers(); this.ProjectileAttributeHelpers = new ProjectileAttributeHelpers(); this.BuffIdentityHelpers = new BuffAttributesHelpers(); this.NPCBannerHelpers = new NPCBannerHelpers(); this.RecipeFinderHelpers = new RecipeFinderHelpers(); this.RecipeGroupHelpers = new RecipeGroupHelpers(); this.PlayerHooks = new ExtendedPlayerHooks(); this.WorldTimeHooks = new WorldTimeHooks(); this.WorldStateHelpers = new WorldStateHelpers(); this.ControlPanel = new UIControlPanel(); this.ModLock = new ModLockService(); this.EntityGroups = new EntityGroups(); this.PlayerMessages = new PlayerMessages(); this.Inbox = new InboxControl(); this.GetModInfo = new GetModInfo(); this.GetModTags = new GetModTags(); this.MenuItemMngr = new MenuItemManager(); this.MenuContextMngr = new MenuContextServiceManager(); this.MusicHelpers = new MusicHelpers(); this.PlayerIdentityHelpers = new PlayerIdentityHelpers(); this.CustomHotkeys = new CustomHotkeys(); this.XnaHelpers = new XNAHelpers(); this.Server = new Server(); //this.PlayerDataMngr = new PlayerDataManager(); this.SupportInfo = new SupportInfoDisplay(); this.RecipeHack = new RecipeHack(); this.ModListHelpers = new ModListHelpers(); this.ItemAttributeHelpers = new ItemAttributeHelpers(); }
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); }); }
public override void Load() { LoadHooks.AddWorldLoadEachHook(delegate { this.CurrentNetMode = Main.netMode; }); CustomLoadHooks.AddHook(ResetModeMod.WorldExitValidator, (_) => { this.CurrentNetMode = -1; return(true); }); this.Session.OnModLoad(); DataDumper.SetDumpSource("ResetMode", () => { return(ResetModeMod.Instance.Session.Data.ToString()); }); }
public override TagCompound Save() { //DataStore.Add( DebugHelpers.GetCurrentContext()+"_A", 1 ); var mymod = (ModHelpersMod)this.mod; TagCompound tags = new TagCompound(); tags["world_id"] = this.ObsoleteId; //mymod.UserHelpers.Save( mymod, tags ); mymod.ModLock.Save(tags); this.WorldLogic.SaveForWorld(tags); CustomLoadHooks.TriggerHook(ModHelpersWorld.SaveValidator, ModHelpersWorld.MyValidatorKey); //DataStore.Add( DebugHelpers.GetCurrentContext()+"_B", 1 ); return(tags); }
/// <summary> /// Reports whether a given mod (by the given internal name), once loaded, is "properly presented": Has a valid /// description, homepage, and any other needed checks (in future considerations). /// </summary> /// <param name="modName"></param> /// <param name="callback"></param> public static void IsListModProperlyPresented(string modName, Action <bool> callback) { CustomLoadHooks.AddHook(GetModInfo.ModInfoListLoadHookValidator, (args) => { if (args.Found && args.ModInfo.ContainsKey(modName)) { BasicModInfo modInfo = args.ModInfo[modName]; bool isProper = ModIdentityHelpers.IsProperlyPresented(modInfo); callback(isProper); } else { if (ModHelpersMod.Config.DebugModeNetInfo) { LogHelpers.Log("Error retrieving mod data for '" + modName + "'"); //+ "': " + reason ); } } return(false); }); }
//////////////// public override void Load(TagCompound tags) { //DataStore.Add( DebugHelpers.GetCurrentContext()+"_"+this.player.name+":"+this.player.whoAmI+"_A", 1 ); try { //PlayerData.LoadAll( this.player.whoAmI, tags ); this.Logic.Load(tags); CustomLoadHooks.TriggerHook( ModHelpersPlayer.LoadValidator, ModHelpersPlayer.MyValidatorKey, this.player.whoAmI ); } catch (Exception e) { if (!(e is ModHelpersException)) { //throw new HamstarException( "!ModHelpers.ModHelpersPlayer.Load - " + e.ToString() ); throw new ModHelpersException(e.ToString()); } } //DataStore.Add( DebugHelpers.GetCurrentContext()+"_"+this.player.name+":"+this.player.whoAmI+"_B", 1 ); }
//////////////// public override void SetDefaults() { int mytype = this.Type; this.DisplayName.SetDefault("Encumbered"); this.Description.SetDefault("You're weighted down" + '\n' + "More items = more burden"); Main.debuff[mytype] = true; if (!Main.dedServ && EncumberedDebuff.IconTex1 == null) { EncumberedDebuff.IconTex1 = EncumbranceMod.Instance.GetTexture("Buffs/EncumberedDebuff_1"); EncumberedDebuff.IconTex2 = EncumbranceMod.Instance.GetTexture("Buffs/EncumberedDebuff_2"); EncumberedDebuff.IconTex3 = EncumbranceMod.Instance.GetTexture("Buffs/EncumberedDebuff_3"); EncumberedDebuff.IconTex4 = EncumbranceMod.Instance.GetTexture("Buffs/EncumberedDebuff_4"); if (!EncumberedDebuff.HasSetPromise) { EncumberedDebuff.HasSetPromise = true; CustomLoadHooks.AddHook(EncumbrancePlayer.PlayerMovementPromiseValidator, (whoAmI) => { Player plr = Main.player[whoAmI]; if (plr != null && plr.active && plr.HasBuff(mytype)) { EncumberedDebuff.ApplyMovementHinderance(plr); } return(true); }); } LoadHooks.AddModUnloadHook(() => { EncumberedDebuff.IconTex1 = null; EncumberedDebuff.IconTex2 = null; EncumberedDebuff.IconTex3 = null; EncumberedDebuff.IconTex4 = null; }); } }
//////////////// public override void Load(TagCompound tags) { //DataStore.Add( DebugHelpers.GetCurrentContext()+"_A", 1 ); var mymod = (ModHelpersMod)this.mod; if (tags.ContainsKey("world_id")) { this.ObsoleteId = tags.GetString("world_id"); } //mymod.UserHelpers.Load( mymod, tags ); mymod.ModLock.Load(tags); this.WorldLogic.LoadForWorld(tags); mymod.ModLock.PostLoad(this); //mymod.UserHelpers.OnWorldLoad( this ); CustomLoadHooks.TriggerHook(ModHelpersWorld.LoadValidator, ModHelpersWorld.MyValidatorKey); this.HasObsoleteId = true; //DataStore.Add( DebugHelpers.GetCurrentContext()+"_B", 1 ); }
public override TagCompound Save() { var tags = new TagCompound(); try { //PlayerData.SaveAll( this.player.whoAmI, tags ); CustomLoadHooks.TriggerHook( ModHelpersPlayer.SaveValidator, ModHelpersPlayer.MyValidatorKey, this.player.whoAmI ); this.Logic.Save(tags); } catch (Exception e) { if (!(e is ModHelpersException)) { throw new ModHelpersException(e.ToString()); } } return(tags); }
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); }); }
//////////////// public override void PostUpdateRunSpeeds() { if (this.player.dead) { return; } var mymod = (EncumbranceMod)this.mod; // Is sprinting? /*if( !player.mount.Active && player.velocity.Y == 0f && player.dashDelay >= 0 ) { * float runMin = PlayerMovementHelpers.MinimumRunSpeed( player ); * float acc = player.accRunSpeed + 0.1f; * float velX = player.velocity.X; * * if( ( player.controlRight && velX > runMin && velX < acc ) || * ( player.controlLeft && velX < -runMin && velX > -acc ) ) { * //Main.NewText("runMin:"+ runMin+ ",acc:"+ acc+ ",velX:"+ velX+",maxRunSpeed:"+ this.Player.maxRunSpeed); * this.DrainStaminaViaSprint( mymod, player ); * } * }*/ // Is dashing? if (!this.IsDashing) { if (this.player.dash != 0 && this.player.dashDelay == -1) { this.RunDashEffect(); this.IsDashing = true; } } else if (this.player.dashDelay != -1) { this.IsDashing = false; } // Is (attempting) jump? if (this.player.controlJump) { if (!this.IsJumping && !PlayerMovementHelpers.IsFlying(this.player)) { if (this.player.swimTime > 0) { this.RunSwimEffect(); } else { if (this.player.velocity.Y == 0 || this.player.sliding || this.player.jumpAgainBlizzard || this.player.jumpAgainCloud || this.player.jumpAgainFart || this.player.jumpAgainSandstorm) { this.RunJumpEffect(); } } this.IsJumping = true; } if (this.player.jump > 0 || PlayerMovementHelpers.IsFlying(this.player)) { if (this.player.swimTime > 0) { this.RunSwimHoldEffect(); } else { this.RunJumpHoldEffect(); } } } else if (this.IsJumping) { this.IsJumping = false; } CustomLoadHooks.TriggerHook(EncumbrancePlayer.PlayerMovementPromiseValidator, EncumbrancePlayer.PlayerMovementPromiseValidatorKey, this.player.whoAmI ); }
//////////////// 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 ) { } //} ); }