private void MenuEvents_MenuChanged(object sender, EventArgsClickableMenuChanged e) { if (e.NewMenu is BobberBar) { Bobber = SBobberBar.ConstructFromBaseClass((BobberBar)e.NewMenu); } }
/********* ** Private methods *********/ /// <summary>Raised after a game menu is opened, closed, or replaced.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnMenuChanged(object sender, MenuChangedEventArgs e) { if (e.NewMenu is BobberBar menu) { this.Bobber = SBobberBar.ConstructFromBaseClass(menu); } }
public static SBobberBar ConstructFromBaseClass(BobberBar baseClass) { var b = new SBobberBar(0, 0, false, 0) { BaseBobberBar = baseClass }; return(b); }
/// <summary>Raised after the game state is updated (≈60 times per second).</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { // apply infinite bait/tackle if (Context.IsWorldReady && e.IsOneSecond && (this.Config.InfiniteBait || this.Config.InfiniteTackle)) { if (Game1.player.CurrentTool is FishingRod rod && rod.attachments?.Length > 0 && rod.attachments[0] != null) { if (this.Config.InfiniteBait) { rod.attachments[0].Stack = rod.attachments[0].maximumStackSize(); } if (this.Config.InfiniteTackle && rod.attachments?.Length > 1 && rod.attachments[1] != null) { rod.attachments[1].uses.Value = 0; } } } // apply fishing minigame changes if (Game1.activeClickableMenu is BobberBar && this.Bobber != null) { SBobberBar bobber = this.Bobber; //Begin fishing game if (!this.BeganFishingGame && this.UpdateIndex > 15) { //Do these things once per fishing minigame, 1/4 second after it updates bobber.difficulty *= this.Config.FishDifficultyMultiplier; bobber.difficulty += this.Config.FishDifficultyAdditive; if (this.Config.AlwaysFindTreasure) { bobber.treasure = true; } if (this.Config.InstantCatchFish) { if (bobber.treasure) { bobber.treasureCaught = true; } bobber.distanceFromCatching += 100; } if (this.Config.InstantCatchTreasure) { if (bobber.treasure || this.Config.AlwaysFindTreasure) { bobber.treasureCaught = true; } } if (this.Config.EasierFishing) { bobber.difficulty = Math.Max(15, Math.Max(bobber.difficulty, 60)); bobber.motionType = 2; } this.BeganFishingGame = true; } if (this.UpdateIndex < 20) { this.UpdateIndex++; } if (this.Config.AlwaysPerfect) { bobber.perfect = true; } if (!bobber.bobberInBar) { bobber.distanceFromCatching += this.Config.LossAdditive; } } else { //End fishing game this.BeganFishingGame = false; this.UpdateIndex = 0; } }
private void GameEvents_OnUpdateTick(object sender, EventArgs e) { if (Game1.activeClickableMenu is BobberBar && this.Bobber != null) { SBobberBar bobber = this.Bobber; //Begin fishing game if (!this.BeganFishingGame && this.UpdateIndex > 15) { //Do these things once per fishing minigame, 1/4 second after it updates bobber.difficulty *= this.Config.FishDifficultyMultiplier; bobber.difficulty += this.Config.FishDifficultyAdditive; if (this.Config.AlwaysFindTreasure) { bobber.treasure = true; } if (this.Config.InstantCatchFish) { if (bobber.treasure) { bobber.treasureCaught = true; } bobber.distanceFromCatching += 100; } if (this.Config.InstantCatchTreasure) { if (bobber.treasure || this.Config.AlwaysFindTreasure) { bobber.treasureCaught = true; } } if (this.Config.EasierFishing) { bobber.difficulty = Math.Max(15, Math.Max(bobber.difficulty, 60)); bobber.motionType = 2; } this.BeganFishingGame = true; } if (this.UpdateIndex < 20) { this.UpdateIndex++; } if (this.Config.AlwaysPerfect) { bobber.perfect = true; } if (!bobber.bobberInBar) { bobber.distanceFromCatching += this.Config.LossAdditive; } } else { //End fishing game this.BeganFishingGame = false; this.UpdateIndex = 0; } }