public static void BobberBar(BobberBar __instance, ref float fishSize) { if (fishSize >= DataLoader.ModConfig.IridiumQualityFishMinimumSize) { if (Game1.player.CurrentTool is FishingRod fishingRod) { if (DataLoader.ModConfig.IridiumQualityFishOnlyWithIridiumQualityBait || DataLoader.ModConfig.IridiumQualityFishOnlyWithWildBait) { if (fishingRod.attachments[0] != null) { if (DataLoader.ModConfig.IridiumQualityFishOnlyWithIridiumQualityBait && fishingRod.attachments[0].Quality != 4) { return; } if (DataLoader.ModConfig.IridiumQualityFishOnlyWithWildBait && fishingRod.attachments[0].ParentSheetIndex != 774) { return; } } else { return; } } if (Game1.random.NextDouble() < fishSize / 2.0) { DataLoader.Helper.Reflection.GetField <int>(__instance, "fishQuality").SetValue(4); } } } }
private void DrawFishDisplay(IList <string> positions, BobberBar bar) { // call a function to determine the x and y coords DetermineCoordinates(positions, bar, out int x, out int y); // call a function to draw the box DrawAtCoordinates(x, y); }
private void DrawFishDisplay(IList <string> positions, BobberBar bar) { // call a function to determine the x and y coords DetermineCoordinates(positions, bar, out int x, out int y); // call a function to draw the box DrawAtCoordinates((int)(x * (Game1.options.zoomLevel / Game1.options.uiScale)), (int)(y * (Game1.options.zoomLevel / Game1.options.uiScale))); }
public static SBobberBar ConstructFromBaseClass(BobberBar baseClass) { var b = new SBobberBar(0, 0, false, 0); b.BaseBobberBar = baseClass; return(b); }
public static void AutoFishing(BobberBar bar) { AutoFishingCounter = (AutoFishingCounter + 1) % 3; if (AutoFishingCounter > 0) { return; } IReflectedField <float> bobberSpeed = Reflection.GetField <float>(bar, "bobberBarSpeed"); float barPos = Reflection.GetField <float>(bar, "bobberBarPos").GetValue(); int barHeight = Reflection.GetField <int>(bar, "bobberBarHeight").GetValue(); float fishPos = Reflection.GetField <float>(bar, "bobberPosition").GetValue(); float treasurePos = Reflection.GetField <float>(bar, "treasurePosition").GetValue(); float distanceFromCatching = Reflection.GetField <float>(bar, "distanceFromCatching").GetValue(); bool treasureCaught = Reflection.GetField <bool>(bar, "treasureCaught").GetValue(); bool treasure = Reflection.GetField <bool>(bar, "treasure").GetValue(); float treasureApeearTimer = Reflection.GetField <float>(bar, "treasureAppearTimer").GetValue(); float bobberBarSpeed = bobberSpeed.GetValue(); float top = barPos; if (treasure && treasureApeearTimer <= 0 && !treasureCaught) { if (!CatchingTreasure && distanceFromCatching > 0.7f) { CatchingTreasure = true; } if (CatchingTreasure && distanceFromCatching < 0.3f) { CatchingTreasure = false; } if (CatchingTreasure) { fishPos = treasurePos; } } if (fishPos > barPos + (barHeight / 2f)) { return; } float strength = (fishPos - (barPos + barHeight / 2f)) / 18f; float distance = fishPos - top; float threshold = Util.Cap(InstanceHolder.Config.CpuThresholdFishing, 0, 0.5f); if (distance < threshold * barHeight || distance > (1 - threshold) * barHeight) { bobberBarSpeed = strength; } bobberSpeed.SetValue(bobberBarSpeed); }
/// <summary> /// Assign the objects that will pull non-public Stardew data. The docs say this is an expensive operation /// and so should be cached and then the same objects are used to call GetValue and SetValue. /// </summary> /// <param name="bar">A reference to the Fishing window</param> private void LoadSVReflectionObjects(BobberBar bar) { log.Silly("Assigning reflected fields to class members."); svBobberBarHeight = helper.Reflection.GetField <int>(bar, "bobberBarHeight"); svBobberBarPos = helper.Reflection.GetField <float>(bar, "bobberBarPos"); svBobberBarSpeed = helper.Reflection.GetField <float>(bar, "bobberBarSpeed"); svDistanceFromCatching = helper.Reflection.GetField <float>(bar, "distanceFromCatching"); svBobberPosition = helper.Reflection.GetField <float>(bar, "bobberPosition"); svTreasurePosition = helper.Reflection.GetField <float>(bar, "treasurePosition"); svPerfect = helper.Reflection.GetField <bool>(bar, "perfect"); svTreasure = helper.Reflection.GetField <bool>(bar, "treasure"); svTreasureCaught = helper.Reflection.GetField <bool>(bar, "treasureCaught"); log.Silly("Finished processing reflected values"); }
private void OnFishingMiniGameStart(BobberBar bar) { bobberBar = bar; inFishingMiniGame = true; isCatching = true; fishPreviewFishId = 0; //Overide fish difficulty OverrideFishDifficult(); //Make treasure appear every time AlwayFindTreasure(); //Instantly catch fish when minigame start InstantCatchFish(); //Instantly catch treasure when treasure appear InstantCatchTreasure(); }
private void fishingExp(object sender, EventArgs args) { var ev = args as EventArgsClickableMenuClosed; if (!(ev.PriorMenu is BobberBar)) { return; } BobberBar fishing = ev.PriorMenu as BobberBar; float diff = ( float )Util.GetInstanceField(typeof(BobberBar), fishing, "difficulty"); bool perfect = ( bool )Util.GetInstanceField(typeof(BobberBar), fishing, "perfect"); bool treasure = ( bool )Util.GetInstanceField(typeof(BobberBar), fishing, "treasureCaught"); if (perfect) { //gainLuckExp((int)(diff / 7) + 1); } if (treasure) { gainLuckExp((int)(diff)); } }
/// <summary>Raised after the game state is updated (≈60 times per second).</summary> /// <param name="e">The event arguments.</param> /// <param name="reflection">Simplifies access to private game code.</param> /// <param name="input">An API for checking input state.</param> public void OnUpdateTicked(UpdateTickedEventArgs e, IReflectionHelper reflection, IInputHelper input) { if (Game1.player?.currentLocation != null) { Farmer player = Game1.player; // movement speed this.UpdateBuff(); // infinite health/stamina if (this.Config.InfiniteHealth) { player.health = player.maxHealth; } if (this.Config.InfiniteStamina) { player.stamina = player.MaxStamina; } // fishing cheats if (player.CurrentTool is FishingRod rod) { BobberBar bobberMenu = Game1.activeClickableMenu as BobberBar; // max cast power if (this.Config.ThrowBobberMax && rod.isTimingCast) { rod.castingPower = 1.01f; } // durable tackles if (this.Config.DurableTackles && rod.attachments[1] != null) { rod.attachments[1].uses.Value = 0; } // instant bite if (this.Config.InstantBite && rod.isFishing && !rod.hit && rod.timeUntilFishingBite > 0) { rod.timeUntilFishingBite = 0; } // always treasure if (this.Config.AlwaysTreasure && bobberMenu != null) { reflection.GetField <bool>(bobberMenu, "treasure").SetValue(true); } // instant catch if (this.Config.InstantCatch && bobberMenu != null) { reflection.GetField <float>(bobberMenu, "distanceFromCatching").SetValue(1); if (reflection.GetField <bool>(bobberMenu, "treasure").GetValue()) { reflection.GetField <bool>(bobberMenu, "treasureCaught").SetValue(true); } } } // one-hit break if (this.Config.OneHitBreak && player.UsingTool && (player.CurrentTool is Axe || player.CurrentTool is Pickaxe)) { Vector2 tile = new Vector2((int)player.GetToolLocation().X / Game1.tileSize, (int)player.GetToolLocation().Y / Game1.tileSize); if (player.CurrentTool is Pickaxe && player.currentLocation.objects.ContainsKey(tile)) { SObject obj = player.currentLocation.Objects[tile]; if (obj != null && obj.name == "Stone") { obj.MinutesUntilReady = 0; } } if (player.CurrentTool is Axe && player.currentLocation.terrainFeatures.ContainsKey(tile)) { TerrainFeature obj = player.currentLocation.terrainFeatures[tile]; if (obj is Tree tree && tree.health.Value > 1) { tree.health.Value = 1; } else if (obj is FruitTree fruitTree && fruitTree.health.Value > 1) { fruitTree.health.Value = 1; } } List <ResourceClump> resourceClumps = new List <ResourceClump>(); if (player.currentLocation is MineShaft mineShaft) { resourceClumps.AddRange(mineShaft.resourceClumps); } if (player.currentLocation is Farm farm) { resourceClumps.AddRange(farm.resourceClumps); } if (player.currentLocation is Forest forest) { resourceClumps.Add(forest.log); } if (player.currentLocation is Woods woods) { resourceClumps.AddRange(woods.stumps); } foreach (ResourceClump r in resourceClumps) { if (r == null) { continue; } if (r.getBoundingBox(r.tile.Value).Contains((int)player.GetToolLocation().X, (int)player.GetToolLocation().Y) && r.health.Value > 0) { r.health.Value = 0; } } } // infinite watering can if (this.Config.InfiniteWateringCan && player.CurrentTool is WateringCan can) { can.WaterLeft = can.waterCanMax; } // unlimited gifts if (this.Config.AlwaysGiveGift) { foreach (Friendship friendship in player.friendshipData.Values) { friendship.GiftsThisWeek = 0; friendship.GiftsToday = 0; } } // one-hit kill if (this.Config.OneHitKill) { foreach (Monster monster in player.currentLocation.characters.OfType <Monster>()) { if (monster.Health > 1) { monster.Health = 1; } } } // grow crops/trees if (this.ShouldGrowCrops || this.ShouldGrowTrees) { Vector2 playerTile = Game1.player.getTileLocation(); if (playerTile != this.LastGrowOrigin || e.IsMultipleOf(30)) { this.Grow(playerTile, growCrops: this.ShouldGrowCrops, growTrees: this.ShouldGrowTrees, radius: this.Config.GrowRadius); this.LastGrowOrigin = playerTile; } } }
/// <summary> /// Called when the Fishing menu is up and the game is ready to play. /// Do all the steps (that are configured) to catched the fish. /// </summary> private void PlayFishMinigame() { log.Silly("Algorithm to play the fishing game started"); BobberBar fishGame = Game1.activeClickableMenu as BobberBar; // Check if this is the first tick we've been in the BobberBar menu if (!inFishingMenu) { log.Trace("Fishing started, setting up environment"); LoadSVReflectionObjects(fishGame); inFishingMenu = true; } // Does the user even want the mod to fish? if (!config.catchFish) { log.Silly("Player does not want this to fish for them. =-("); return; } // Just set perfect first so it gets caught by boring fishing. if (config.alwaysPerfect) { log.Trace("Setting perfect flag to true"); svPerfect.SetValue(true); } // Are we being boring? if (config.boringFishing) { log.Silly("Boring fishing turned on, just catch the fish"); svDistanceFromCatching.SetValue(1.0F); return; } // Here, fBar is the green fishing bar, fish is the 'bobber' or eemmm.. fish. Top of the window // is 0 and y+ as you go down, so a negative velocity means bar is going up. Cache the values // so they're not constantly queried from the Reflected fields. log.Silly("Acquiring values from reflected fields"); int fBarHeight = svBobberBarHeight.GetValue(); float maxFBarPos = BobberBar.bobberBarTrackHeight - fBarHeight; float currentFBarPos = svBobberBarPos.GetValue(); float currentFbarHalfPos = currentFBarPos + (fBarHeight / 2); float currentFBarVelocity = svBobberBarSpeed.GetValue(); float fishPos = svBobberPosition.GetValue(); float distanceFromCatching = svDistanceFromCatching.GetValue(); float desiredPos = fishPos; bool treasureSpawn = svTreasure.GetValue(); bool caughtTreasure = svTreasureCaught.GetValue(); float treasurePos = svTreasurePosition.GetValue(); // Go for the treasure? if (treasureSpawn && treasurePos > 0 && !caughtTreasure) { if (distanceFromCatching > switchToTreasureThreshold && catchingFishState) { catchingFishState = false; } else if (distanceFromCatching < switchtoFishThreshold && !catchingFishState) { catchingFishState = true; } } else { // If we not catching treasure at all, always make sure we're going for the fish. catchingFishState = true; } log.Silly($"Going for the fish? {catchingFishState}"); desiredPos = catchingFishState ? fishPos : treasurePos; // Check velocity limits first if ((Math.Abs(currentFBarVelocity) > fBarTerminalVelocity) || (IsFishInsideBar(fBarHeight, currentFBarPos, desiredPos) && Math.Abs(currentFBarVelocity) > FBarTargetVelocity(Math.Abs(currentFbarHalfPos - desiredPos), fBarMaxVelocity, fBarTerminalVelocity, 0.01F, (fBarHeight / 2)))) { log.Silly("Fishing bar is travelling too fast; limiting rate"); if (currentFBarVelocity > 0.0) { IsButtonDownHack.simulateDown = true; } else { IsButtonDownHack.simulateDown = false; } } else if ((currentFBarPos > maxFBarPos - lowerLimitBrakePoint) && currentFBarVelocity > lowerLimitMaxVelocity) { // The bar can bounce on the bottom, but don't stop it too early in case it's trying to // catch the fish. But try to minimize the speed before the bounce. log.Silly("Fishing bar is about to bounce on the bottom; limiting rate"); IsButtonDownHack.simulateDown = true; } else if (desiredPos >= currentFbarHalfPos) { log.Silly($"Pos >= half, turning off. Des: {desiredPos} half: {currentFbarHalfPos}"); IsButtonDownHack.simulateDown = false; } else { log.Silly($"Pos < half, turning on. Des: {desiredPos} half: {currentFbarHalfPos}"); IsButtonDownHack.simulateDown = true; } }
private void DetermineCoordinates(IList <string> positions, BobberBar bar, out int x, out int y) { // define offset values int xLeftOffset = -32; int xCenterOffset = 32; int xRightOffset = 80; int yTopOffset = -32; int yUpperOffset = 0; int yLowerOffset = -40; int yBottomOffset = -12; // determine x and y positions foreach (string position in positions) { // set the correct display coordinates from position values in order of priority switch (position) { case "Top": x = bar.xPositionOnScreen + (bar.width / 2) - (boxwidth / 2) + xCenterOffset; y = bar.yPositionOnScreen - boxheight + yTopOffset; break; case "UpperRight": x = bar.xPositionOnScreen + bar.width + xRightOffset; y = bar.yPositionOnScreen + yUpperOffset; break; case "UpperLeft": x = bar.xPositionOnScreen - boxwidth + xLeftOffset; y = bar.yPositionOnScreen + yUpperOffset; break; case "Bottom": x = bar.xPositionOnScreen + (bar.width / 2) - (boxwidth / 2) + xCenterOffset; y = bar.yPositionOnScreen + bar.height + yBottomOffset; break; case "LowerRight": x = bar.xPositionOnScreen + bar.width + xRightOffset; y = bar.yPositionOnScreen + bar.height - boxheight + yLowerOffset; break; case "LowerLeft": x = bar.xPositionOnScreen - boxwidth + xLeftOffset; y = bar.yPositionOnScreen + bar.height - boxheight + yLowerOffset; break; default: // default to UpperRight position x = bar.xPositionOnScreen + bar.width + xRightOffset; y = bar.yPositionOnScreen + yUpperOffset; //this.Monitor.Log($"Invalid position {position} listed in displayOrder.", LogLevel.Debug); break; } // if the box display is in bounds, break the loop. Otherwise proceed to alternative display position(s). if (x >= 0 && y >= 0 && x + boxwidth <= Game1.viewport.Width && y + boxheight <= Game1.viewport.Height) { return; } } // if no suitable location found in foreach, default to UpperRight position x = bar.xPositionOnScreen + bar.width + xRightOffset; y = bar.yPositionOnScreen + yUpperOffset; //this.Monitor.Log($"No suitable coordinate position found in displayOrder.", LogLevel.Debug); }
private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e) { BobberBar fishBarMenu = e.NewMenu as BobberBar; FishingRod fishTool = Game1.player.CurrentTool as FishingRod; if (fishBarMenu == null || fishTool == null || Settings.Active.DisableMod) { return; } _fishMenu = fishBarMenu; int attachmentValue = fishTool.attachments[0] == null ? -1 : fishTool.attachments[0].parentSheetIndex; bool caughtDouble = Settings.Active.AlwaysCatchDoubleFish || (bossFish && attachmentValue == 774 && Game1.random.NextDouble() < 0.25 + Game1.player.DailyLuck / 2.0); if (Settings.Active.OverrideFishType >= 0) { whichFish = Settings.Active.OverrideFishType; } if (Settings.Active.OverrideFishQuality >= 0) { fishQuality = Settings.Active.OverrideFishQuality; } if (Settings.Active.AlwaysPerfectCatch) { perfect = true; } if (Settings.Active.AlwaysCatchTreasure) { treasure = true; treasureCaught = true; } if (Settings.Active.DistanceFromCatchingOverride >= 0) { distanceFromCatching = Settings.Active.DistanceFromCatchingOverride; } if (Settings.Active.OverrideBarHeight >= 0) { bobberBarHeight = Settings.Active.OverrideBarHeight; } if (Settings.Active.ReelFishCycling) { if (_circularFishList == null) { LoadFishList(); } whichFish = _circularFishList.ElementAt(0); _circularFishList.Rotate(1); } if (Settings.Active.AutoReelFish) { // Emulate BobberBar.update() when fadeOut = true if (EnableDebugOutput) { Monitor.Log(string.Format("Auto-reeling fish with id: {0}. : {1},", whichFish, GetFishNameFromId(whichFish))); } fadeOut = true; handledFishResult = true; distanceFromCatching = 1; fishTool.pullFishFromWater(whichFish, fishSize, fishQuality, (int)difficulty, treasure, perfect, fromFishPond, caughtDouble); Game1.exitActiveMenu(); } Game1.setRichPresence("location", (object)Game1.currentLocation.Name); }
public static void Serialize_BobberBar(dynamic menu, BobberBar bb, Point cursorPosition) { menu.menuType = "fishingMenu"; }
public static void DrawFishingInfoBox(SpriteBatch batch, BobberBar bar, SpriteFont font) { int width = 0, height = 120; float scale = 1.0f; int whichFish = Reflection.GetField <int>(bar, "whichFish").GetValue(); int fishSize = Reflection.GetField <int>(bar, "fishSize").GetValue(); int fishQuality = Reflection.GetField <int>(bar, "fishQuality").GetValue(); bool treasure = Reflection.GetField <bool>(bar, "treasure").GetValue(); bool treasureCaught = Reflection.GetField <bool>(bar, "treasureCaught").GetValue(); float treasureAppearTimer = Reflection.GetField <float>(bar, "treasureAppearTimer").GetValue() / 1000; bool perfect = Reflection.GetField <bool>(bar, "perfect").GetValue(); if (perfect) { if (fishQuality >= 2) { fishQuality = 4; } else if (fishQuality >= 1) { fishQuality = 3; } } Object fish = new Object(whichFish, 1, quality: fishQuality); int salePrice = fish.sellToStorePrice(); if (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.en) { scale = 0.7f; } string speciesText = Util.TryFormat(Translation.Get("fishinfo.species").ToString(), fish.DisplayName); string sizeText = Util.TryFormat(Translation.Get("fishinfo.size").ToString(), GetFinalSize(fishSize)); string qualityText1 = Translation.Get("fishinfo.quality").ToString(); string qualityText2 = Translation.Get(GetKeyForQuality(fishQuality)).ToString(); string incomingText = Util.TryFormat(Translation.Get("fishinfo.treasure.incoming").ToString(), treasureAppearTimer); string appearedText = Translation.Get("fishinfo.treasure.appear").ToString(); string caughtText = Translation.Get("fishinfo.treasure.caught").ToString(); string priceText = Util.TryFormat(Translation.Get("fishinfo.price"), salePrice); { Vector2 size = font.MeasureString(speciesText) * scale; if (size.X > width) { width = (int)size.X; } height += (int)size.Y; size = font.MeasureString(sizeText) * scale; if (size.X > width) { width = (int)size.X; } height += (int)size.Y; Vector2 temp = font.MeasureString(qualityText1); Vector2 temp2 = font.MeasureString(qualityText2); size = new Vector2(temp.X + temp2.X, Math.Max(temp.Y, temp2.Y)); if (size.X > width) { width = (int)size.X; } height += (int)size.Y; size = font.MeasureString(priceText) * scale; if (size.X > width) { width = (int)size.X; } height += (int)size.Y; } if (treasure) { if (treasureAppearTimer > 0) { Vector2 size = font.MeasureString(incomingText) * scale; if (size.X > width) { width = (int)size.X; } height += (int)size.Y; } else { if (!treasureCaught) { Vector2 size = font.MeasureString(appearedText) * scale; if (size.X > width) { width = (int)size.X; } height += (int)size.Y; } else { Vector2 size = font.MeasureString(caughtText) * scale; if (size.X > width) { width = (int)size.X; } height += (int)size.Y; } } } width += 64; int x = bar.xPositionOnScreen + bar.width + 96; if (x + width > Game1.viewport.Width) { x = bar.xPositionOnScreen - width - 96; } int y = (int)Util.Cap(bar.yPositionOnScreen, 0, Game1.viewport.Height - height); Util.DrawWindow(x, y, width, height); fish.drawInMenu(batch, new Vector2(x + width / 2 - 32, y + 16), 1.0f, 1.0f, 0.9f, StackDrawType.Hide); Vector2 vec2 = new Vector2(x + 32, y + 96); Util.DrawString(batch, font, ref vec2, speciesText, Color.Black, scale); Util.DrawString(batch, font, ref vec2, sizeText, Color.Black, scale); Util.DrawString(batch, font, ref vec2, qualityText1, Color.Black, scale, true); Util.DrawString(batch, font, ref vec2, qualityText2, GetColorForQuality(fishQuality), scale); vec2.X = x + 32; Util.DrawString(batch, font, ref vec2, priceText, Color.Black, scale); if (treasure) { if (!treasureCaught) { if (treasureAppearTimer > 0f) { Util.DrawString(batch, font, ref vec2, incomingText, Color.Red, scale); } else { Util.DrawString(batch, font, ref vec2, appearedText, Color.LightGoldenrodYellow, scale); } } else { Util.DrawString(batch, font, ref vec2, caughtText, Color.ForestGreen, scale); } } }
private void UpdateTick(object sender, UpdateTickedEventArgs e) { if (Game1.player == null) { return; } if (Game1.player.CurrentTool is FishingRod) { FishingRod currentTool = Game1.player.CurrentTool as FishingRod; if (Config.fastBite && currentTool.timeUntilFishingBite > 0) { currentTool.timeUntilFishingBite /= 2; // 快速咬钩 } if (Config.autoHit && currentTool.isNibbling && !currentTool.isReeling && !currentTool.hit && !currentTool.pullingOutOfWater && !currentTool.fishCaught) { currentTool.DoFunction(Game1.player.currentLocation, 1, 1, 1, Game1.player); // 自动咬钩 } if (Config.maxCastPower) { currentTool.castingPower = 1; } } if (Game1.activeClickableMenu is BobberBar) // 自动小游戏 { BobberBar bar = Game1.activeClickableMenu as BobberBar; float barPos = Helper.Reflection.GetField <float>(bar, "bobberBarPos").GetValue(); float barHeight = Helper.Reflection.GetField <int>(bar, "bobberBarHeight").GetValue(); float fishPos = Helper.Reflection.GetField <float>(bar, "bobberPosition").GetValue(); float treasurePos = Helper.Reflection.GetField <float>(bar, "treasurePosition").GetValue(); float distanceFromCatching = Helper.Reflection.GetField <float>(bar, "distanceFromCatching").GetValue(); bool treasureCaught = Helper.Reflection.GetField <bool>(bar, "treasureCaught").GetValue(); bool hasTreasure = Helper.Reflection.GetField <bool>(bar, "treasure").GetValue(); float treasureScale = Helper.Reflection.GetField <float>(bar, "treasureScale").GetValue(); float bobberBarSpeed = Helper.Reflection.GetField <float>(bar, "bobberBarSpeed").GetValue(); float barPosMax = 568 - barHeight; float min = barPos + barHeight / 4, max = barPos + barHeight / 1.5f; if (Config.catchTreasure && hasTreasure && !treasureCaught && (distanceFromCatching > 0.75 || catching)) { catching = true; fishPos = treasurePos; } if (catching && distanceFromCatching < 0.15) { catching = false; fishPos = Helper.Reflection.GetField <float>(bar, "bobberPosition").GetValue(); } if (fishPos < min) { bobberBarSpeed -= 0.35f + (min - fishPos) / 20; Helper.Reflection.GetField <float>(bar, "bobberBarSpeed").SetValue(bobberBarSpeed); } else if (fishPos > max) { bobberBarSpeed += 0.35f + (fishPos - max) / 20; Helper.Reflection.GetField <float>(bar, "bobberBarSpeed").SetValue(bobberBarSpeed); } else { float target = 0.1f; if (bobberBarSpeed > target) { bobberBarSpeed -= 0.1f + (bobberBarSpeed - target) / 25; if (barPos + bobberBarSpeed > barPosMax) { bobberBarSpeed /= 2; // 减小触底反弹 } if (bobberBarSpeed < target) { bobberBarSpeed = target; } } else { bobberBarSpeed += 0.1f + (target - bobberBarSpeed) / 25; if (barPos + bobberBarSpeed < 0) { bobberBarSpeed /= 2; // 减小触顶反弹 } if (bobberBarSpeed > target) { bobberBarSpeed = target; } } Helper.Reflection.GetField <float>(bar, "bobberBarSpeed").SetValue(bobberBarSpeed); } } else { catching = false; } }
public BobberBarUpdateEvent(BobberBar bobberBar, GameTime time) { BobberBar = bobberBar; Time = time; }
public static void onUpdate() { if (Game1.player != null) { Farmer plr = Game1.player; //Log.Info(Game1.currentLocation.name + ": " + plr.getTileLocation().X + ", " + plr.getTileLocation().Y); if (CJBCheatsMenu.config.increasedMovement && plr.running) { plr.addedSpeed = CJBCheatsMenu.config.moveSpeed; } else if (!CJBCheatsMenu.config.increasedMovement && plr.addedSpeed == CJBCheatsMenu.config.moveSpeed) { plr.addedSpeed = 0; } if (plr.controller != null) { plr.addedSpeed = 0; } if (Game1.CurrentEvent == null) { plr.movementDirections.Clear(); } if (CJBCheatsMenu.config.infiniteHealth) { plr.health = plr.maxHealth; } if (CJBCheatsMenu.config.infiniteStamina) { plr.stamina = plr.maxStamina; } if (Game1.activeClickableMenu == null && plr.CurrentTool is FishingRod) { FishingRod tool = (FishingRod)plr.CurrentTool; if (CJBCheatsMenu.config.throwBobberMax) { tool.castingPower = 1.01F; } if (CJBCheatsMenu.config.instantBite && tool.isFishing) { if (tool.timeUntilFishingBite > 0) { tool.timeUntilFishingBite = 0; } } if (CJBCheatsMenu.config.durableTackles && tool.attachments[1] != null) { tool.attachments[1].scale.Y = 1; } } if (CJBCheatsMenu.config.oneHitBreak && plr.usingTool && (plr.CurrentTool is Axe || plr.CurrentTool is Pickaxe)) { int x = (int)plr.GetToolLocation().X / Game1.tileSize; int y = (int)plr.GetToolLocation().Y / Game1.tileSize; Vector2 index = new Vector2(x, y); if (plr.CurrentTool is Pickaxe && plr.currentLocation.objects.ContainsKey(index)) { StardewValley.Object o = plr.currentLocation.Objects[index]; if (o != null && o.name.Equals("Stone")) { o.minutesUntilReady = 0; } } if (plr.CurrentTool is Axe && plr.currentLocation.terrainFeatures.ContainsKey(index)) { TerrainFeature o = plr.currentLocation.terrainFeatures[index]; if (o != null && o is Tree) { Tree t = (Tree)o; if (t.health > 1) { t.health = 1; } } } List <ResourceClump> rl = new List <ResourceClump>(); if (plr.currentLocation is MineShaft) { rl.AddRange(((MineShaft)plr.currentLocation).resourceClumps); } if (plr.currentLocation is Farm) { rl.AddRange(((Farm)plr.currentLocation).resourceClumps); } if (plr.currentLocation is Forest) { rl.Add(((Forest)plr.currentLocation).log); } if (plr.currentLocation is Woods) { rl.AddRange(((Woods)plr.currentLocation).stumps); } foreach (ResourceClump r in rl) { if (r == null) { continue; } if (r.getBoundingBox(r.tile).Contains((int)plr.GetToolLocation().X, (int)plr.GetToolLocation().Y) && r.health > 0) { r.health = 0; } } } if (CJBCheatsMenu.config.infiniteWateringCan && plr.CurrentTool is WateringCan) { WateringCan tool = (WateringCan)plr.CurrentTool; typeof(WateringCan).GetField("waterLeft", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(tool, tool.waterCanMax); } if (CJBCheatsMenu.config.alwaysGiveGift) { foreach (KeyValuePair <string, int[]> fr in plr.friendships) { if (fr.Value != null) { fr.Value[1] = 0; fr.Value[3] = 0; /*if (fr.Value[0] < 500) * fr.Value[0] = 500;*/ } } } } if (CJBCheatsMenu.config.maxDailyLuck) { Game1.dailyLuck = 0.115d; } if (CJBCheatsMenu.config.oneHitKill && Game1.currentLocation != null) { if (Game1.currentLocation.characters != null) { foreach (NPC npc in Game1.currentLocation.characters) { if (npc is Monster) { ((Monster)npc).health = 1; } } } } if ((CJBCheatsMenu.config.instantCatch || CJBCheatsMenu.config.alwaysTreasure) && Game1.activeClickableMenu is BobberBar) { BobberBar menu = (BobberBar)Game1.activeClickableMenu; if (CJBCheatsMenu.config.alwaysTreasure) { typeof(BobberBar).GetField("treasure", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(menu, true); } if (CJBCheatsMenu.config.instantCatch) { typeof(BobberBar).GetField("distanceFromCatching", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(menu, 1F); } if ((bool)typeof(BobberBar).GetField("treasure", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(menu)) { typeof(BobberBar).GetField("treasureCaught", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(menu, true); } } if (CJBCheatsMenu.config.infiniteHay) { Farm farm = (Farm)Game1.getLocationFromName("Farm"); if (farm != null) { farm.piecesOfHay = Utility.numSilos() * 240; } } }