private static bool Prefix(RefinementVM __instance, Hero currentCraftingHero) { if (__instance.CurrentSelectedAction != null) { ICraftingCampaignBehavior craftingBehavior = (ICraftingCampaignBehavior)Traverse.Create(__instance).Field("_craftingBehavior").GetValue(); var formula = __instance.CurrentSelectedAction.RefineFormula; var itemRoster = MobileParty.MainParty.ItemRoster; if (craftingBehavior != null) { if (Input.IsKeyDown(InputKey.LeftShift)) { if (Input.IsKeyDown(InputKey.LeftControl)) { while (craftingBehavior.GetHeroCraftingStamina(currentCraftingHero) >= Campaign.Current.Models.SmithingModel.GetEnergyCostForRefining(ref formula, currentCraftingHero) && HasEnoughCraftingMaterial(itemRoster, formula)) { craftingBehavior.DoRefinement(currentCraftingHero, __instance.CurrentSelectedAction.RefineFormula); } } else { for (int i = 0; i < 10 && craftingBehavior.GetHeroCraftingStamina(currentCraftingHero) >= Campaign.Current.Models.SmithingModel.GetEnergyCostForRefining(ref formula, currentCraftingHero) && HasEnoughCraftingMaterial(itemRoster, formula); i++) { craftingBehavior.DoRefinement(currentCraftingHero, __instance.CurrentSelectedAction.RefineFormula); } } } else { craftingBehavior.DoRefinement(currentCraftingHero, __instance.CurrentSelectedAction.RefineFormula); } } __instance.RefreshRefinementActionsList(currentCraftingHero); RefinementActionItemVM currentSelectedAction = __instance.CurrentSelectedAction; if (currentSelectedAction != null && !currentSelectedAction.IsEnabled) { currentSelectedAction = null; } } return(false); }
private static bool Prefix(SmeltingVM __instance, Hero currentCraftingHero) { if (Traverse.Create(__instance).Field("_currentSelectedItem").GetValue() != null && Traverse.Create(__instance).Field("_smithingBehavior").GetValue() != null) { ICraftingCampaignBehavior smithingBehavior = (ICraftingCampaignBehavior)Traverse.Create(__instance).Field("_smithingBehavior").GetValue(); var itemRoster = MobileParty.MainParty.ItemRoster; if (smithingBehavior != null) { if (Input.IsKeyDown(InputKey.LeftShift)) { var stackAmount = __instance.CurrentSelectedItem.NumOfItems; var charcoalAmount = itemRoster.GetItemNumber(DefaultItems.Charcoal); var energyCost = Campaign.Current.Models.SmithingModel.GetEnergyCostForSmelting(__instance.CurrentSelectedItem.Item, currentCraftingHero); var heroStamina = smithingBehavior.GetHeroCraftingStamina(currentCraftingHero); for (int i = 0; i < stackAmount && heroStamina >= energyCost && charcoalAmount >= 1; i++) { smithingBehavior.DoSmelting(currentCraftingHero, ((SmeltingItemVM)Traverse.Create(__instance).Field("_currentSelectedItem").GetValue()).Item); __instance.RefreshList(); charcoalAmount--; heroStamina -= energyCost; } } else { smithingBehavior.DoSmelting(currentCraftingHero, ((SmeltingItemVM)Traverse.Create(__instance).Field("_currentSelectedItem").GetValue()).Item); } } } __instance.RefreshList(); if (__instance.CurrentSelectedItem != null) { SmeltingItemVM newItem = __instance.SmeltableItemList.FirstOrDefault((SmeltingItemVM i) => i.Item == __instance.CurrentSelectedItem.Item) ?? __instance.SmeltableItemList.FirstOrDefault <SmeltingItemVM>(); Traverse.Create(__instance).Method("OnItemSelection", newItem).GetValue(); } Traverse.Create(__instance).Method("_updateYieldValuesAcion").GetValue(); return(false); }
static void Postfix(SmeltingVM __instance, Hero currentCraftingHero, ref SmeltingItemVM ____currentSelectedItem, ref ICraftingCampaignBehavior ____smithingBehavior) { if (repeating) { return; } if (____currentSelectedItem != null && ____smithingBehavior != null && Input.IsKeyDown(InputKey.LeftControl)) { repeating = true; int maxfailsafe = 100; while (maxfailsafe-- > 0 && ____currentSelectedItem != null && ____smithingBehavior != null) { __instance.SmeltSelectedItems(currentCraftingHero); } repeating = false; } }