private void doAction() { SFarmer Player = Game1.player; GameLocation location = Game1.currentLocation; Tool tool = Player.CurrentTool; Item item = Player.CurrentItem; ITool[] tools = this.Tools .Where(tools1 => tools1.IsEnabled(Player, tool, item, location)) .ToArray(); if (!tools.Any()) { return; } Vector2[] grid = this.GetGrid(Player.getTileLocation(), this.Config.ToolRadius).ToArray(); foreach (Vector2 tile in grid) { location.objects.TryGetValue(tile, out SObject tileObj); location.terrainFeatures.TryGetValue(tile, out TerrainFeature tileFeature); foreach (ITool tool1 in tools) { if (tool1.Apply(tile, tileObj, tileFeature, Player, tool, item, location)) { break; } } } }
private void doMine() { SFarmer Player = Game1.player; GameLocation location = Game1.currentLocation; Tool tool = Player.CurrentTool; Item item = Player.CurrentItem; Dictionary <Vector2, SObject> curObj = new Dictionary <Vector2, SObject>(); Dictionary <Vector2, TerrainFeature> curTerrain = new Dictionary <Vector2, TerrainFeature>(); ITool[] tools = this.Tools .Where(tools1 => tools1.IsEnabled(Player, tool, item, location)) .ToArray(); if (!tools.Any()) { return; } if (location.isFarm || location.name.Contains("Greenhouse") || location.name.Contains("FarmExpan")) { return; } Vector2[] grid = this.GetGrid(Player.getTileLocation(), 50).ToArray(); foreach (Vector2 tile in grid) { location.objects.TryGetValue(tile, out SObject tileObj); location.terrainFeatures.TryGetValue(tile, out TerrainFeature tileFeature); foreach (ITool tool1 in tools) { if (tool1.Apply(tile, tileObj, tileFeature, Player, tool, item, location)) { break; } } } }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param> /// <param name="farmer">The underlying in-game object.</param> public FarmerTarget(GameHelper gameHelper, SFarmer farmer) : base(gameHelper, TargetType.Farmer, farmer, farmer.getTileLocation()) { }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="farmer">The underlying in-game object.</param> public FarmerTarget(SFarmer farmer) : base(TargetType.Farmer, farmer, farmer.getTileLocation()) { }