/** Check whether the used harvest method is allowed for the given harvest mode. * Method: 0 = plucking, 1 = scything. */ public static bool CanHarvest(HarvestModeEnum mode, int method) { // If mode is BOTH, then set mode depending on whether the scythe is currently equipped. if (mode == HarvestModeEnum.BOTH) { var t = Game1.player.CurrentTool; if (t is MeleeWeapon && (t as MeleeWeapon).isScythe(-1)) { mode = HarvestModeEnum.SCYTHE; } else { mode = HarvestModeEnum.HAND; } } // Determine if the currently used harvesting method is currently allowed. if (method == HARVEST_PLUCKING) { return(mode == HarvestModeEnum.HAND); } else { return(mode == HarvestModeEnum.SCYTHE); } }
/** Check whether the used harvest method is allowed for the given harvest mode. */ public static bool CanHarvest(HarvestModeEnum mode, int method) { var t = Game1.player.CurrentTool; if (IsScythe(t)) { if (mode == HarvestModeEnum.BOTH) { // If mode is BOTH, then set mode depending on whether the scythe is currently equipped. mode = HarvestModeEnum.SCYTHE; } else if (mode == HarvestModeEnum.GOLD && t.InitialParentTileIndex == MeleeWeapon.goldenScythe) { // If mode is GOLD, then set mode depending on whether the golden scythe is currently equipped. mode = HarvestModeEnum.SCYTHE; } } // Determine if the currently used harvesting method is currently allowed. if (method == HARVEST_PLUCKING) { return(mode != HarvestModeEnum.SCYTHE); } else { return(mode == HarvestModeEnum.SCYTHE); } }
/** Determine whether the given object can be harvested using the given method. * Assumes that isForage() returned true. */ public static bool CanHarvestObject(StardewValley.Object obj, int method) { // Get harvest settings from config ModConfig.HarvestModeClass config = getInstance().config.HarvestMode; HarvestModeEnum mode = config.Forage; return(CanHarvest(mode, method)); }
static string writeEnum(HarvestModeEnum val) { switch (val) { case HarvestModeEnum.HAND: return("Hand"); case HarvestModeEnum.SCYTHE: return("Scythe"); case HarvestModeEnum.BOTH: return("Both"); case HarvestModeEnum.GOLD: return("Gold"); default: throw new Exception("Invalid HarvestModeEnum value"); } }