Decompiled source of Stable Zap Gun v1.1.0

StableZap.dll

Decompiled 6 months ago
using System;
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.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StableZap")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+43206f0475d7dae18e393eaa115cfd192399712f")]
[assembly: AssemblyProduct("StableZap")]
[assembly: AssemblyTitle("StableZap")]
[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;
		}
	}
}
public static class ZapGunConfig
{
	private static ConfigEntry<float> batteryUsageConfig;

	private static ConfigEntry<float> customCooldownConfig;

	public static void InitConfig(ConfigFile configFile)
	{
		batteryUsageConfig = configFile.Bind<float>("Settings", "BatteryUsage", 66f, "This is the amount of time that the zap gun will take to run out of battery. Lower values means less battery life. Values that equal 0 will cause the Zap Gun to die immediately upon use.");
		customCooldownConfig = configFile.Bind<float>("Settings", "CooldownDuration", 5f, "This is the amount of time you have to wait before using the Zap Gun again.");
	}

	public static float GetBatteryUsage()
	{
		return batteryUsageConfig.Value;
	}

	public static float GetCooldownDur()
	{
		return customCooldownConfig.Value;
	}
}
[HarmonyPatch(typeof(PatcherTool))]
internal class PatcherTool_BatteryInfPatch
{
	[HarmonyPatch("ItemActivate")]
	[HarmonyPrefix]
	private static void ModifyPatcherToolBatteryUsage(ref PatcherTool __instance)
	{
		float batteryUsage = ZapGunConfig.GetBatteryUsage();
		((GrabbableObject)__instance).itemProperties.batteryUsage = batteryUsage;
	}
}
[BepInPlugin("Project_BlueFlame.InfZapGun", "InfiniteZapGun", "1.0.0")]
public class ZapGunPatch : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Expected O, but got Unknown
		ZapGunConfig.InitConfig(((BaseUnityPlugin)this).Config);
		Harmony val = new Harmony("Project_BlueFlame.InfZapGun");
		val.PatchAll();
	}
}
[HarmonyPatch(typeof(PatcherTool), "ShiftBendRandomizer")]
internal class PatcherTool_ShiftBendRandomizer_Patch
{
	private static void Postfix(ref float ___bendMultiplier)
	{
		___bendMultiplier = 0f;
	}
}
[HarmonyPatch(typeof(GrabbableObject), "RequireCooldown")]
internal class GrabbableObject_RequireCooldown_Patch
{
	private static void Postfix(GrabbableObject __instance)
	{
		float cooldownDur = ZapGunConfig.GetCooldownDur();
		if (__instance is PatcherTool)
		{
			__instance.currentUseCooldown = cooldownDur;
		}
	}
}