@@ -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 {
0 commit comments