Decompiled source of MaxTreeCutter v1.0.1

MaxTreeCutter.dll

Decompiled 2 weeks 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 BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Bossa.Dynamika.Utilities;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using UnityEngine;
using Utilities.Weapons;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MaxTreeCutter")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Nines (Natives)")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("MaxTreeCutter")]
[assembly: AssemblyTitle("MaxTreeCutter")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 MaxTreeCutter
{
	[BepInPlugin("MaxTreeCutter", "MaxTreeCutter", "1.0.1")]
	public class Plugin : BasePlugin
	{
		private class MaxTreeCutterSimpleChatCommands
		{
			public static string SetAoeRadiusOnImpact(float value)
			{
				if (value <= 0f)
				{
					MaxTreeCutter_AoeRadiusOnImpact.Value = (float)((ConfigEntryBase)MaxTreeCutter_AoeRadiusOnImpact).DefaultValue;
				}
				else
				{
					MaxTreeCutter_AoeRadiusOnImpact.Value = value;
				}
				return $"AOE radius on impact now set to {value}.";
			}
		}

		internal static ManualLogSource Log;

		internal static Harmony harmonyInstance;

		private static ConfigEntry<float> MaxTreeCutter_AoeRadiusOnImpact;

		public override void Load()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Log = ((BasePlugin)this).Log;
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("MaxTreeCutter");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
			MaxTreeCutter_AoeRadiusOnImpact = ((BasePlugin)this).Config.Bind<float>("MaxTreeCutter", "AoeRadiusOnImpact", 1.5f, "AoeRadiusOnImpact");
			harmonyInstance = Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
		}

		public override bool Unload()
		{
			Harmony obj = harmonyInstance;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			return true;
		}

		[HarmonyPatch(typeof(TreeCutter), "StartFiringHeld")]
		[HarmonyPrefix]
		public static bool TreeCutter_StartFiringHeld(TreeCutter __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Invalid comparison between Unknown and I4
			if ((int)__instance.CuttingProjectile.CurrentState == 4 && __instance.CuttingProjectile.IsValid)
			{
				return false;
			}
			if (__instance.CuttingProjectile.ProjectileAvailable)
			{
				if (MaxTreeCutter_AoeRadiusOnImpact.Value > 0f)
				{
					__instance._aoeRadiusOnImpact = MaxTreeCutter_AoeRadiusOnImpact.Value;
				}
				if ((int)__instance.CuttingProjectile.CurrentState == 5)
				{
					__instance._perfectCatchIndex = ((Il2CppArrayBase<PerfectCatchData>)(object)__instance._perfectCatchList).Length - 1;
				}
			}
			return true;
		}

		[HarmonyPatch(typeof(TreeCutter), "FixedUpdate")]
		[HarmonyPostfix]
		public static void TreeCutter_FixedUpdate(TreeCutter __instance)
		{
			if (((Behaviour)((UtilityItem)__instance).Character).enabled && __instance.CuttingProjectile.ProjectileAvailable && ((WeaponBase)__instance)._firingHeldStarted)
			{
				((WeaponBase)__instance).StartFiringHeld();
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MaxTreeCutter";

		public const string PLUGIN_NAME = "MaxTreeCutter";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}