public bool PerformAction(JunimoAbility ability, Guid id, Vector2 pos, JunimoHarvester junimo) { switch (ability) { case JunimoAbility.FertilizeCrops: return(UseItemAbility(id, pos, SObject.fertilizerCategory, Fertilize)); case JunimoAbility.PlantCrops: return(UseItemAbility(id, pos, SObject.SeedsCategory, Plant)); case JunimoAbility.HarvestForageCrops: return(HarvestForageCrop(id, pos, junimo)); case JunimoAbility.ClearDeadCrops: return(ClearDeadCrops(pos)); } return(false); }
public static bool Prefix(JunimoHarvester __instance) { Vector2 pos = __instance.getTileLocation(); var harvestTimer = Util.Reflection.GetField <int>(__instance, "harvestTimer"); // avoid flowers, etc (todo: move) if (Util.ShouldAvoidHarvesting(pos)) { harvestTimer.SetValue(0); __instance.jumpWithoutSound(); __instance.pathfindToNewCrop(); return(false); } int time = Util.Config.JunimoImprovements.WorkFaster ? 300 : 998; Guid id = Util.GetHutIdFromJunimo(__instance); JunimoAbility junimoAbility = Util.Abilities.IdentifyJunimoAbility(pos, id); // Use the update() harvesting if (junimoAbility == JunimoAbility.HarvestCrops) { time = 2000; } else if (junimoAbility != JunimoAbility.None) { if (!Util.Abilities.PerformAction(junimoAbility, id, pos, __instance)) { // didn't succeed, move on time = 0; } } else { __instance.pokeToHarvest(); } harvestTimer.SetValue(time); return(false); }