/// <summary>Apply the tool to the given tile.</summary> /// <param name="tile">The tile to modify.</param> /// <param name="tileObj">The object on the tile.</param> /// <param name="tileFeature">The feature on the tile.</param> /// <param name="player">The current player.</param> /// <param name="tool">The tool selected by the player (if any).</param> /// <param name="item">The item selected by the player (if any).</param> /// <param name="location">The current location.</param> public override bool Apply(Vector2 tile, SObject?tileObj, TerrainFeature?tileFeature, Farmer player, Tool?tool, Item?item, GameLocation location) { tool = tool.AssertNotNull(); // clear dead crops if (this.Config.ClearDeadCrops && this.TryClearDeadCrop(location, tile, tileFeature, player)) { return(true); } // break mine containers if (this.Config.BreakMineContainers && this.TryBreakContainer(tile, tileObj, tool, location)) { return(true); } // harvest grass if (this.Config.HarvestGrass && this.TryHarvestGrass(tileFeature as Grass, location, tile)) { return(true); } // attack monsters if (this.Config.AttackMonsters && this.UseWeaponOnTile((MeleeWeapon)tool, tile, player, location)) { return(false); } return(false); }
/// <summary>Apply the tool to the given tile.</summary> /// <param name="tile">The tile to modify.</param> /// <param name="tileObj">The object on the tile.</param> /// <param name="tileFeature">The feature on the tile.</param> /// <param name="player">The current player.</param> /// <param name="tool">The tool selected by the player (if any).</param> /// <param name="item">The item selected by the player (if any).</param> /// <param name="location">The current location.</param> public override bool Apply(Vector2 tile, SObject?tileObj, TerrainFeature?tileFeature, Farmer player, Tool?tool, Item?item, GameLocation location) { tool = tool.AssertNotNull(); this.Reflection.GetField <bool>(tool, "canPlaySound").SetValue(false); return(this.UseToolOnTile(tool, tile, player, location)); }
/// <summary>Apply the tool to the given tile.</summary> /// <param name="tile">The tile to modify.</param> /// <param name="tileObj">The object on the tile.</param> /// <param name="tileFeature">The feature on the tile.</param> /// <param name="player">The current player.</param> /// <param name="tool">The tool selected by the player (if any).</param> /// <param name="item">The item selected by the player (if any).</param> /// <param name="location">The current location.</param> public override bool Apply(Vector2 tile, SObject?tileObj, TerrainFeature?tileFeature, Farmer player, Tool?tool, Item?item, GameLocation location) { tool = tool.AssertNotNull(); // clear weeds if (this.Config.ClearWeeds && this.IsWeed(tileObj)) { return(this.UseToolOnTile(tool, tile, player, location)); } // collect artifact spots if (this.Config.DigArtifactSpots && tileObj?.ParentSheetIndex == HoeAttachment.ArtifactSpotItemID) { return(this.UseToolOnTile(tool, tile, player, location)); } // harvest ginger if (this.Config.HarvestGinger && tileFeature is HoeDirt dirt && dirt.crop?.whichForageCrop.Value == Crop.forageCrop_ginger && dirt.crop.hitWithHoe((int)tile.X, (int)tile.Y, location, dirt)) { dirt.destroyCrop(tile, showAnimation: false, location); return(true); } // till plain dirt if (this.Config.TillDirt && tileFeature == null && tileObj == null && this.TryStartCooldown(tile.ToString(), this.TillDirtDelay)) { return(this.UseToolOnTile(tool, tile, player, location)); } return(false); }
/// <summary>Apply the tool to the given tile.</summary> /// <param name="tile">The tile to modify.</param> /// <param name="tileObj">The object on the tile.</param> /// <param name="tileFeature">The feature on the tile.</param> /// <param name="player">The current player.</param> /// <param name="tool">The tool selected by the player (if any).</param> /// <param name="item">The item selected by the player (if any).</param> /// <param name="location">The current location.</param> public override bool Apply(Vector2 tile, SObject?tileObj, TerrainFeature?tileFeature, Farmer player, Tool?tool, Item?item, GameLocation location) { // apply melee weapon if (tool is MeleeWeapon weapon) { return(this.UseWeaponOnTile(weapon, tile, player, location)); } // apply tool if (tool != null && this.CustomNames.Contains(tool.Name)) { return(this.UseToolOnTile(tool, tile, player, location)); } // apply item if (item is { Stack : > 0 } && this.CustomNames.Contains(item.Name))
/// <summary>Apply the tool to the given tile.</summary> /// <param name="tile">The tile to modify.</param> /// <param name="tileObj">The object on the tile.</param> /// <param name="tileFeature">The feature on the tile.</param> /// <param name="player">The current player.</param> /// <param name="tool">The tool selected by the player (if any).</param> /// <param name="item">The item selected by the player (if any).</param> /// <param name="location">The current location.</param> public override bool Apply(Vector2 tile, SObject?tileObj, TerrainFeature?tileFeature, Farmer player, Tool?tool, Item?item, GameLocation location) { tool = tool.AssertNotNull(); if (this.TryStartCooldown(tile.ToString(), this.AnimalCheckDelay)) { FarmAnimal?animal = this.GetBestHarvestableFarmAnimal(tool, location, tile); if (animal != null) { Vector2 useAt = this.GetToolPixelPosition(tile); this.Reflection.GetField <FarmAnimal>(tool, "animal").SetValue(animal); tool.DoFunction(location, (int)useAt.X, (int)useAt.Y, 0, player); return(true); } } return(false); }
/// <summary>Apply the tool to the given tile.</summary> /// <param name="tile">The tile to modify.</param> /// <param name="tileObj">The object on the tile.</param> /// <param name="tileFeature">The feature on the tile.</param> /// <param name="player">The current player.</param> /// <param name="tool">The tool selected by the player (if any).</param> /// <param name="item">The item selected by the player (if any).</param> /// <param name="location">The current location.</param> public override bool Apply(Vector2 tile, SObject?tileObj, TerrainFeature?tileFeature, Farmer player, Tool?tool, Item?item, GameLocation location) { tool = tool.AssertNotNull(); // clear debris if (this.Config.ClearDebris && (this.IsTwig(tileObj) || this.IsWeed(tileObj))) { return(this.UseToolOnTile(tool, tile, player, location)); } // cut terrain features switch (tileFeature) { // cut non-fruit tree case Tree tree: return(this.ShouldCut(tree, tile, location) && this.UseToolOnTile(tool, tile, player, location)); // cut fruit tree case FruitTree tree: return(this.ShouldCut(tree) && this.UseToolOnTile(tool, tile, player, location)); // cut bushes case Bush bush: return(this.ShouldCut(bush) && this.UseToolOnTile(tool, tile, player, location)); // clear crops case HoeDirt { crop: not null } dirt: if (this.Config.ClearDeadCrops && dirt.crop.dead.Value) { return(this.UseToolOnTile(tool, tile, player, location)); } if (this.Config.ClearLiveCrops && !dirt.crop.dead.Value) { return(this.UseToolOnTile(tool, tile, player, location)); } break; } // cut resource stumps if (this.Config.ClearDebris || this.Config.CutGiantCrops) { if (this.TryGetResourceClumpCoveringTile(location, tile, player, out ResourceClump? clump, out Func <Tool, bool>?applyTool)) { // giant crops if (this.Config.CutGiantCrops && clump is GiantCrop) { applyTool(tool); return(true); } // big stumps and fallen logs // This needs to check if the axe upgrade level is high enough first, to avoid spamming // 'need to upgrade your tool' messages. Based on ResourceClump.performToolAction. if (this.Config.ClearDebris && this.ResourceUpgradeLevelsNeeded.ContainsKey(clump.parentSheetIndex.Value) && tool.UpgradeLevel >= this.ResourceUpgradeLevelsNeeded[clump.parentSheetIndex.Value]) { applyTool(tool); return(true); } } } // cut bushes in large terrain features if (this.Config.CutBushes) { foreach (Bush bush in location.largeTerrainFeatures.OfType <Bush>().Where(p => p.tilePosition.Value == tile)) { if (this.ShouldCut(bush) && this.UseToolOnTile(tool, tile, player, location)) { return(true); } } } return(false); }
/// <summary>Apply the tool to the given tile.</summary> /// <param name="tile">The tile to modify.</param> /// <param name="tileObj">The object on the tile.</param> /// <param name="tileFeature">The feature on the tile.</param> /// <param name="player">The current player.</param> /// <param name="tool">The tool selected by the player (if any).</param> /// <param name="item">The item selected by the player (if any).</param> /// <param name="location">The current location.</param> public override bool Apply(Vector2 tile, SObject?tileObj, TerrainFeature?tileFeature, Farmer player, Tool?tool, Item?item, GameLocation location) { tool = tool.AssertNotNull(); // break stones if (this.Config.ClearDebris && tileObj?.Name == "Stone") { return(this.UseToolOnTile(tool, tile, player, location)); } // break flooring & paths if (this.Config.ClearFlooring && tileFeature is Flooring) { return(this.UseToolOnTile(tool, tile, player, location)); } // break objects if (this.Config.ClearObjects && tileObj != null) { return(this.UseToolOnTile(tool, tile, player, location)); } // break mine containers if (this.Config.BreakMineContainers && this.TryBreakContainer(tile, tileObj, tool, location)) { return(true); } // clear weeds if (this.Config.ClearWeeds && this.IsWeed(tileObj)) { return(this.UseToolOnTile(tool, tile, player, location)); } // handle dirt if (tileFeature is HoeDirt dirt && tileObj is null) { // clear tilled dirt if (this.Config.ClearDirt && dirt.crop == null) { return(this.UseToolOnTile(tool, tile, player, location)); } // clear dead crops if (this.Config.ClearDeadCrops && dirt.crop != null && dirt.crop.dead.Value) { return(this.UseToolOnTile(tool, tile, player, location)); } } // clear boulders / meteorites // This needs to check if the axe upgrade level is high enough first, to avoid spamming // 'need to upgrade your tool' messages. Based on ResourceClump.performToolAction. if (this.Config.ClearBouldersAndMeteorites) { if (this.CanBreakBoulderAt(location, tile, player, tool, out Func <Tool, bool>?applyTool)) { applyTool(tool); return(true); } } // harvest spawned mine objects if (this.Config.HarvestMineSpawns && location is MineShaft && tileObj?.IsSpawnedObject == true && this.CheckTileAction(location, tile, player)) { this.CancelAnimation(player, FarmerSprite.harvestItemDown, FarmerSprite.harvestItemLeft, FarmerSprite.harvestItemRight, FarmerSprite.harvestItemUp); return(true); } return(false); }