/// <summary> /// Checks if there's a choppable object at the tile associated with this node. /// </summary> /// <param name="gameLocation">The <see cref="GameLocation"/> instance.</param> /// <returns> /// Returns true if there's something that can be chopped at this node's tile. Returns /// false otherwise. /// </returns> public bool ConstainsChoppable() { GameLocation gameLocation = this.graph.GameLocation; gameLocation.terrainFeatures.TryGetValue(new Vector2(this.X, this.Y), out TerrainFeature terrainFeature); if (terrainFeature is Tree || terrainFeature is FruitTree || (terrainFeature is Bush bush && bush.IsDestroyable( gameLocation, this.X, this.Y))) { return(true); } int tileLocationX = this.X * Game1.tileSize; int tileLocationY = this.Y * Game1.tileSize; foreach (LargeTerrainFeature largeTerrainFeature in gameLocation.largeTerrainFeatures) { if (largeTerrainFeature is Bush largeBush && largeBush.getRenderBounds(new Vector2(largeBush.tilePosition.X, largeBush.tilePosition.Y)) .Contains(tileLocationX, tileLocationY) && largeBush.IsDestroyable(gameLocation, this.X, this.Y)) { return(true); } } return((gameLocation is Forest { log : { } } forest&& forest.log.getBoundingBox(forest.log.tile) .Contains(tileLocationX, tileLocationY)) || gameLocation.IsStumpAt(this.X, this.Y)); }
public static bool IsMatureTreeStumpOrBoulderAt(this GameLocation gameLocation, Point tile) { gameLocation.terrainFeatures.TryGetValue(new Vector2(tile.X, tile.Y), out TerrainFeature terrainFeature); if (terrainFeature is Tree || terrainFeature is FruitTree || (terrainFeature is Bush bush && bush.IsDestroyable(gameLocation, tile))) { return(true); } foreach (LargeTerrainFeature largeTerrainFeature in gameLocation.largeTerrainFeatures) { if (largeTerrainFeature is Bush bush2 && bush2.getRenderBounds(new Vector2(bush2.tilePosition.X, bush2.tilePosition.Y)).Contains( tile.X * Game1.tileSize, tile.Y * Game1.tileSize) && bush2.IsDestroyable(gameLocation, tile)) { return(true); } } return(gameLocation.IsStumpAt(tile.X, tile.Y) || gameLocation.IsBoulderAt(tile.X, tile.Y)); }