public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { if ((this.hoeDirt.Value.crop != null && !DataLoader.ModConfig.EnablePlacementOfCropsOutsideOutOfTheFarm && !location.IsFarm && location.IsOutdoors)) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:HoeDirt.cs.13919")); return(false); } bool result = base.placementAction(location, x, y, who); Vector2 placedPotLocation = new Vector2((float)(x / 64), (float)(y / 64)); if (location.objects[placedPotLocation] is IndoorPot pot) { if (this.hoeDirt.Value.crop != null) { pot.hoeDirt.Value.crop = this.hoeDirt.Value.crop; pot.hoeDirt.Value.fertilizer.Value = this.hoeDirt.Value.fertilizer.Value; TransplantOverrides.ShakeCrop(pot.hoeDirt.Value, placedPotLocation); } else if (this.bush.Value != null) { pot.bush.Value = TransplantOverrides.PrepareBushForPlacement(this.bush.Value, placedPotLocation); } TransplantOverrides.CleanHeldIndoorPot(); } return(result); }
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { if (!DataLoader.ModConfig.EnablePlacementOfCropsOutsideOutOfTheFarm && !Game1.player.currentLocation.IsFarm && Game1.player.currentLocation.IsOutdoors) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:HoeDirt.cs.13919")); return(false); } bool result = base.placementAction(location, x, y, who); if (this.hoeDirt.Value.crop != null) { Vector2 index1 = new Vector2((float)(x / 64), (float)(y / 64)); if (location.objects[index1] is IndoorPot pot) { pot.hoeDirt.Value.crop = this.hoeDirt.Value.crop; pot.hoeDirt.Value.fertilizer.Value = this.hoeDirt.Value.fertilizer.Value; TransplantOverrides.ShakeCrop(pot.hoeDirt.Value, index1); } } return(result); }