Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HarmonyPatch(typeof(AutomataMachineMenuCtr))]
- [HarmonyPatch("StartAutomata")]
- public static class AutomataStartHook
- {
- public static bool Prefix(AutomataMachineMenuCtr __instance, CompoundItem ___curItem, AutomataMachineData ___machine, bool ___isWorktable)
- {
- func(__instance, ___curItem, ___machine, ___isWorktable);
- return false;
- }
- private static void func(AutomataMachineMenuCtr __instance, CompoundItem curItem, AutomataMachineData machine, bool isWorktable)
- {
- Module<AudioModule>.Self.PlayEffect2D(68, false, true, false);
- if (!Module<CompoundManager>.Self.CheckMatEnough(curItem, OperateType.Compound, 1))
- {
- UIUtils.ShowTips(0, TextMgr.GetStr(100402, -1), 2f, false, null);
- return;
- }
- if (machine.Data.fuelId != 0 && machine.Data.MaxFuel > 0 && machine.lastFuel_F <= 0f && machine.Data.plugType != 0 && !machine.PowerMachineWorking)
- {
- UIUtils.ShowTips(0, TextMgr.GetStr(201377, -1), 2f, false, null);
- return;
- }
- int num = Module<CompoundManager>.Self.GetCompoundCount(curItem, OperateType.Compound);
- int itemCount = machine.GetItemCount(curItem.itemId, 0);
- num = ((num <= machine.Data.itemMaxCount - itemCount) ? num : (machine.Data.itemMaxCount - itemCount));
- if (num <= 0 || Module<AutomataMgr>.Self.CheckListMax(machine.machineId, curItem.itemId, 0))
- {
- UIUtils.ShowTips(0, TextMgr.GetStr(100500, -1), 2f, false, null);
- return;
- }
- float totalTime = __instance.GetTotalTime(curItem, machine);
- string text = curItem.Name;
- if (isWorktable)
- {
- float num2 = Module<FeatureModule>.Self.ModifyFloat(FeatureType.WorkbenchMaterialCut, new object[]
- {
- 0f
- });
- if (num2 > 0f)
- {
- text = text + "\n" + string.Format(TextMgr.GetStr(101343, -1), (int)(num2 * 100f));
- }
- }
- //////////
- else
- {
- float num2 = Module<FeatureModule>.Self.ModifyFloat(Mod.MACHINE_CRAFTING_FEATURE, new object[]
- {
- 0f
- });
- if (num2 > 0f)
- {
- text = text + "\n" + string.Format(TextMgr.GetStr(101343, -1), (int)(num2 * 100f));
- }
- }
- var meth = __instance.GetType().GetMethod("StartAutomataResult", BindingFlags.NonPublic | BindingFlags.Instance);
- Action<int> action = (Action<int>)Delegate.CreateDelegate(__instance.GetType(), __instance, meth);
- //////////
- /*
- UIUtils.ShowNumberSelectMinMax(this.curItem.itemId, 0, Mathf.Max(num, 0), 1, TextMgr.GetStr(100401, -1), new Action<int>(this.StartAutomataResult), delegate
- {
- }, true, (int)totalTime, text);*/
- UIUtils.ShowNumberSelectMinMax(curItem.itemId, 0, Mathf.Max(num, 0), 1, TextMgr.GetStr(100401, -1), action, delegate
- {
- }, true, (int)totalTime, text);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement