public static bool CheckForAction_Prefix(Object __instance, Farmer who, bool justCheckingForActivity, ref bool __result) { try { if (SkipNextCheckForAction) { SkipNextCheckForAction = false; return(false); } if (justCheckingForActivity) { CFAData = null; } else { CFAData = new CheckForActionData(who, __instance); //MachineAugmentorsMod.ModInstance.Monitor.Log(string.Format("Prefix: {0} ({1})", CFAData.PreviousHeldObject.DisplayName, CFAData.PreviousHeldObject.Stack), LogLevel.Info); } return(true); } catch (Exception ex) { MachineAugmentorsMod.ModInstance.Monitor.Log(string.Format("Unhandled Error in {0}:\n{1}", nameof(CheckForAction_Prefix), ex), LogLevel.Error); PODIData = null; return(true); } }
public static void OnProductsCollected(CheckForActionData CFAData, int AugmentorQuantity) { #if LEGACYCODE if (MachineInfo.TryGetMachineInfo(CFAData.Machine, out MachineInfo Info)) { if (!Info.AttachableAugmentors.Contains(AugmentorType.Duplication) || AugmentorQuantity <= 0 || Info.RequiresInput || CFAData.Machine.readyForHarvest) { return; } bool Success = SpawnDuplicate(AugmentorQuantity, CFAData.CurrentMinutesUntilReady, Info.RequiresInput, out double Chance); if (Success) { if (CFAData.Machine.getOne() is Object Duplicate) { Duplicate.Stack = 1; int SpawnDirection = Randomizer.Next(4); Game1.createItemDebris(Duplicate, Game1.player.getStandingPosition(), SpawnDirection, null, -1); } } MachineAugmentorsMod.LogTrace(AugmentorType.Duplication, AugmentorQuantity, CFAData.Machine, Info.RequiresInput, CFAData.Machine.TileLocation, "CreateDuplicate", 0, Chance, Convert.ToInt32(Success), Chance); } #endif }
public static void OnProductsCollected(CheckForActionData CFAData, int AugmentorQuantity) { //MachineInfo Info = MachineInfo.GetMachineInfo(CFAData.Machine); //if (!AugmentableMachineTypes.Contains(Info.Type) || AugmentorQuantity <= 0 || Info.RequiresInput || CFAData.CurrentHeldObject == null) // return; // Intentionally left blank since there are no inputs to multiply by during an OnProductsCollected // And I think it'd be too overpowered to allow using ProductionAugmentors on machines that don't require inputs, since then // you'd receive a big boost to output with no penalty to balance it out. }
internal void OnProductsCollected(CheckForActionData CFAData) { if (!CFAData.IsLocalPlayer) { return; } if (CFAData.CurrentHeldObject != null) { // This point of the code should be reached when collecting from a machine that does not require inputs // such as when collecting from a Bee Hive / Crystalarium / Tapper, a new product is automatically placed back into the machine and the MinutesUntilReady gets reset if (TryFindAugmentedTile(CFAData.Machine, CFAData.Machine.TileLocation, out AugmentedTile AT)) { foreach (KeyValuePair <AugmentorType, int> KVP in GetOrderedEnumerable(AT.Quantities)) { AugmentorType Type = KVP.Key; int AttachedQuantity = KVP.Value; if (AttachedQuantity > 0) { if (Type == AugmentorType.Output) { OutputAugmentor.OnProductsCollected(CFAData, AttachedQuantity); } else if (Type == AugmentorType.Speed) { SpeedAugmentor.OnProductsCollected(CFAData, AttachedQuantity); } else if (Type == AugmentorType.Efficiency) { EfficiencyAugmentor.OnProductsCollected(CFAData, AttachedQuantity); } else if (Type == AugmentorType.Quality) { QualityAugmentor.OnProductsCollected(CFAData, AttachedQuantity); } else if (Type == AugmentorType.Production) { ProductionAugmentor.OnProductsCollected(CFAData, AttachedQuantity); } else if (Type == AugmentorType.Duplication) { DuplicationAugmentor.OnProductsCollected(CFAData, AttachedQuantity); } else { throw new NotImplementedException(string.Format("Unrecognized AugmentorType: {0}", Type.ToString())); } } } } } }
public static void OnProductsCollected(CheckForActionData CFAData, int AugmentorQuantity) { if (MachineInfo.TryGetMachineInfo(CFAData.Machine, out MachineInfo Info)) { if (!Info.AttachableAugmentors.Contains(AugmentorType.Production) || AugmentorQuantity <= 0 || Info.RequiresInput || CFAData.CurrentHeldObject == null) { return; } // Modify the output int PreviousOutputStack = CFAData.CurrentHeldObjectQuantity; int NewOutputStack = ComputeNewValue(AugmentorQuantity, double.MaxValue, PreviousOutputStack, Info.RequiresInput, out double OutputEffect, out double DesiredNewOutputValue); CFAData.CurrentHeldObject.Stack = NewOutputStack; MachineAugmentorsMod.LogTrace(AugmentorType.Production, AugmentorQuantity, CFAData.Machine, Info.RequiresInput, CFAData.Machine.TileLocation, "HeldObject.Stack", PreviousOutputStack, DesiredNewOutputValue, NewOutputStack, OutputEffect); } }
public static void OnProductsCollected(CheckForActionData CFAData, int AugmentorQuantity) { #if LEGACYCODE if (MachineInfo.TryGetMachineInfo(CFAData.Machine, out MachineInfo Info)) { if (!Info.AttachableAugmentors.Contains(AugmentorType.Output) || Info.RequiresInput || CFAData.CurrentHeldObject == null) { return; } int PreviousStack = CFAData.CurrentHeldObjectQuantity; int NewStack = ComputeNewValue(AugmentorQuantity, PreviousStack, Info.RequiresInput, out double Effect, out double DesiredNewValue); CFAData.CurrentHeldObject.Stack = NewStack; MachineAugmentorsMod.LogTrace(AugmentorType.Output, AugmentorQuantity, CFAData.Machine, Info.RequiresInput, CFAData.Machine.TileLocation, "HeldObject.Stack", PreviousStack, DesiredNewValue, NewStack, Effect); } #endif }
public static void OnProductsCollected(CheckForActionData CFAData, int AugmentorQuantity) { #if LEGACYCODE if (MachineInfo.TryGetMachineInfo(CFAData.Machine, out MachineInfo Info)) { if (!Info.AttachableAugmentors.Contains(AugmentorType.Speed) || AugmentorQuantity <= 0 || Info.RequiresInput || CFAData.Machine.readyForHarvest.Value) { return; } int PreviousMinutes = CFAData.CurrentMinutesUntilReady; int NewMinutes = ComputeNewValue(AugmentorQuantity, PreviousMinutes, Info.RequiresInput, out double Effect, out double DesiredNewValue); CFAData.Machine.MinutesUntilReady = NewMinutes; if (NewMinutes <= 0) { CFAData.Machine.readyForHarvest.Value = true; } MachineAugmentorsMod.LogTrace(AugmentorType.Speed, AugmentorQuantity, CFAData.Machine, Info.RequiresInput, CFAData.Machine.TileLocation, "HeldObject.MinutesUntilReady", PreviousMinutes, DesiredNewValue, NewMinutes, Effect); } #endif }
public static void OnProductsCollected(CheckForActionData CFAData, int AugmentorQuantity) { // Intentionally left blank since there are no inputs to refund during an OnProductsCollected. }