using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Pigeon.Math;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Sparroh")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("HeavyBugfix")]
[assembly: AssemblyTitle("HeavyBugfix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
[HarmonyPatch(typeof(UpgradeProperty_FireInterval), "GetStatData")]
internal static class FireIntervalGetStatDataPatch
{
private static readonly object ResolveLock = new object();
private static bool _resolved;
private static MethodInfo _createInverse;
private static bool _loggedResolve;
private static bool Prefix(UpgradeProperty_FireInterval __instance, Random rand, IUpgradable gear, UpgradeInstance upgrade, ref IEnumerator<StatData> __result)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
__result = BuildStatData(__instance, rand, gear, upgrade);
return false;
}
private static IEnumerator<StatData> BuildStatData(UpgradeProperty_FireInterval instance, Random rand, IUpgradable gear, UpgradeInstance upgrade)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
OverrideData<Range<float>> additiveData = instance.fireInterval.GetAdditiveData(0);
float prefabFireInterval = GetPrefabFireInterval(gear);
yield return CreateInverseCompat(TextBlocks.GetString("firerate"), additiveData, upgrade, ref rand, prefabFireInterval, BoostParams.MinIsBetter);
}
private static StatData CreateInverseCompat(string name, OverrideData<Range<float>> range, UpgradeInstance upgrade, ref Random rand, float prefabValue, BoostParams canBeBoosted)
{
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
EnsureCreateInverseResolved();
if (_createInverse != null)
{
try
{
ParameterInfo[] parameters = _createInverse.GetParameters();
object[] array = new object[parameters.Length];
array[0] = name;
array[1] = range;
array[2] = upgrade;
array[3] = rand;
array[4] = prefabValue;
for (int i = 5; i < parameters.Length; i++)
{
ParameterInfo parameterInfo = parameters[i];
Type parameterType = parameterInfo.ParameterType;
if (parameterType == typeof(BoostParams))
{
array[i] = canBeBoosted;
}
else if (parameterInfo.HasDefaultValue)
{
array[i] = parameterInfo.DefaultValue;
}
else if (!parameterType.IsValueType || Nullable.GetUnderlyingType(parameterType) != null)
{
array[i] = null;
}
else
{
array[i] = Activator.CreateInstance(parameterType);
}
}
StatData result = (StatData)_createInverse.Invoke(null, array);
rand = (Random)array[3];
return result;
}
catch (Exception ex)
{
ManualLogSource log = HeavyBugfixPlugin.Log;
if (log != null)
{
log.LogDebug((object)("CreateInverse invoke failed, using inline fallback: " + ex.GetBaseException().Message));
}
}
}
return CreateInverseInline(name, range, upgrade, ref rand, prefabValue, canBeBoosted);
}
private static void EnsureCreateInverseResolved()
{
if (_resolved)
{
return;
}
lock (ResolveLock)
{
if (_resolved)
{
return;
}
try
{
_createInverse = FindCreateInverseMethod();
if (!_loggedResolve)
{
_loggedResolve = true;
if (_createInverse != null)
{
ManualLogSource log = HeavyBugfixPlugin.Log;
if (log != null)
{
log.LogDebug((object)$"Using StatData.CreateInverse overload: {_createInverse}");
}
}
else
{
ManualLogSource log2 = HeavyBugfixPlugin.Log;
if (log2 != null)
{
log2.LogDebug((object)"No compatible StatData.CreateInverse overload found; using inline fallback.");
}
}
}
}
catch (Exception ex)
{
ManualLogSource log3 = HeavyBugfixPlugin.Log;
if (log3 != null)
{
log3.LogDebug((object)("CreateInverse resolve failed: " + ex.Message));
}
_createInverse = null;
}
_resolved = true;
}
}
private static MethodInfo FindCreateInverseMethod()
{
MethodInfo result = null;
int num = int.MinValue;
MethodInfo[] methods = typeof(StatData).GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.Name != "CreateInverse" || methodInfo.ReturnType != typeof(StatData))
{
continue;
}
ParameterInfo[] parameters = methodInfo.GetParameters();
if (parameters.Length >= 5 && !(parameters[0].ParameterType != typeof(string)) && IsOverrideDataRangeFloat(parameters[1].ParameterType) && !(parameters[2].ParameterType != typeof(UpgradeInstance)) && IsRandomParam(parameters[3].ParameterType) && !(parameters[4].ParameterType != typeof(float)))
{
int num2 = 100 - parameters.Length;
for (int j = 5; j < parameters.Length; j++)
{
num2 = ((!(parameters[j].ParameterType == typeof(BoostParams))) ? ((!parameters[j].HasDefaultValue && !(Nullable.GetUnderlyingType(parameters[j].ParameterType) != null)) ? (num2 - 5) : (num2 + 3)) : (num2 + 10));
}
if (num2 > num)
{
num = num2;
result = methodInfo;
}
}
}
return result;
}
private static bool IsOverrideDataRangeFloat(Type type)
{
if (!type.IsGenericType || type.GetGenericTypeDefinition() != typeof(OverrideData<>))
{
return false;
}
Type type2 = type.GetGenericArguments()[0];
if (type2.IsGenericType && type2.GetGenericTypeDefinition() == typeof(Range<>))
{
return type2.GetGenericArguments()[0] == typeof(float);
}
return false;
}
private static bool IsRandomParam(Type type)
{
return (type.IsByRef ? type.GetElementType() : type) == typeof(Random);
}
private static StatData CreateInverseInline(string name, OverrideData<Range<float>> range, UpgradeInstance upgrade, ref Random rand, float prefabValue, BoostParams canBeBoosted)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Invalid comparison between Unknown and I4
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Invalid comparison between Unknown and I4
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
if (!range.Override)
{
return new StatData((string)null, (string)null, (OverrideType)0, (LabelType)1, default(BoostParams));
}
if (prefabValue == 0f || float.IsNaN(prefabValue) || float.IsInfinity(prefabValue))
{
prefabValue = 1f;
}
if ((int)range.method == 1)
{
range.data.min = range.data.min / prefabValue + 1f;
range.data.max = range.data.max / prefabValue + 1f;
}
else if ((int)range.method == 3)
{
range.data.min = range.data.min / prefabValue;
range.data.max = range.data.max / prefabValue;
}
float value = range.data.GetValue(ref rand, upgrade, canBeBoosted);
string valueString = StatData.GetValueString((OverrideType)2, 1f / value, 2, (string)null);
string rangeValueString = StatData.GetRangeValueString((OverrideType)2, 1f / range.data.min, 2, (string)null);
string rangeValueString2 = StatData.GetRangeValueString((OverrideType)2, 1f / range.data.max, 2, (string)null);
return new StatData(name, valueString, rangeValueString, rangeValueString2, (OverrideType)2, (LabelType)1, canBeBoosted);
}
private static float GetPrefabFireInterval(IUpgradable gear)
{
IUpgradable val = gear;
try
{
if (gear != null)
{
IUpgradable prefab = gear.GetPrefab();
if (prefab != null)
{
val = prefab;
}
}
}
catch (Exception ex)
{
ManualLogSource log = HeavyBugfixPlugin.Log;
if (log != null)
{
log.LogDebug((object)("GetPrefab failed, using provided gear: " + ex.Message));
}
}
IWeapon val2 = (IWeapon)(object)((val is IWeapon) ? val : null);
if (val2 != null)
{
return val2.GunData.fireInterval;
}
IWeapon val3 = (IWeapon)(object)((gear is IWeapon) ? gear : null);
if (val3 != null)
{
return val3.GunData.fireInterval;
}
return 1f;
}
}
[BepInPlugin("sparroh.heavybugfix", "HeavyBugfix", "1.0.2")]
[MycoMod(/*Could not decode attribute arguments.*/)]
public class HeavyBugfixPlugin : BaseUnityPlugin
{
public const string PluginGUID = "sparroh.heavybugfix";
public const string PluginName = "HeavyBugfix";
public const string PluginVersion = "1.0.2";
internal static ManualLogSource Log;
private Harmony _harmony;
private void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
_harmony = new Harmony("sparroh.heavybugfix");
_harmony.PatchAll(typeof(FireIntervalGetStatDataPatch));
Log.LogInfo((object)"HeavyBugfix v1.0.2 loaded — fire-interval range display stabilized.");
}
private void OnDestroy()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}
namespace HeavyBugfix
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "HeavyBugfix";
public const string PLUGIN_NAME = "HeavyBugfix";
public const string PLUGIN_VERSION = "1.0.2";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}