internal void Reset(Item item) { ProducerRuleController.ClearProduction(_machine, Location); if (ProducerController.GetProducerConfig(_machine.Name) is ProducerConfig producerConfig) { if (producerConfig.NoInputStartMode != null || producerConfig.IncrementStatsOnOutput.Count > 0) { producerConfig.IncrementStats(item); if (producerConfig.NoInputStartMode == NoInputStartMode.Placement) { if (ProducerController.GetProducerItem(_machine.Name, null) is ProducerRule producerRule) { try { if (producerConfig.CheckLocationCondition(Location) && producerConfig.CheckSeasonCondition()) { ProducerRuleController.ProduceOutput(producerRule, _machine, (i, q) => true, null, Location, producerConfig); } } catch (RestrictionException) { /*No action needed*/ } } } } } }
[HarmonyPriority(Priority.First + 1)] //Just before ProducerFrameworkMod. Can't use HarmonyBefore attribute, that wasn't working for some reason public static bool DayUpdate_Prefix(SObject __instance, GameLocation location) { if (__instance == null || string.IsNullOrEmpty(__instance.GetMassProducerKey())) { return(true); } MassProductionMachineDefinition mpm = ModEntry.GetMPMMachine(__instance.name, __instance.GetMassProducerKey()); if (mpm == null) { return(true); } if (__instance.bigCraftable.Value) { if (ProducerController.GetProducerConfig(__instance.Name) is ProducerConfig producerConfig) { if (producerConfig != null) { if (ProducerController.GetProducerItem(__instance.Name, null) is ProducerRule producerRule) { if (!producerConfig.CheckSeasonCondition() || !producerConfig.CheckLocationCondition(location)) { ProducerRuleController.ClearProduction(__instance, location); return(false); } else if (producerConfig.NoInputStartMode != null) { if (producerConfig.NoInputStartMode == NoInputStartMode.DayUpdate || producerConfig.NoInputStartMode == NoInputStartMode.Placement) { if (__instance.heldObject.Value == null) { try { Farmer who = Game1.getFarmer((long)__instance.owner); PFMCompatability.ProduceOutput(producerRule, mpm.Settings, __instance, (i, q) => who.hasItemInInventory(i, q), who, who.currentLocation, producerConfig); } catch (RestrictionException) { //Does not show the restriction error since the machine is auto-starting. } } } return(false); } } } } } return(true); }