internal BetterInfoCardsCompat() { RegisterMethodFunc addConv = null; exportMethod = null; try { addConv = PPatchTools.GetTypeSafe(BIC_NAMESPACE + "ConverterManager", BIC_ASSEMBLY)?.Detour <RegisterMethodFunc>("AddConverterReflect"); var patchType = PPatchTools.GetTypeSafe(BIC_NAMESPACE + "CollectHoverInfo", BIC_ASSEMBLY)?.GetNestedType("GetSelectInfo_Patch", BindingFlags.Static | BindingFlags.Instance | PPatchTools.BASE_FLAGS); if (patchType != null) { exportMethod = patchType.Detour <ExportMethodFunc>("Export"); } } catch (AmbiguousMatchException e) { PUtil.LogWarning("Exception when loading Better Info Cards compatibility:"); PUtil.LogExcWarn(e); } catch (DetourException e) { PUtil.LogWarning("Exception when loading Better Info Cards compatibility:"); PUtil.LogExcWarn(e); } if (addConv != null && exportMethod != null) { try { Register(addConv, EXPORT_THERMAL_MASS, ObjectToFloat, SumThermalMass); Register(addConv, EXPORT_HEAT_ENERGY, ObjectToFloat, SumHeatEnergy); PUtil.LogDebug("Registered Better Info Cards status data handlers"); } catch (Exception e) { PUtil.LogWarning("Exception when registering Better Info Cards compatibility:"); PUtil.LogExcWarn(e.GetBaseException()); } } }
internal BetterInfoCardsCompat() { MethodInfo addConv = null; exportMethod = null; try { addConv = PPatchTools.GetTypeSafe(BIC_NAMESPACE + "ConverterManager", BIC_ASSEMBLY)?.GetMethodSafe("AddConverter", true, PPatchTools. AnyArguments); var patchType = PPatchTools.GetTypeSafe(BIC_NAMESPACE + "CollectHoverInfo", BIC_ASSEMBLY)?.GetNestedType("GetSelectInfo_Patch", BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); if (patchType != null) { exportMethod = patchType.CreateStaticDelegate <ExportMethodFunc>("Export", typeof(string), typeof(object)); } } catch (TargetInvocationException e) { PUtil.LogWarning("Exception when loading Better Info Cards compatibility:"); PUtil.LogExcWarn(e?.GetBaseException() ?? e); } catch (AmbiguousMatchException e) { PUtil.LogWarning("Exception when loading Better Info Cards compatibility:"); PUtil.LogExcWarn(e); } if (addConv != null && exportMethod != null) { // Delegates are much faster at runtime registerMethod = addConv; try { Register(EXPORT_THERMAL_MASS, ObjectToFloat, SumThermalMass); Register(EXPORT_HEAT_ENERGY, ObjectToFloat, SumHeatEnergy); PUtil.LogDebug("Registered Better Info Cards status data handlers"); } catch (TargetInvocationException e) { PUtil.LogWarning("Exception when registering Better Info Cards compatibility:"); PUtil.LogExcWarn(e?.GetBaseException() ?? e); } } else { registerMethod = null; } }