From 71c846acc5d6d8585977244fe9516ea2c277be69 Mon Sep 17 00:00:00 2001 From: Date: Wed, 27 Sep 2017 19:06:41 -0700 Subject: [PATCH] Implemente correct interaction range with planter boxes. --- GeneralMods/AdditionalCropsFramework/PlanterBox.cs | 7 +++++-- GeneralMods/StardustCore/Utilities.cs | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/GeneralMods/AdditionalCropsFramework/PlanterBox.cs b/GeneralMods/AdditionalCropsFramework/PlanterBox.cs index e9f8f448..5ab9d3ab 100644 --- a/GeneralMods/AdditionalCropsFramework/PlanterBox.cs +++ b/GeneralMods/AdditionalCropsFramework/PlanterBox.cs @@ -421,9 +421,11 @@ namespace AdditionalCropsFramework public override bool clicked(StardewValley.Farmer who) { - if (StardustCore.Utilities.isWithinRange(2, this.tileLocation) == false) return false; - + int range = 2; + if (StardustCore.Utilities.isWithinRange(range, this.tileLocation) == false) return false; + if (StardustCore.Utilities.isWithinDirectionRange(Game1.player.FacingDirection, range, this.tileLocation)) + { if (Game1.player.CurrentItem != null) { if (Game1.player.getToolFromName(Game1.player.CurrentItem.Name) is StardewValley.Tools.WateringCan) @@ -456,6 +458,7 @@ namespace AdditionalCropsFramework } } } + } diff --git a/GeneralMods/StardustCore/Utilities.cs b/GeneralMods/StardustCore/Utilities.cs index effc423b..781cddcd 100644 --- a/GeneralMods/StardustCore/Utilities.cs +++ b/GeneralMods/StardustCore/Utilities.cs @@ -737,6 +737,20 @@ namespace StardustCore return true; } + public static bool isWithinDirectionRange(int direction,int range, Vector2 positionToCheck) + { + Vector2 v = Game1.player.getTileLocation(); + if (direction==3 && (v.X >= positionToCheck.X - range)) return true; //face left + if (direction==1 && (v.X <= positionToCheck.X + range)) return true; //face right + if (direction==0 && (v.Y <= positionToCheck.Y + range)) return true; //face up + if (direction==2 && (v.Y >= positionToCheck.Y - range)) return true; //face down + + return true; + } + + + + public static void drawGreenPlus() { try