Decompiled source of GadgetTweaks v1.2.0

BepInEx/plugins/ViViKo.GadgetTweaks.dll

Decompiled 6 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.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using ContentSettings.API;
using ContentSettings.API.Settings;
using GadgetTweaks.Patches;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Zorro.Settings;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("ViViKo.GadgetTweaks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("GadgetTweaks")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0")]
[assembly: AssemblyProduct("GadgetTweaks")]
[assembly: AssemblyTitle("ViViKo.GadgetTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.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 GadgetTweaks
{
	[ContentWarningPlugin("ViViKo.GadgetTweaks", "GadgetTweaks", false)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("ViViKo.GadgetTweaks", "GadgetTweaks", "1.2.0")]
	public class GadgetTweaks : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("ViViKo.GadgetTweaks");

		public static GadgetTweaks Instance;

		public bool infiniteShockCharge;

		public bool infiniteDefibCharge;

		public bool infiniteFlare;

		public bool infiniteFlashlight;

		public bool infinitePartyPopper;

		public bool infiniteRescueHookCharge;

		public bool infiniteNorgGun;

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			harmony.PatchAll();
			SettingsLoader.RegisterSetting("ViViKo Mods", "GadgetTweaks", (Setting)(object)new InfiniteShockChargeSetting());
			SettingsLoader.RegisterSetting("ViViKo Mods", "GadgetTweaks", (Setting)(object)new InfiniteDefibChargeSetting());
			SettingsLoader.RegisterSetting("ViViKo Mods", "GadgetTweaks", (Setting)(object)new InfiniteFlareSetting());
			SettingsLoader.RegisterSetting("ViViKo Mods", "GadgetTweaks", (Setting)(object)new InfiniteFlashlightSetting());
			SettingsLoader.RegisterSetting("ViViKo Mods", "GadgetTweaks", (Setting)(object)new InfinitePartyPopperSetting());
			SettingsLoader.RegisterSetting("ViViKo Mods", "GadgetTweaks", (Setting)(object)new InfiniteRescueHookChargeSetting());
			SettingsLoader.RegisterSetting("ViViKo Mods", "GadgetTweaks", (Setting)(object)new InfiniteNorgGunSetting());
			Logger.LogInfo((object)"Plugin GadgetTweaks v1.2.0 is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ViViKo.GadgetTweaks";

		public const string PLUGIN_NAME = "GadgetTweaks";

		public const string PLUGIN_VERSION = "1.2.0";
	}
}
namespace GadgetTweaks.Patches
{
	[HarmonyPatch(typeof(Defib))]
	public class DefibPatch
	{
		[HarmonyPatch("ConfigItem")]
		[HarmonyPrefix]
		private static void ConfigItemPatch(Defib __instance)
		{
			__instance.maxCharges = 30;
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void UpdatePatch(Defib __instance)
		{
			if (GadgetTweaks.Instance.infiniteDefibCharge)
			{
				__instance.m_batteryEntry.m_charge = __instance.m_batteryEntry.m_maxCharge;
			}
		}
	}
	public class InfiniteDefibChargeSetting : BoolSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			GadgetTweaks.Instance.infiniteDefibCharge = ((BoolSetting)this).Value;
		}

		public string GetDisplayName()
		{
			return "Infinite Defib";
		}

		protected override bool GetDefaultValue()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(Flare))]
	public class FlarePatch
	{
		[HarmonyPatch("ConfigItem")]
		[HarmonyPrefix]
		private static void ConfigItemPatch(Flare __instance)
		{
			__instance.maxLifeTime = 200f;
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void UpdatePatch(Flare __instance)
		{
			if (GadgetTweaks.Instance.infiniteFlare)
			{
				__instance.m_lifeTimeEntry.m_lifeTimeLeft = __instance.m_lifeTimeEntry.m_maxLifeTime;
			}
		}
	}
	public class InfiniteFlareSetting : BoolSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			GadgetTweaks.Instance.infiniteFlare = ((BoolSetting)this).Value;
		}

		public string GetDisplayName()
		{
			return "Infinite Flare";
		}

		protected override bool GetDefaultValue()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(Flashlight))]
	public class FlashlightPatch
	{
		[HarmonyPatch("ConfigItem")]
		[HarmonyPrefix]
		private static void ConfigItemPatch(Flashlight __instance)
		{
			__instance.maxCharge = 400f;
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void UpdatePatch(Flashlight __instance)
		{
			if (GadgetTweaks.Instance.infiniteFlashlight)
			{
				__instance.m_batteryEntry.m_charge = __instance.m_batteryEntry.m_maxCharge;
			}
		}
	}
	public class InfiniteFlashlightSetting : BoolSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			GadgetTweaks.Instance.infiniteFlashlight = ((BoolSetting)this).Value;
		}

		public string GetDisplayName()
		{
			return "Infinite Flashlight";
		}

		protected override bool GetDefaultValue()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(ItemHugger))]
	public class ItemHuggerPatch
	{
		[HarmonyPatch("ConfigItem")]
		[HarmonyPrefix]
		private static void ConfigItemPatch(ItemHugger __instance)
		{
			__instance.fullHealTime = 3.3f;
		}
	}
	[HarmonyPatch(typeof(NorgGun))]
	public class NorgGunPatch
	{
		[HarmonyPatch("ConfigItem")]
		[HarmonyPrefix]
		private static void ConfigItemPatch(NorgGun __instance)
		{
			__instance.maxCharges = 90;
		}

		[HarmonyPatch("LateUpdate")]
		[HarmonyPostfix]
		private static void LateUpdatePatch(NorgGun __instance)
		{
			if (GadgetTweaks.Instance.infiniteNorgGun)
			{
				__instance.m_batteryEntry.m_charge = __instance.m_batteryEntry.m_maxCharge;
			}
		}
	}
	public class InfiniteNorgGunSetting : BoolSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			GadgetTweaks.Instance.infiniteNorgGun = ((BoolSetting)this).Value;
		}

		public string GetDisplayName()
		{
			return "Infinite NorgGun Ammo";
		}

		protected override bool GetDefaultValue()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(PartyPopper))]
	public class PartyPopperPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(PartyPopper __instance)
		{
			if (GadgetTweaks.Instance.infinitePartyPopper && __instance.usedEntry.on)
			{
				__instance.usedEntry.on = false;
				__instance.stashAbleEntry.isStashAble = true;
				((ItemDataEntry)__instance.stashAbleEntry).SetDirty();
				((ItemDataEntry)__instance.usedEntry).SetDirty();
				__instance.wasUsedOnConfig = false;
			}
		}
	}
	public class InfinitePartyPopperSetting : BoolSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			GadgetTweaks.Instance.infinitePartyPopper = ((BoolSetting)this).Value;
		}

		public string GetDisplayName()
		{
			return "Infinite PartyPopper";
		}

		protected override bool GetDefaultValue()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(RescueHook))]
	public class RescueHookPatch
	{
		[HarmonyPatch("ConfigItem")]
		[HarmonyPrefix]
		private static void ConfigItemPatch(RescueHook __instance)
		{
			__instance.maxCharges = 15;
			__instance.range = 60;
		}

		[HarmonyPatch("LateUpdate")]
		[HarmonyPostfix]
		private static void LateUpdatePatch(RescueHook __instance)
		{
			if (GadgetTweaks.Instance.infiniteRescueHookCharge)
			{
				__instance.m_batteryEntry.m_charge = __instance.m_batteryEntry.m_maxCharge;
			}
		}
	}
	public class InfiniteRescueHookChargeSetting : BoolSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			GadgetTweaks.Instance.infiniteRescueHookCharge = ((BoolSetting)this).Value;
		}

		public string GetDisplayName()
		{
			return "Infinite RescueHook";
		}

		protected override bool GetDefaultValue()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(ShockStick))]
	public class ShockStickPatch
	{
		[HarmonyPatch("ConfigItem")]
		[HarmonyPrefix]
		private static void ConfigItemPatch(ShockStick __instance)
		{
			__instance.shockBatteryCost = 0f;
		}

		[HarmonyPatch("RPC_Shock")]
		[HarmonyPostfix]
		private static void RPC_ShockPatch(ShockStick __instance)
		{
			if (!__instance.m_onOffEntry.on)
			{
				__instance.m_onOffEntry.on = true;
				((ItemDataEntry)__instance.m_onOffEntry).SetDirty();
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void UpdatePatch(ShockStick __instance)
		{
			if (GadgetTweaks.Instance.infiniteShockCharge)
			{
				__instance.m_batteryEntry.m_charge = __instance.m_batteryEntry.m_maxCharge;
			}
		}
	}
	[HarmonyPatch(typeof(ShockStickTrigger))]
	public class ShockStickTriggerPatch
	{
		[HarmonyTranspiler]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static IEnumerable<CodeInstruction> TranspileMoveNext(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				CodeInstruction val = list[i];
				if (!(val.opcode != OpCodes.Ldc_R4) && (float)val.operand == 1f)
				{
					val.operand = 0.2f;
				}
			}
			return list.AsEnumerable();
		}
	}
	public class InfiniteShockChargeSetting : BoolSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			GadgetTweaks.Instance.infiniteShockCharge = ((BoolSetting)this).Value;
		}

		public string GetDisplayName()
		{
			return "Infinite ShockStick";
		}

		protected override bool GetDefaultValue()
		{
			return false;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}