Skip to content

Commit db26211

Browse files
apply hotfix change
apply hotfix change to this mod.
1 parent 4748d30 commit db26211

3 files changed

Lines changed: 20 additions & 16 deletions

File tree

TLSmithingFasterMod/TLSmithingFasterCraftingCampaignBehaviorDoSmeltingPatch.cs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,36 @@ namespace TLSmithingFasterMod
1212
[HarmonyPatch(typeof(CraftingCampaignBehavior), "DoSmelting")]
1313
public class TLSmithingFasterCraftingCampaignBehaviorDoSmeltingPatch
1414
{
15-
public static void Postfix(ref CraftingCampaignBehavior __instance, Hero hero, ItemObject item)
15+
public static void Postfix(ref CraftingCampaignBehavior __instance, Hero hero, EquipmentElement equipmentElement)
1616
{
1717
ScreenBase topScreen = ScreenManager.TopScreen;
1818
if (topScreen != null && Input.IsKeyDown(InputKey.LeftShift) && !TLSmithingFasterOperationCounts.Flag)
1919
{
2020
TLSmithingFasterOperationCounts.Flag = true;
21-
int maxcounts = TLSmithingFasterOperationCounts.GetMaxCounts(ref __instance, hero, item);
21+
int maxcounts = TLSmithingFasterOperationCounts.GetMaxCounts(ref __instance, hero, equipmentElement);
2222
maxcounts = Math.Min(maxcounts, 4);
2323
IEnumerable<EquipmentElement> locks = Campaign.Current.GetCampaignBehavior<InventoryLockTracker>().GetLocks();
2424
ItemRoster itemRoster = MobileParty.MainParty.ItemRoster;
25+
ItemRosterElement[] ItemRosterElements = itemRoster.GetCopyOfAllElements();
2526
bool IsLocked = false;
26-
int max_item_count = itemRoster.Count;
27+
int max_item_count = ItemRosterElements.Length;
2728
for (int i = 0; i < max_item_count && maxcounts > 0; i++)
2829
{
2930
itemRoster = MobileParty.MainParty.ItemRoster;
31+
ItemRosterElements = itemRoster.GetCopyOfAllElements();
3032
foreach (EquipmentElement EquipmentElement in locks)
3133
{
32-
if (EquipmentElement.Item == itemRoster.GetItemAtIndex(i))
34+
if (EquipmentElement.IsEqualTo(ItemRosterElements[i].EquipmentElement))
3335
{
3436
IsLocked = true;
3537
break;
3638
}
3739
}
38-
int item_num = itemRoster.GetItemNumber(itemRoster.GetItemAtIndex(i));
40+
int item_num = ItemRosterElements[i].Amount;
3941
int j;
40-
for (j = 0; j < item_num && !IsLocked && itemRoster.GetItemAtIndex(i).IsCraftedWeapon; j++)
42+
for (j = 0; j < item_num && !IsLocked && ItemRosterElements[i].EquipmentElement.Item.IsCraftedWeapon; j++)
4143
{
42-
__instance.DoSmelting(hero, itemRoster.GetItemAtIndex(i));
44+
__instance.DoSmelting(hero, ItemRosterElements[i].EquipmentElement);
4345
maxcounts--;
4446
if (maxcounts <= 0)
4547
{
@@ -59,27 +61,29 @@ public static void Postfix(ref CraftingCampaignBehavior __instance, Hero hero, I
5961
if (topScreen != null && Input.IsKeyDown(InputKey.LeftControl) && !TLSmithingFasterOperationCounts.Flag)
6062
{
6163
TLSmithingFasterOperationCounts.Flag = true;
62-
int maxcounts = TLSmithingFasterOperationCounts.GetMaxCounts(ref __instance, hero, item);
64+
int maxcounts = TLSmithingFasterOperationCounts.GetMaxCounts(ref __instance, hero, equipmentElement);
6365
IEnumerable<EquipmentElement> locks = Campaign.Current.GetCampaignBehavior<InventoryLockTracker>().GetLocks();
6466
ItemRoster itemRoster = MobileParty.MainParty.ItemRoster;
67+
ItemRosterElement[] ItemRosterElements = itemRoster.GetCopyOfAllElements();
6568
bool IsLocked = false;
66-
int max_item_count = itemRoster.Count;
69+
int max_item_count = ItemRosterElements.Length;
6770
for (int i = 0; i < max_item_count && maxcounts > 0; i++)
6871
{
6972
itemRoster = MobileParty.MainParty.ItemRoster;
73+
ItemRosterElements = itemRoster.GetCopyOfAllElements();
7074
foreach (EquipmentElement EquipmentElement in locks)
7175
{
72-
if (EquipmentElement.Item == itemRoster.GetItemAtIndex(i))
76+
if (EquipmentElement.IsEqualTo(ItemRosterElements[i].EquipmentElement))
7377
{
7478
IsLocked = true;
7579
break;
7680
}
7781
}
78-
int item_num = itemRoster.GetItemNumber(itemRoster.GetItemAtIndex(i));
82+
int item_num = ItemRosterElements[i].Amount;
7983
int j;
80-
for (j = 0; j < item_num && !IsLocked && itemRoster.GetItemAtIndex(i).IsCraftedWeapon; j++)
84+
for (j = 0; j < item_num && !IsLocked && ItemRosterElements[i].EquipmentElement.Item.IsCraftedWeapon; j++)
8185
{
82-
__instance.DoSmelting(hero, itemRoster.GetItemAtIndex(i));
86+
__instance.DoSmelting(hero, ItemRosterElements[i].EquipmentElement);
8387
maxcounts--;
8488
if (maxcounts <= 0)
8589
{

TLSmithingFasterMod/TLSmithingFasterOperationCounts.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public static int GetMaxCounts(ref CraftingCampaignBehavior instance, Hero hero,
3131
}
3232
return result;
3333
}
34-
public static int GetMaxCounts(ref CraftingCampaignBehavior instance, Hero hero, ItemObject item)
34+
public static int GetMaxCounts(ref CraftingCampaignBehavior instance, Hero hero, EquipmentElement equipmentElement)
3535
{
3636
ItemRoster itemRoster = MobileParty.MainParty.ItemRoster;
37-
int energyCostForSmelting = Campaign.Current.Models.SmithingModel.GetEnergyCostForSmelting(item, hero);
37+
int energyCostForSmelting = Campaign.Current.Models.SmithingModel.GetEnergyCostForSmelting(equipmentElement.Item, hero);
3838
int result = instance.GetHeroCraftingStamina(hero) / energyCostForSmelting;
3939
string charcoal = "charcoal";
4040
int charcoal_num = 0;

TLSmithingFasterMod/TLSmithingFasterSubModule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ protected override void OnSubModuleLoad()
1515
protected override void OnBeforeInitialModuleScreenSetAsRoot()
1616
{
1717
base.OnBeforeInitialModuleScreenSetAsRoot();
18-
InformationManager.DisplayMessage(new InformationMessage("TL Smithing Faster Mod beta1.3.0.2 is successfully loaded. HarmonyLib 2.0.0.10"));
18+
InformationManager.DisplayMessage(new InformationMessage("TL Smithing Faster Mod beta1.3.0.3 is successfully loaded. HarmonyLib 2.0.0.10"));
1919
}
2020
}
2121
}

0 commit comments

Comments
 (0)