public static bool PatchTapperAndMushroomQuality(ref StardewObject __instance, ref Farmer who, ref bool justCheckingForActivity) { try { if (!justCheckingForActivity && __instance != null && __instance.minutesUntilReady <= 0 && __instance.heldObject != null && __instance.heldObject.Value != null) { if (TapperAndMushroomQualityLogic.IsTapper(__instance)) { TapperAndMushroomQualityLogic.RewardTapperExp(mod); if (mod.Config.TapperQualityOptions <= 0 && mod.Config.TapperQualityOptions > 4) { __instance.heldObject.Value.quality.Value = 0; return(true); } TerrainFeature terrain; who.currentLocation.terrainFeatures.TryGetValue(__instance.TileLocation, out terrain); if (terrain != null && terrain is Tree tree) { __instance.heldObject.Value.quality.Value = TapperAndMushroomQualityLogic.DetermineTapperQuality(mod, who, __instance, tree); } else { __instance.heldObject.Value.quality.Value = 0; } return(true); } if (TapperAndMushroomQualityLogic.IsMushroomBox(__instance)) { TapperAndMushroomQualityLogic.RewardMushroomBoxExp(mod); if (!mod.Config.MushroomBoxQuality) { __instance.heldObject.Value.quality.Value = 0; } else { __instance.heldObject.Value.quality.Value = ForageFantasy.DetermineForageQuality(who); } return(true); } } return(true); } catch (Exception e) { mod.ErrorLog("There was an exception in a patch", e); return(true); } }
public static void TryAddItemToPlayerInventory_Post(ref StardewObject container, ref bool __result) { try { // I can't reduce the quality of a non successfully harvested box here, // because it doesn't get called if the method throws a inventoryfull exception if (__result && TapperAndMushroomQualityLogic.IsMushroomBox(container)) { if (mod.Config.AutomationHarvestsGrantXP) { TapperAndMushroomQualityLogic.RewardMushroomBoxExp(mod); } } } catch (Exception e) { mod.ErrorLog("There was an exception in a patch", e); } }
public static bool TryAddItemToPlayerInventory_Pre(ref Farmer player, ref Item item, ref StardewObject container) { try { if (TapperAndMushroomQualityLogic.IsMushroomBox(container)) { if (mod.Config.MushroomBoxQuality) { (item as StardewObject).Quality = ForageFantasy.DetermineForageQuality(player); } } return(true); } catch (Exception e) { mod.ErrorLog("There was an exception in a patch", e); return(true); } }
public static void ReduceQualityAfterHarvest(ref GameLocation location) { // reduce quality of non successfully harvested items and reset in general try { foreach (var item in location.Objects.Values) { if (TapperAndMushroomQualityLogic.IsMushroomBox(item)) { if (item.heldObject != null && item.heldObject.Value != null) { item.heldObject.Value.Quality = StardewObject.lowQuality; } } } } catch (Exception e) { mod.ErrorLog("There was an exception in a patch", e); } }