Decompiled source of DMRReloadFix v0.0.5

DMRReloadFix.dll

Decompiled 10 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using API;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using GameData;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Player;
using UnityEngine.Analytics;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DMRReloadFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+186b8e6130edc88c84ce66b13d2fa3c82c8ec868")]
[assembly: AssemblyProduct("DMRReloadFix")]
[assembly: AssemblyTitle("DMRReloadFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace DMRReloadFix
{
	public static class ConfigManager
	{
		private static ConfigEntry<bool> debug;

		public static bool Debug => debug.Value;

		static ConfigManager()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			debug = new ConfigFile(Path.Combine(Paths.ConfigPath, "DMRReloadFix.cfg"), true).Bind<bool>("Debug", "enable", false, "Enables debug messages when true.");
		}
	}
	public static class Module
	{
		public const string GUID = "randomuserhi.DMRReloadFix";

		public const string Name = "DMRReloadFix";

		public const string Version = "0.0.1";
	}
	[BepInPlugin("randomuserhi.DMRReloadFix", "DMRReloadFix", "0.0.1")]
	internal class Entry : BasePlugin
	{
		private Harmony harmony;

		public override void Load()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			APILogger.Debug("DMRReloadFix", "Loaded DMRReloadFix");
			harmony = new Harmony("randomuserhi.DMRReloadFix");
			harmony.PatchAll();
			APILogger.Debug("DMRReloadFix", "Debug is " + (ConfigManager.Debug ? "Enabled" : "Disabled"));
		}
	}
}
namespace DMRReloadFix.Patches
{
	[HarmonyPatch(typeof(GameDataInit))]
	internal class GameDataInit_Patches
	{
		[HarmonyPatch("Initialize")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		public static void Initialize_Postfix()
		{
			Analytics.enabled = false;
		}
	}
	[HarmonyPatch]
	internal static class Reload
	{
		private static bool callOriginal;

		[HarmonyPatch(typeof(PlayerAmmoStorage), "GetClipBulletsFromPack")]
		[HarmonyPrefix]
		private static bool Prefix_GetClipBulletsFromPack(PlayerAmmoStorage __instance, ref int __result, int currentClip, AmmoType ammoType)
		{
			//IL_0011: 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)
			if (!callOriginal)
			{
				callOriginal = true;
				__result = __instance.GetClipBulletsFromPack(__instance.GetClipBulletsFromPack(currentClip, ammoType), ammoType);
				callOriginal = false;
				return false;
			}
			return true;
		}
	}
}
namespace API
{
	internal static class APILogger
	{
		private static readonly ManualLogSource logger;

		static APILogger()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			logger = new ManualLogSource("Rand-API");
			Logger.Sources.Add((ILogSource)(object)logger);
		}

		private static string Format(string module, object msg)
		{
			return $"[{module}]: {msg}";
		}

		public static void Info(string module, object data)
		{
			logger.LogMessage((object)Format(module, data));
		}

		public static void Verbose(string module, object data)
		{
		}

		public static void Debug(string module, object data)
		{
			logger.LogDebug((object)Format(module, data));
		}

		public static void Warn(string module, object data)
		{
			logger.LogWarning((object)Format(module, data));
		}

		public static void Error(string module, object data)
		{
			logger.LogError((object)Format(module, data));
		}
	}
}