//////////////// 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 OnFinishPlayerEnterWorldForAny() { CustomLoadHooks.TriggerHook(RewardsPlayer.EnterWorldValidator, RewardsPlayer.MyValidatorKey); LoadHooks.AddWorldUnloadOnceHook(() => { CustomLoadHooks.ClearHook(RewardsPlayer.EnterWorldValidator, RewardsPlayer.MyValidatorKey); }); }
internal void PostOnEnterWorld() { CustomLoadHooks.TriggerHook(LicensesPlayer.EnterWorldValidator, LicensesPlayer.MyValidatorKey); LoadHooks.AddWorldUnloadOnceHook(() => { CustomLoadHooks.ClearHook(LicensesPlayer.EnterWorldValidator, LicensesPlayer.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); }
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 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); }
//////////////// 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 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); }
//////////////// 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 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 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 ) { } //} ); }