Decompiled source of HarderTurrets v1.0.0

HarderTurrets.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarderTurrets.Patches;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("HarderTurrets")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HarderTurrets")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5ef44eae-4d1a-48f4-ace9-8da88ee852dd")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 HarderTurrets
{
	[BepInPlugin("Jacky.HarderTurrets", "HarderTurrets", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class HarderTurrets : BaseUnityPlugin
	{
		private const string modGUID = "Jacky.HarderTurrets";

		private const string modName = "HarderTurrets";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Jacky.HarderTurrets");

		public static HarderTurrets Instance;

		public ConfigEntry<int> turretSpawnMultiplier;

		public static ManualLogSource logger;

		private void Awake()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_0075: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			logger = ((BaseUnityPlugin)this).Logger;
			logger.LogInfo((object)"Harder turrets has awaken");
			turretSpawnMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("HarderTurrets Config", "Turret Spawn Multiplier", 2, "This value multiplies the number of Turret spawn!");
			ConfigEntry<int> obj = turretSpawnMultiplier;
			IntSliderOptions val = new IntSliderOptions();
			((BaseRangeOptions<int>)val).Min = 0;
			((BaseRangeOptions<int>)val).Max = 30;
			IntSliderConfigItem val2 = new IntSliderConfigItem(obj, val);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
			harmony.PatchAll(typeof(RoundManagerPatch));
		}
	}
}
namespace HarderTurrets.Patches
{
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch("SpawnMapObjects")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> HazardSpawnPatch(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			for (int i = 0; i < list.Count; i++)
			{
				CodeInstruction val = list[i];
				if (val.opcode == OpCodes.Conv_I4)
				{
					CodeInstruction item = new CodeInstruction(OpCodes.Ldc_I4, (object)3);
					CodeInstruction item2 = new CodeInstruction(OpCodes.Add, (object)null);
					CodeInstruction item3 = new CodeInstruction(OpCodes.Ldc_I4, (object)HarderTurrets.Instance.turretSpawnMultiplier.Value);
					CodeInstruction item4 = new CodeInstruction(OpCodes.Mul, (object)null);
					list.Insert(i + 1, item);
					list.Insert(i + 2, item2);
					list.Insert(i + 3, item3);
					list.Insert(i + 4, item4);
					break;
				}
			}
			return list;
		}
	}
}
namespace SigurdLib.Util.Extensions
{
	public static class ManualLogSourceExtensions
	{
		private class CodeInstructionFormatter
		{
			private int _instructionIndexPadLength = instructionCount.ToString().Length;

			public CodeInstructionFormatter(int instructionCount)
			{
			}

			public string Format(CodeInstruction instruction, int index)
			{
				return $"    IL_{index.ToString().PadLeft(_instructionIndexPadLength, '0')}: {instruction}";
			}
		}

		public static void LogDebugInstructionsFrom(this ManualLogSource source, CodeMatcher matcher)
		{
			string name = new StackTrace().GetFrame(1).GetMethod().Name;
			CodeInstructionFormatter @object = new CodeInstructionFormatter(matcher.Length);
			StringBuilder stringBuilder = new StringBuilder("'" + name + "' Matcher Instructions:\n").AppendLine(string.Join("\n", matcher.InstructionEnumeration().Select(@object.Format))).AppendLine("End of matcher instructions.");
			source.LogInfo((object)stringBuilder.ToString());
		}

		public static void LogDebugInstructionsFrom(this ManualLogSource source, IEnumerable<CodeInstruction> instructions)
		{
			string name = new StackTrace().GetFrame(1).GetMethod().Name;
			CodeInstruction[] array = instructions.ToArray();
			CodeInstructionFormatter @object = new CodeInstructionFormatter(array.Length);
			StringBuilder stringBuilder = new StringBuilder("'" + name + "' Enumerable Instructions:\n").AppendLine(string.Join("\n", array.Select(@object.Format))).AppendLine("End of matcher instructions.");
			source.LogInfo((object)stringBuilder.ToString());
		}
	}
}