Decompiled source of RealisticReloadV3 v1.0.3

RealisticReloadV2.dll

Decompiled a week ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using DMRReloadFix.Patches;
using GTFO.API;
using GTFO.API.JSON;
using HarmonyLib;
using MTFO.API;
using Microsoft.CodeAnalysis;
using Player;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("RealisticReloadV2")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RealisticReloadV2")]
[assembly: AssemblyTitle("RealisticReloadV2")]
[assembly: TargetPlatform("Windows7.0")]
[assembly: SupportedOSPlatform("Windows7.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
namespace RealisticReloadV2
{
	internal static class DMRFixWrapper
	{
		private const string PluginGUID = "randomuserhi.DMRReloadFix";

		public static bool IsLoaded;

		static DMRFixWrapper()
		{
			IsLoaded = false;
			IsLoaded = ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("randomuserhi.DMRReloadFix");
		}
	}
	[BepInPlugin("RealisticReloadV2.GUID", "RealisticReloadV2", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class EntryPoint : BasePlugin
	{
		private Harmony _Harmony = null;

		public override void Load()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			_Harmony = new Harmony("RealisticReloadV2.Harmony");
			_Harmony.PatchAll();
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin has loaded with ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_Harmony.GetPatchedMethods().Count());
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" patches!");
			}
			Logger.Info(val);
			GameDataAPI.OnGameDataInitialized += FileParse.init;
		}

		public override bool Unload()
		{
			_Harmony.UnpatchSelf();
			return ((BasePlugin)this).Unload();
		}
	}
	internal class FileParse
	{
		public static List<uint> ExemptGuns = new List<uint> { 13u, 44u, 61u };

		public static string filename = "RealisticReloadExemptions.json";

		public static void init()
		{
			if (MTFOWrapper.IsLoaded)
			{
				load();
			}
		}

		public static void load()
		{
			if (MTFOPathAPI.HasCustomPath)
			{
				string path = Path.Combine(MTFOPathAPI.CustomPath, filename);
				if (File.Exists(path))
				{
					ExemptGuns = JsonSerializer.Deserialize<List<uint>>(File.ReadAllText(path), (JsonSerializerOptions)null);
				}
			}
		}
	}
	internal static class Logger
	{
		private static readonly ManualLogSource _Logger;

		static Logger()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			_Logger = new ManualLogSource("RealisticReloadV2");
			Logger.Sources.Add((ILogSource)(object)_Logger);
		}

		private static string Format(object msg)
		{
			return msg.ToString();
		}

		public static void Info(BepInExInfoLogInterpolatedStringHandler handler)
		{
			_Logger.LogInfo(handler);
		}

		public static void Info(string str)
		{
			_Logger.LogMessage((object)str);
		}

		public static void Info(object data)
		{
			_Logger.LogMessage((object)Format(data));
		}

		public static void Debug(BepInExDebugLogInterpolatedStringHandler handler)
		{
			_Logger.LogDebug(handler);
		}

		public static void Debug(string str)
		{
			_Logger.LogDebug((object)str);
		}

		public static void Debug(object data)
		{
			_Logger.LogDebug((object)Format(data));
		}

		public static void Error(BepInExErrorLogInterpolatedStringHandler handler)
		{
			_Logger.LogError(handler);
		}

		public static void Error(string str)
		{
			_Logger.LogError((object)str);
		}

		public static void Error(object data)
		{
			_Logger.LogError((object)Format(data));
		}

		public static void Fatal(BepInExFatalLogInterpolatedStringHandler handler)
		{
			_Logger.LogFatal(handler);
		}

		public static void Fatal(string str)
		{
			_Logger.LogFatal((object)str);
		}

		public static void Fatal(object data)
		{
			_Logger.LogFatal((object)Format(data));
		}

		public static void Warn(BepInExWarningLogInterpolatedStringHandler handler)
		{
			_Logger.LogWarning(handler);
		}

		public static void Warn(string str)
		{
			_Logger.LogWarning((object)str);
		}

		public static void Warn(object data)
		{
			_Logger.LogWarning((object)Format(data));
		}

		[Conditional("DEBUG")]
		public static void DebugOnly(object data)
		{
			_Logger.LogDebug((object)Format(data));
		}
	}
	internal static class MTFOWrapper
	{
		private const string PluginGUID = "com.dak.MTFO";

		public static bool IsLoaded;

		static MTFOWrapper()
		{
			IsLoaded = false;
			IsLoaded = ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("com.dak.MTFO");
		}
	}
	[HarmonyPatch]
	internal class Patches
	{
		public static List<DRAMA_State> DramaStateList = new List<DRAMA_State>(4)
		{
			(DRAMA_State)6,
			(DRAMA_State)5,
			(DRAMA_State)8,
			(DRAMA_State)7
		};

		[HarmonyPatch(typeof(PlayerAmmoStorage), "GetClipBulletsFromPack")]
		[HarmonyPrefix]
		[HarmonyPriority(500)]
		public static void DoAmmoPrefix(PlayerAmmoStorage __instance, ref int currentClip, AmmoType ammoType)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			if (!DramaStateList.Contains(DramaManager.CurrentStateEnum) || __instance.m_playerBackpack.Owner.IsBot)
			{
				return;
			}
			InventorySlot slotFromAmmoType = PlayerAmmoStorage.GetSlotFromAmmoType(ammoType);
			BackpackItem val = default(BackpackItem);
			__instance.m_playerBackpack.TryGetBackpackItem(slotFromAmmoType, ref val);
			if (!uint.TryParse(val.GearIDRange.PlayfabItemInstanceId.Substring("OfflineGear_ID_".Length), out var result))
			{
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to convert string to integer: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(val.GearIDRange.PlayfabItemInstanceId);
				}
				Logger.Error(val2);
			}
			else if (!FileParse.ExemptGuns.Contains(result) && (!DMRFixWrapper.IsLoaded || !DMRRetriever()))
			{
				currentClip = 0;
			}
		}

		public static bool DMRRetriever()
		{
			return Reload.callOriginal;
		}
	}
	[GeneratedCode("VersionInfoGenerator", "2.1.3+git35c0c2a-master")]
	[CompilerGenerated]
	internal static class VersionInfo
	{
		public const string RootNamespace = "RealisticReloadV2";

		public const string Version = "1.0.0";

		public const string VersionPrerelease = null;

		public const string VersionMetadata = null;

		public const string SemVer = "1.0.0";

		public const string GitRevShort = null;

		public const string GitRevLong = null;

		public const string GitBranch = null;

		public const string GitTag = null;

		public const int GitCommitsSinceTag = 0;

		public const bool GitIsDirty = false;
	}
}