/// <summary> /// Override to lift the pot back when an empty spot on the tool bar is selected. /// </summary> /// <param name="__result"></param> /// <returns></returns> public static bool PressUseToolButton(ref bool __result) { if (Game1.fadeToBlack) { return(false); } Game1.player.toolPower = 0; Game1.player.toolHold = 0; if (Game1.player.CurrentTool == null && Game1.player.ActiveObject == null) { Vector2 key = key = Game1.currentCursorTile; if (!Game1.currentLocation.Objects.ContainsKey(key) || !(Game1.currentLocation.Objects[key] is IndoorPot) || !Utility.tileWithinRadiusOfPlayer((int)key.X, (int)key.Y, 1, Game1.player)) { key = Game1.player.GetToolLocation(false) / 64f; key.X = (float)(int)key.X; key.Y = (float)(int)key.Y; } if (Game1.currentLocation.Objects.ContainsKey(key)) { Object @object = Game1.currentLocation.Objects[key]; if (@object is IndoorPot pot) { pot.performRemoveAction(pot.TileLocation, Game1.currentLocation); Game1.currentLocation.Objects.Remove(pot.TileLocation); HoeDirt potHoeDirt = pot.hoeDirt.Value; if (potHoeDirt.crop != null) { CurrentHeldIndoorPot = new HeldIndoorPot(pot.TileLocation); RegularPotObject = new Object(Vector2.Zero, 62, false); HoeDirt holdenHoeDirt = CurrentHeldIndoorPot.hoeDirt.Value; holdenHoeDirt.crop = potHoeDirt.crop; holdenHoeDirt.fertilizer.Value = potHoeDirt.fertilizer.Value; ShakeCrop(holdenHoeDirt, pot.TileLocation); Game1.player.Stamina -= ((float)DataLoader.ModConfig.CropTransplantEnergyCost - (float)Game1.player.FarmingLevel * DataLoader.ModConfig.CropTransplantEnergyCost / 20f); Game1.player.ActiveObject = CurrentHeldIndoorPot; GameEvents.UpdateTick += TickUpdate; } else { Game1.player.ActiveObject = new Object(Vector2.Zero, 62, false); } __result = true; return(false); } } } return(true); }
/// <summary> /// Override to lift the pot back when an empty spot on the tool bar is selected. /// </summary> /// <param name="__result"></param> /// <returns></returns> public static bool PressUseToolButton(ref bool __result) { if (Game1.fadeToBlack) { return(false); } Game1.player.toolPower = 0; Game1.player.toolHold = 0; if (Game1.player.CurrentTool == null && Game1.player.ActiveObject == null) { Vector2 key = key = Game1.currentCursorTile; if (!Game1.currentLocation.Objects.ContainsKey(key) || !(Game1.currentLocation.Objects[key] is IndoorPot) || (!Utility.tileWithinRadiusOfPlayer((int)key.X, (int)key.Y, 1, Game1.player) && !DataLoader.ModConfig.EnableUnlimitedRangeToTransplant)) { key = Game1.player.GetToolLocation(false) / 64f; key.X = (float)(int)key.X; key.Y = (float)(int)key.Y; } if (Game1.currentLocation.Objects.ContainsKey(key)) { Object @object = Game1.currentLocation.Objects[key]; if (@object is IndoorPot pot) { pot.performRemoveAction(pot.TileLocation, Game1.currentLocation); Game1.currentLocation.Objects.Remove(pot.TileLocation); HoeDirt potHoeDirt = pot.hoeDirt.Value; if (potHoeDirt.crop != null) { CurrentHeldIndoorPot = new HeldIndoorPot(pot.TileLocation); HoeDirt holdenHoeDirt = CurrentHeldIndoorPot.hoeDirt.Value; holdenHoeDirt.crop = potHoeDirt.crop; holdenHoeDirt.fertilizer.Value = potHoeDirt.fertilizer.Value; TransplantController.ShakeCrop(holdenHoeDirt, pot.TileLocation); Game1.player.Stamina -= ((float)DataLoader.ModConfig.CropTransplantEnergyCost - (float)Game1.player.FarmingLevel * DataLoader.ModConfig.CropTransplantEnergyCost / 20f); Game1.player.ActiveObject = CurrentHeldIndoorPot; Events.GameLoop.UpdateTicked += OnUpdateTicked; } else if (pot.bush.Value is Bush bush) { CurrentHeldIndoorPot = new HeldIndoorPot(pot.TileLocation); CurrentHeldIndoorPot.bush.Value = bush; Bush holdenBush = CurrentHeldIndoorPot.bush.Value; TransplantController.ShakeBush(holdenBush); Game1.player.Stamina -= ((float)DataLoader.ModConfig.CropTransplantEnergyCost - (float)Game1.player.FarmingLevel * DataLoader.ModConfig.CropTransplantEnergyCost / 20f); Game1.player.ActiveObject = CurrentHeldIndoorPot; Events.GameLoop.UpdateTicked += OnUpdateTicked; } else { Game1.player.ActiveObject = (Object)RegularPotObject.getOne(); } __result = true; return(false); } } } return(true); }