/// <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 data.</param> private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { //Override auto-click on hold for milk pail if (Config.PreventFailedHarvesting && GameExtensions.HoldingOverridableTool() && GameExtensions.IsClickableArea() && Game1.mouseClickPolling > 50) { Game1.mouseClickPolling = 50; } if (!Game1.player.UsingTool && AnimalBeingRanched != null) { AnimalBeingRanched = null; } }
private void ActionTriggered(EventArgs e) { var who = Game1.player; if (Config.PreventFailedHarvesting && GameExtensions.HoldingOverridableTool() && GameExtensions.IsClickableArea()) { if (e is EventArgsMouseStateChanged mouse) { Vector2 vector2 = (double)Game1.mouseCursorTransparency == 0.0 ? Game1.player.GetToolLocation(false) : new Vector2((float)(Game1.getOldMouseX() + @Game1.viewport.X), (float)(Game1.getOldMouseY() + Game1.viewport.Y)); if (Utility.withinRadiusOfPlayer((int)vector2.X, (int)vector2.Y, 1, Game1.player) && ((double)Math.Abs(vector2.X - (float)Game1.player.getStandingX()) >= (double)(Game1.tileSize / 2) || (double)Math.Abs(vector2.Y - (float)Game1.player.getStandingY()) >= (double)(Game1.tileSize / 2))) { if (who.CanMove && (double)Game1.mouseCursorTransparency != 0.0 && !Game1.isAnyGamePadButtonBeingHeld()) { who.Halt(); who.faceGeneralDirection(new Vector2((float)(int)vector2.X, (float)(int)vector2.Y), 0); } } OverrideRanching(Game1.currentLocation, (int)who.GetToolLocation().X, (int)who.GetToolLocation().Y, who, mouse.NewState, who.CurrentTool?.Name); } else if (e is EventArgsControllerButtonPressed) { OverrideRanching(Game1.currentLocation, (int)who.GetToolLocation().X, (int)who.GetToolLocation().Y, who , new GamePadState(Game1.oldPadState.ThumbSticks, Game1.oldPadState.Triggers, new GamePadButtons(Buttons.X), Game1.oldPadState.DPad) , who.CurrentTool?.Name); } } }
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> private void OnButtonPressed(object sender, ButtonPressedEventArgs e) { if (!Context.IsWorldReady || !Game1.currentLocation.IsFarm) { return; } if (e.Button.IsUseToolButton() && Config.PreventFailedHarvesting && GameExtensions.HoldingOverridableTool() && GameExtensions.IsClickableArea()) { Farmer who = Game1.player; if (e.Button == SButton.MouseLeft) { Vector2 pos = Game1.mouseCursorTransparency == 0.0 ? Game1.player.GetToolLocation() : new Vector2(Game1.getOldMouseX() + @Game1.viewport.X, Game1.getOldMouseY() + Game1.viewport.Y); if (Utility.withinRadiusOfPlayer((int)pos.X, (int)pos.Y, 1, Game1.player) && (Math.Abs(pos.X - Game1.player.getStandingX()) >= (double)(Game1.tileSize / 2) || Math.Abs(pos.Y - Game1.player.getStandingY()) >= (double)(Game1.tileSize / 2))) { if (who.CanMove && Game1.mouseCursorTransparency != 0.0 && !Game1.isAnyGamePadButtonBeingHeld()) { who.Halt(); who.faceGeneralDirection(new Vector2((int)pos.X, (int)pos.Y), 0); } } OverrideRanching(Game1.currentLocation, (int)who.GetToolLocation().X, (int)who.GetToolLocation().Y, who, e.Button, who.CurrentTool?.Name); } else { OverrideRanching(Game1.currentLocation, (int)who.GetToolLocation().X, (int)who.GetToolLocation().Y, who, e.Button, who.CurrentTool?.Name); } } }