BepInEx / HarmonyX

Harmony built on top of MonoMod.RuntimeDetours with additional features
MIT License
329 stars 42 forks source link

Pass-through transpiler messes up leave labels in inner `MoveNext()` with `try/finally` block #82

Closed Neoshrimp closed 1 month ago

Neoshrimp commented 10 months ago

Pay attention to IL_0129, the leave instruction at the end of the Try block. Compared to IL when only Prefix is applied the operand is changed completely and points at the wrong label.

The transpiler returns instructions as they were and prefix patch method is empty. Decompiled method code for reference.

IL with transpiler applied:

[Info   :  HarmonyX] Patching virtual bool LBoL.Presentation.UI.Panels.BattleManaPanel+<ViewConsumeMana>d__54::MoveNext() with 0 prefixes, 0 postfixes, 1 transpilers, 0 finalizers
1 transpilers:
* static System.Collections.Generic.IEnumerable<HarmonyLib.CodeInstruction> LBoLEntitySideloader.GameFixes+ViewConsumeMana_ErrorMessage_Patch::Transpiler(System.Collections.Generic.IEnumerable<HarmonyLib.CodeInstruction> instructions)

[Info   :  HarmonyX] Running ILHook manipulator on virtual bool LBoL.Presentation.UI.Panels.BattleManaPanel+<ViewConsumeMana>d__54::MoveNext()
[Info   :  HarmonyX] Transpiling virtual bool LBoL.Presentation.UI.Panels.BattleManaPanel+<ViewConsumeMana>d__54::MoveNext()
[Info   :  HarmonyX] Running transpiler static System.Collections.Generic.IEnumerable<HarmonyLib.CodeInstruction> LBoLEntitySideloader.GameFixes+ViewConsumeMana_ErrorMessage_Patch::Transpiler(System.Collections.Generic.IEnumerable<HarmonyLib.CodeInstruction> instructions)
[Debug  :  HarmonyX] Generated patch (System.Boolean DMD<LBoL.Presentation.UI.Panels.BattleManaPanel+<ViewConsumeMana>d__54::MoveNext>?1612689876::LBoL.Presentation.UI.Panels.BattleManaPanel+<ViewConsumeMana>d__54::MoveNext(LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54)):
.locals init (
    System.Int32 V_0
    LBoL.Presentation.UI.Panels.BattleManaPanel V_1
    System.Single V_2
    LBoL.Presentation.UI.Panels.PlayBoard V_3
    LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets V_4
    System.Collections.Generic.IEnumerator`1<LBoL.Presentation.UI.Widgets.BattleManaWidget> V_5
    LBoL.Presentation.UI.Widgets.BattleManaWidget V_6
    UnityEngine.Vector3 V_7
    LBoL.Core.Cards.Card V_8
    LBoL.Presentation.UI.ExtraWidgets.HandCard V_9
    LBoL.Base.ManaGroup V_10
)
IL_0000: ldarg.0
IL_0001: ldfld System.Int32 LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::<>1__state
IL_0006: stloc.0
IL_0007: ldarg.0
IL_0008: ldfld LBoL.Presentation.UI.Panels.BattleManaPanel LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::<>4__this
IL_000d: stloc.1
IL_000e: ldloc.0
IL_000f: brfalse IL_001d
IL_0014: ldloc.0
IL_0015: ldc.i4.1
IL_0016: beq IL_01e2
IL_001b: ldc.i4.0
IL_001c: ret
IL_001d: ldarg.0
IL_001e: ldc.i4.m1
IL_001f: stfld System.Int32 LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::<>1__state
IL_0024: ldc.r4 0
IL_0029: stloc.2
IL_002a: call TPanel LBoL.Presentation.UI.UiManager::GetPanel<LBoL.Presentation.UI.Panels.PlayBoard>()
IL_002f: stloc.3
IL_0030: ldloc.1
IL_0031: ldfld System.Collections.Generic.List`1<LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets> LBoL.Presentation.UI.Panels.BattleManaPanel::_consumingDeque
IL_0036: callvirt System.Int32 System.Collections.Generic.List`1<LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets>::get_Count()
IL_003b: ldc.i4.0
IL_003c: ble IL_0184
IL_0041: ldloc.1
IL_0042: ldfld System.Collections.Generic.List`1<LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets> LBoL.Presentation.UI.Panels.BattleManaPanel::_consumingDeque
IL_0047: ldc.i4.0
IL_0048: callvirt T System.Collections.Generic.List`1<LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets>::get_Item(System.Int32)
IL_004d: stloc.s V_4
IL_004f: ldloc.1
IL_0050: ldfld System.Collections.Generic.List`1<LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets> LBoL.Presentation.UI.Panels.BattleManaPanel::_consumingDeque
IL_0055: ldc.i4.0
IL_0056: callvirt System.Void System.Collections.Generic.List`1<LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets>::RemoveAt(System.Int32)
IL_005b: ldloc.s V_4
IL_005d: callvirt LBoL.Presentation.UI.Panels.ConsumingMana LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets::get_Value()
IL_0062: callvirt LBoL.Base.ManaGroup LBoL.Presentation.UI.Panels.ConsumingMana::get_TotalMana()
IL_0067: ldarg.0
IL_0068: ldfld LBoL.Core.Battle.BattleActions.ConsumeManaAction LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::action
IL_006d: callvirt TArgs LBoL.Core.Battle.EventBattleAction`1<LBoL.Core.ManaEventArgs>::get_Args()
IL_0072: callvirt LBoL.Base.ManaGroup LBoL.Core.ManaEventArgs::get_Value()
IL_0077: call System.Boolean LBoL.Base.ManaGroup::op_Equality(LBoL.Base.ManaGroup,LBoL.Base.ManaGroup)
IL_007c: brfalse IL_013d
IL_0081: ldloc.s V_4
IL_0083: callvirt System.Collections.Generic.List`1<LBoL.Presentation.UI.Widgets.BattleManaWidget> LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets::get_UnpooledWidgets()
IL_0088: ldloc.s V_4
IL_008a: callvirt System.Collections.Generic.List`1<LBoL.Presentation.UI.Widgets.BattleManaWidget> LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets::get_PooledWidgets()
IL_008f: call System.Collections.Generic.IEnumerable`1<TSource> System.Linq.Enumerable::Concat<LBoL.Presentation.UI.Widgets.BattleManaWidget>(System.Collections.Generic.IEnumerable`1<TSource>,System.Collections.Generic.IEnumerable`1<TSource>)
IL_0094: callvirt System.Collections.Generic.IEnumerator`1<T> System.Collections.Generic.IEnumerable`1<LBoL.Presentation.UI.Widgets.BattleManaWidget>::GetEnumerator()
IL_0099: stloc.s V_5
.try
{
  IL_009b: br IL_011d
  IL_00a0: ldloc.s V_5
  IL_00a2: callvirt T System.Collections.Generic.IEnumerator`1<LBoL.Presentation.UI.Widgets.BattleManaWidget>::get_Current()
  IL_00a7: stloc.s V_6
  IL_00a9: ldloc.1
  IL_00aa: ldloc.s V_6
  IL_00ac: call System.Void LBoL.Presentation.UI.Panels.BattleManaPanel::ConsumeAndReleaseManaWidget(LBoL.Presentation.UI.Widgets.BattleManaWidget)
  IL_00b1: ldloc.1
  IL_00b2: ldloc.s V_6
  IL_00b4: call UnityEngine.Vector3 LBoL.Presentation.UI.Panels.BattleManaPanel::GetTargetCenterWorldPosition(LBoL.Presentation.UI.Widgets.BattleManaWidget)
  IL_00b9: stloc.s V_7
  IL_00bb: ldarg.0
  IL_00bc: ldfld LBoL.Core.Battle.BattleActions.ConsumeManaAction LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::action
  IL_00c1: callvirt TArgs LBoL.Core.Battle.EventBattleAction`1<LBoL.Core.ManaEventArgs>::get_Args()
  IL_00c6: callvirt LBoL.Core.GameEntity LBoL.Core.GameEventArgs::get_ActionSource()
  IL_00cb: isinst LBoL.Core.Cards.Card
  IL_00d0: stloc.s V_8
  IL_00d2: ldloc.s V_8
  IL_00d4: brfalse IL_011d
  IL_00d9: ldloc.3
  IL_00da: callvirt LBoL.Presentation.UI.Panels.CardUi LBoL.Presentation.UI.Panels.PlayBoard::get_CardUi()
  IL_00df: ldloc.s V_8
  IL_00e1: callvirt LBoL.Presentation.UI.ExtraWidgets.HandCard LBoL.Presentation.UI.Panels.CardUi::FindHandWidget(LBoL.Core.Cards.Card)
  IL_00e6: stloc.s V_9
  IL_00e8: ldloc.s V_9
  IL_00ea: brfalse IL_011d
  IL_00ef: ldloc.s V_9
  IL_00f1: call System.Boolean UnityEngine.Object::op_Implicit(UnityEngine.Object)
  IL_00f6: brfalse IL_011d
  IL_00fb: ldloc.3
  IL_00fc: ldloc.s V_6
  IL_00fe: callvirt LBoL.Base.ManaColor LBoL.Presentation.UI.Widgets.BattleManaWidget::get_ManaColor()
  IL_0103: ldloc.s V_7
  IL_0105: ldloc.s V_9
  IL_0107: callvirt UnityEngine.Vector3 LBoL.Presentation.UI.ExtraWidgets.HandCard::get_TargetWorldPosition()
  IL_010c: newobj System.Void System.Nullable`1<UnityEngine.Vector3>::.ctor(T)
  IL_0111: callvirt System.Single LBoL.Presentation.UI.Panels.PlayBoard::PlayManaConsumeEffect(LBoL.Base.ManaColor,UnityEngine.Vector3,System.Nullable`1<UnityEngine.Vector3>)
  IL_0116: ldloc.2
  IL_0117: call System.Single System.Math::Max(System.Single,System.Single)
  IL_011c: stloc.2
  IL_011d: ldloc.s V_5
  IL_011f: callvirt System.Boolean System.Collections.IEnumerator::MoveNext()
  IL_0124: brtrue IL_00a0
  IL_0129: leave IL_013d
} // end .try
finally
{
  IL_012e: ldloc.s V_5
  IL_0130: brfalse IL_013c
  IL_0135: ldloc.s V_5
  IL_0137: callvirt System.Void System.IDisposable::Dispose()
  IL_013c: endfinally
} // end handler (finally)
IL_013d: ldstr "Queued mana ({0}) not match consuming {1}, resetting all."
IL_0142: ldloc.s V_4
IL_0144: callvirt LBoL.Presentation.UI.Panels.ConsumingMana LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets::get_Value()
IL_0149: ldarg.0
IL_014a: ldfld LBoL.Core.Battle.BattleActions.ConsumeManaAction LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::action
IL_014f: callvirt TArgs LBoL.Core.Battle.EventBattleAction`1<LBoL.Core.ManaEventArgs>::get_Args()
IL_0154: callvirt LBoL.Base.ManaGroup LBoL.Core.ManaEventArgs::get_Value()
IL_0159: box LBoL.Base.ManaGroup
IL_015e: call System.String System.String::Format(System.String,System.Object,System.Object)
IL_0163: call System.Void UnityEngine.Debug::LogError(System.Object)
IL_0168: ldloc.1
IL_0169: ldloc.1
IL_016a: call LBoL.Core.Battle.BattleController LBoL.Presentation.UI.UiPanelBase::get_Battle()
IL_016f: callvirt LBoL.Base.ManaGroup LBoL.Core.Battle.BattleController::get_BattleMana()
IL_0174: ldsfld LBoL.Base.ManaGroup LBoL.Base.ManaGroup::Empty
IL_0179: ldc.i4.1
IL_017a: call System.Void LBoL.Presentation.UI.Panels.BattleManaPanel::ResetAllManas(LBoL.Base.ManaGroup,LBoL.Base.ManaGroup,System.Boolean)
IL_017f: br IL_01a5
IL_0184: ldstr "Cannot dequeue consuming mana, resetting all."
IL_0189: call System.Void UnityEngine.Debug::LogError(System.Object)
IL_018e: ldloc.1
IL_018f: ldloc.1
IL_0190: call LBoL.Core.Battle.BattleController LBoL.Presentation.UI.UiPanelBase::get_Battle()
IL_0195: callvirt LBoL.Base.ManaGroup LBoL.Core.Battle.BattleController::get_BattleMana()
IL_019a: ldsfld LBoL.Base.ManaGroup LBoL.Base.ManaGroup::Empty
IL_019f: ldc.i4.1
IL_01a0: call System.Void LBoL.Presentation.UI.Panels.BattleManaPanel::ResetAllManas(LBoL.Base.ManaGroup,LBoL.Base.ManaGroup,System.Boolean)
IL_01a5: ldloc.1
IL_01a6: ldloc.1
IL_01a7: ldfld LBoL.Presentation.UI.Panels.BattleManaPanel/ManaCollection LBoL.Presentation.UI.Panels.BattleManaPanel::_pooledCollection
IL_01ac: callvirt LBoL.Base.ManaGroup LBoL.Presentation.UI.Panels.BattleManaPanel/ManaCollection::get_TotalMana()
IL_01b1: stloc.s V_10
IL_01b3: ldloca.s V_10
IL_01b5: call System.Boolean LBoL.Base.ManaGroup::get_IsEmpty()
IL_01ba: ldc.i4.0
IL_01bb: ceq
IL_01bd: call System.Void LBoL.Presentation.UI.Panels.BattleManaPanel::SetPoolBgActive(System.Boolean)
IL_01c2: ldloc.2
IL_01c3: ldc.r4 0
IL_01c8: ble.un IL_01e9
IL_01cd: ldarg.0
IL_01ce: ldloc.2
IL_01cf: newobj System.Void UnityEngine.WaitForSeconds::.ctor(System.Single)
IL_01d4: stfld System.Object LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::<>2__current
IL_01d9: ldarg.0
IL_01da: ldc.i4.1
IL_01db: stfld System.Int32 LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::<>1__state
IL_01e0: ldc.i4.1
IL_01e1: ret
IL_01e2: ldarg.0
IL_01e3: ldc.i4.m1
IL_01e4: stfld System.Int32 LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::<>1__state
IL_01e9: ldc.i4.0
IL_01ea: ret

IL with just Prefix:

[Info   :  HarmonyX] Patching virtual bool LBoL.Presentation.UI.Panels.BattleManaPanel+<ViewConsumeMana>d__54::MoveNext() with 1 prefixes, 0 postfixes, 0 transpilers, 0 finalizers
1 prefixes:
* static void LBoLEntitySideloader.GameFixes+ViewConsumeMana_ErrorMessage_Patch::Prefix()

[Info   :  HarmonyX] Running ILHook manipulator on virtual bool LBoL.Presentation.UI.Panels.BattleManaPanel+<ViewConsumeMana>d__54::MoveNext()
[Info   :  HarmonyX] Writing prefixes
[Debug  :  HarmonyX] Generated patch (System.Boolean DMD<LBoL.Presentation.UI.Panels.BattleManaPanel+<ViewConsumeMana>d__54::MoveNext>?-1219928796::LBoL.Presentation.UI.Panels.BattleManaPanel+<ViewConsumeMana>d__54::MoveNext(LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54)):
.locals init (
    System.Int32 V_0
    LBoL.Presentation.UI.Panels.BattleManaPanel V_1
    System.Single V_2
    LBoL.Presentation.UI.Panels.PlayBoard V_3
    LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets V_4
    System.Collections.Generic.IEnumerator`1<LBoL.Presentation.UI.Widgets.BattleManaWidget> V_5
    LBoL.Presentation.UI.Widgets.BattleManaWidget V_6
    UnityEngine.Vector3 V_7
    LBoL.Core.Cards.Card V_8
    LBoL.Presentation.UI.ExtraWidgets.HandCard V_9
    LBoL.Base.ManaGroup V_10
    System.Boolean V_11
    System.Boolean V_12
)
IL_0000: ldc.i4.1
IL_0001: stloc V_12
IL_0005: call System.Void LBoLEntitySideloader.GameFixes/ViewConsumeMana_ErrorMessage_Patch::Prefix()
IL_000a: ldarg.0
IL_000b: ldfld System.Int32 LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::<>1__state
IL_0010: stloc.0
IL_0011: ldarg.0
IL_0012: ldfld LBoL.Presentation.UI.Panels.BattleManaPanel LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::<>4__this
IL_0017: stloc.1
IL_0018: ldloc.0
IL_0019: brfalse.s IL_0028
IL_001b: ldloc.0
IL_001c: ldc.i4.1
IL_001d: beq IL_01d6
IL_0022: ldc.i4.0
IL_0023: br IL_01e3
IL_0028: ldarg.0
IL_0029: ldc.i4.m1
IL_002a: stfld System.Int32 LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::<>1__state
IL_002f: ldc.r4 0
IL_0034: stloc.2
IL_0035: call TPanel LBoL.Presentation.UI.UiManager::GetPanel<LBoL.Presentation.UI.Panels.PlayBoard>()
IL_003a: stloc.3
IL_003b: ldloc.1
IL_003c: ldfld System.Collections.Generic.List`1<LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets> LBoL.Presentation.UI.Panels.BattleManaPanel::_consumingDeque
IL_0041: callvirt System.Int32 System.Collections.Generic.List`1<LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets>::get_Count()
IL_0046: ldc.i4.0
IL_0047: ble IL_0177
IL_004c: ldloc.1
IL_004d: ldfld System.Collections.Generic.List`1<LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets> LBoL.Presentation.UI.Panels.BattleManaPanel::_consumingDeque
IL_0052: ldc.i4.0
IL_0053: callvirt T System.Collections.Generic.List`1<LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets>::get_Item(System.Int32)
IL_0058: stloc.s V_4
IL_005a: ldloc.1
IL_005b: ldfld System.Collections.Generic.List`1<LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets> LBoL.Presentation.UI.Panels.BattleManaPanel::_consumingDeque
IL_0060: ldc.i4.0
IL_0061: callvirt System.Void System.Collections.Generic.List`1<LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets>::RemoveAt(System.Int32)
IL_0066: ldloc.s V_4
IL_0068: callvirt LBoL.Presentation.UI.Panels.ConsumingMana LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets::get_Value()
IL_006d: callvirt LBoL.Base.ManaGroup LBoL.Presentation.UI.Panels.ConsumingMana::get_TotalMana()
IL_0072: ldarg.0
IL_0073: ldfld LBoL.Core.Battle.BattleActions.ConsumeManaAction LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::action
IL_0078: callvirt TArgs LBoL.Core.Battle.EventBattleAction`1<LBoL.Core.ManaEventArgs>::get_Args()
IL_007d: callvirt LBoL.Base.ManaGroup LBoL.Core.ManaEventArgs::get_Value()
IL_0082: call System.Boolean LBoL.Base.ManaGroup::op_Equality(LBoL.Base.ManaGroup,LBoL.Base.ManaGroup)
IL_0087: brfalse IL_0133
IL_008c: ldloc.s V_4
IL_008e: callvirt System.Collections.Generic.List`1<LBoL.Presentation.UI.Widgets.BattleManaWidget> LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets::get_UnpooledWidgets()
IL_0093: ldloc.s V_4
IL_0095: callvirt System.Collections.Generic.List`1<LBoL.Presentation.UI.Widgets.BattleManaWidget> LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets::get_PooledWidgets()
IL_009a: call System.Collections.Generic.IEnumerable`1<TSource> System.Linq.Enumerable::Concat<LBoL.Presentation.UI.Widgets.BattleManaWidget>(System.Collections.Generic.IEnumerable`1<TSource>,System.Collections.Generic.IEnumerable`1<TSource>)
IL_009f: callvirt System.Collections.Generic.IEnumerator`1<T> System.Collections.Generic.IEnumerable`1<LBoL.Presentation.UI.Widgets.BattleManaWidget>::GetEnumerator()
IL_00a4: stloc.s V_5
.try
{
  IL_00a6: br.s IL_011c
  IL_00a8: ldloc.s V_5
  IL_00aa: callvirt T System.Collections.Generic.IEnumerator`1<LBoL.Presentation.UI.Widgets.BattleManaWidget>::get_Current()
  IL_00af: stloc.s V_6
  IL_00b1: ldloc.1
  IL_00b2: ldloc.s V_6
  IL_00b4: call System.Void LBoL.Presentation.UI.Panels.BattleManaPanel::ConsumeAndReleaseManaWidget(LBoL.Presentation.UI.Widgets.BattleManaWidget)
  IL_00b9: ldloc.1
  IL_00ba: ldloc.s V_6
  IL_00bc: call UnityEngine.Vector3 LBoL.Presentation.UI.Panels.BattleManaPanel::GetTargetCenterWorldPosition(LBoL.Presentation.UI.Widgets.BattleManaWidget)
  IL_00c1: stloc.s V_7
  IL_00c3: ldarg.0
  IL_00c4: ldfld LBoL.Core.Battle.BattleActions.ConsumeManaAction LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::action
  IL_00c9: callvirt TArgs LBoL.Core.Battle.EventBattleAction`1<LBoL.Core.ManaEventArgs>::get_Args()
  IL_00ce: callvirt LBoL.Core.GameEntity LBoL.Core.GameEventArgs::get_ActionSource()
  IL_00d3: isinst LBoL.Core.Cards.Card
  IL_00d8: stloc.s V_8
  IL_00da: ldloc.s V_8
  IL_00dc: brfalse.s IL_011c
  IL_00de: ldloc.3
  IL_00df: callvirt LBoL.Presentation.UI.Panels.CardUi LBoL.Presentation.UI.Panels.PlayBoard::get_CardUi()
  IL_00e4: ldloc.s V_8
  IL_00e6: callvirt LBoL.Presentation.UI.ExtraWidgets.HandCard LBoL.Presentation.UI.Panels.CardUi::FindHandWidget(LBoL.Core.Cards.Card)
  IL_00eb: stloc.s V_9
  IL_00ed: ldloc.s V_9
  IL_00ef: brfalse.s IL_011c
  IL_00f1: ldloc.s V_9
  IL_00f3: call System.Boolean UnityEngine.Object::op_Implicit(UnityEngine.Object)
  IL_00f8: brfalse.s IL_011c
  IL_00fa: ldloc.3
  IL_00fb: ldloc.s V_6
  IL_00fd: callvirt LBoL.Base.ManaColor LBoL.Presentation.UI.Widgets.BattleManaWidget::get_ManaColor()
  IL_0102: ldloc.s V_7
  IL_0104: ldloc.s V_9
  IL_0106: callvirt UnityEngine.Vector3 LBoL.Presentation.UI.ExtraWidgets.HandCard::get_TargetWorldPosition()
  IL_010b: newobj System.Void System.Nullable`1<UnityEngine.Vector3>::.ctor(T)
  IL_0110: callvirt System.Single LBoL.Presentation.UI.Panels.PlayBoard::PlayManaConsumeEffect(LBoL.Base.ManaColor,UnityEngine.Vector3,System.Nullable`1<UnityEngine.Vector3>)
  IL_0115: ldloc.2
  IL_0116: call System.Single System.Math::Max(System.Single,System.Single)
  IL_011b: stloc.2
  IL_011c: ldloc.s V_5
  IL_011e: callvirt System.Boolean System.Collections.IEnumerator::MoveNext()
  IL_0123: brtrue.s IL_00a8
  IL_0125: leave.s IL_0198
} // end .try
finally
{
  IL_0127: ldloc.s V_5
  IL_0129: brfalse.s IL_0132
  IL_012b: ldloc.s V_5
  IL_012d: callvirt System.Void System.IDisposable::Dispose()
  IL_0132: endfinally
} // end handler (finally)
IL_0133: ldstr "Queued mana ({0}) not match consuming {1}, resetting all."
IL_0138: ldloc.s V_4
IL_013a: callvirt LBoL.Presentation.UI.Panels.ConsumingMana LBoL.Presentation.UI.Panels.BattleManaPanel/ConsumingManaWidgets::get_Value()
IL_013f: ldarg.0
IL_0140: ldfld LBoL.Core.Battle.BattleActions.ConsumeManaAction LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::action
IL_0145: callvirt TArgs LBoL.Core.Battle.EventBattleAction`1<LBoL.Core.ManaEventArgs>::get_Args()
IL_014a: callvirt LBoL.Base.ManaGroup LBoL.Core.ManaEventArgs::get_Value()
IL_014f: box LBoL.Base.ManaGroup
IL_0154: call System.String System.String::Format(System.String,System.Object,System.Object)
IL_0159: call System.Void UnityEngine.Debug::LogError(System.Object)
IL_015e: ldloc.1
IL_015f: ldloc.1
IL_0160: call LBoL.Core.Battle.BattleController LBoL.Presentation.UI.UiPanelBase::get_Battle()
IL_0165: callvirt LBoL.Base.ManaGroup LBoL.Core.Battle.BattleController::get_BattleMana()
IL_016a: ldsfld LBoL.Base.ManaGroup LBoL.Base.ManaGroup::Empty
IL_016f: ldc.i4.1
IL_0170: call System.Void LBoL.Presentation.UI.Panels.BattleManaPanel::ResetAllManas(LBoL.Base.ManaGroup,LBoL.Base.ManaGroup,System.Boolean)
IL_0175: br.s IL_0198
IL_0177: ldstr "Cannot dequeue consuming mana, resetting all."
IL_017c: call System.Void UnityEngine.Debug::LogError(System.Object)
IL_0181: ldloc.1
IL_0182: ldloc.1
IL_0183: call LBoL.Core.Battle.BattleController LBoL.Presentation.UI.UiPanelBase::get_Battle()
IL_0188: callvirt LBoL.Base.ManaGroup LBoL.Core.Battle.BattleController::get_BattleMana()
IL_018d: ldsfld LBoL.Base.ManaGroup LBoL.Base.ManaGroup::Empty
IL_0192: ldc.i4.1
IL_0193: call System.Void LBoL.Presentation.UI.Panels.BattleManaPanel::ResetAllManas(LBoL.Base.ManaGroup,LBoL.Base.ManaGroup,System.Boolean)
IL_0198: ldloc.1
IL_0199: ldloc.1
IL_019a: ldfld LBoL.Presentation.UI.Panels.BattleManaPanel/ManaCollection LBoL.Presentation.UI.Panels.BattleManaPanel::_pooledCollection
IL_019f: callvirt LBoL.Base.ManaGroup LBoL.Presentation.UI.Panels.BattleManaPanel/ManaCollection::get_TotalMana()
IL_01a4: stloc.s V_10
IL_01a6: ldloca.s V_10
IL_01a8: call System.Boolean LBoL.Base.ManaGroup::get_IsEmpty()
IL_01ad: ldc.i4.0
IL_01ae: ceq
IL_01b0: call System.Void LBoL.Presentation.UI.Panels.BattleManaPanel::SetPoolBgActive(System.Boolean)
IL_01b5: ldloc.2
IL_01b6: ldc.r4 0
IL_01bb: ble.un.s IL_01dd
IL_01bd: ldarg.0
IL_01be: ldloc.2
IL_01bf: newobj System.Void UnityEngine.WaitForSeconds::.ctor(System.Single)
IL_01c4: stfld System.Object LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::<>2__current
IL_01c9: ldarg.0
IL_01ca: ldc.i4.1
IL_01cb: stfld System.Int32 LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::<>1__state
IL_01d0: ldc.i4.1
IL_01d1: br IL_01e3
IL_01d6: ldarg.0
IL_01d7: ldc.i4.m1
IL_01d8: stfld System.Int32 LBoL.Presentation.UI.Panels.BattleManaPanel/<ViewConsumeMana>d__54::<>1__state
IL_01dd: ldc.i4.0
IL_01de: br IL_01e3
IL_01e3: ret

Decompiled method:

private IEnumerator ViewConsumeMana(ConsumeManaAction action)
{
    float num = 0f;
    PlayBoard panel = UiManager.GetPanel<PlayBoard>();
    if (this._consumingDeque.Count > 0)
    {
        BattleManaPanel.ConsumingManaWidgets consumingManaWidgets = this._consumingDeque[0];
        this._consumingDeque.RemoveAt(0);
        if (consumingManaWidgets.Value.TotalMana == action.Args.Value)
        {
            using (IEnumerator<BattleManaWidget> enumerator = consumingManaWidgets.UnpooledWidgets.Concat(consumingManaWidgets.PooledWidgets).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    BattleManaWidget battleManaWidget = enumerator.Current;
                    this.ConsumeAndReleaseManaWidget(battleManaWidget);
                    Vector3 targetCenterWorldPosition = this.GetTargetCenterWorldPosition(battleManaWidget);
                    Card card = action.Args.ActionSource as Card;
                    if (card != null)
                    {
                        HandCard handCard = panel.CardUi.FindHandWidget(card);
                        if (handCard != null && handCard)
                        {
                            num = Math.Max(panel.PlayManaConsumeEffect(battleManaWidget.ManaColor, targetCenterWorldPosition, new Vector3?(handCard.TargetWorldPosition)), num);
                        }
                    }
                }
                goto IL_18A;
            }
        }
        Debug.LogError(string.Format("Queued mana ({0}) not match consuming {1}, resetting all.", consumingManaWidgets.Value, action.Args.Value));
        this.ResetAllManas(base.Battle.BattleMana, ManaGroup.Empty, true);
    }
    else
    {
        Debug.LogError("Cannot dequeue consuming mana, resetting all.");
        this.ResetAllManas(base.Battle.BattleMana, ManaGroup.Empty, true);
    }
    IL_18A:
    this.SetPoolBgActive(!this._pooledCollection.TotalMana.IsEmpty);
    if (num > 0f)
    {
        yield return new WaitForSeconds(num);
    }
    yield break;
}
ManlyMarco commented 10 months ago

Same as #77?

Neoshrimp commented 10 months ago

Seems to be. I'll use Nop workaround for now, thanks

ManlyMarco commented 1 month ago

Fixed in latest releases.