Decompiled source of Bracken Jammer v1.0.1

LC_BrackenJammer.dll

Decompiled 9 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LC_BrackenJammer.Patches;
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("LC_BrackenJammer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LC_BrackenJammer")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ebe2ce90-2c0d-44b5-96df-e8066753b1d0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LC_BrackenJammer
{
	internal class ConfigurationController
	{
		private ConfigEntry<double> JammingDistanceCfg;

		internal double JammingDistance
		{
			get
			{
				if (JammingDistanceCfg.Value == 0.0)
				{
					return (double)((ConfigEntryBase)JammingDistanceCfg).DefaultValue;
				}
				return JammingDistanceCfg.Value;
			}
			set
			{
				JammingDistanceCfg.Value = value;
			}
		}

		public ConfigurationController(ConfigFile Config)
		{
			JammingDistanceCfg = Config.Bind<double>("LC_BrackenJammer Settings", "Jamming Distance", 70.0, "The minimum Distance for the jammer to run");
		}
	}
	[BepInPlugin("Forellma.LCBrackenJammer", "LC Bracken Jammer", "1.0.0.0")]
	public class BrackenJammer : BaseUnityPlugin
	{
		private const string modGUID = "Forellma.LCBrackenJammer";

		private const string modName = "LC Bracken Jammer";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("Forellma.LCBrackenJammer");

		internal static BrackenJammer Instance;

		internal static ManualLogSource mls;

		internal ConfigurationController ConfigManager;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Forellma.LCBrackenJammer");
			mls.LogInfo((object)"Mod has started");
			harmony.PatchAll(typeof(BrackenJammer));
			harmony.PatchAll(typeof(WalkieTalkiePatch));
			ConfigManager = new ConfigurationController(((BaseUnityPlugin)this).Config);
			mls = ((BaseUnityPlugin)this).Logger;
		}
	}
}
namespace LC_BrackenJammer.Patches
{
	[HarmonyPatch(typeof(WalkieTalkie))]
	internal class WalkieTalkiePatch
	{
		[HarmonyPatch("SetLocalClientSpeaking")]
		[HarmonyPrefix]
		private static bool jamWalkie1(ref WalkieTalkie __instance)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			FlowermanAI val = Object.FindObjectOfType<FlowermanAI>();
			if ((Object)(object)val != (Object)null)
			{
				Vector3 position = ((Component)val).transform.position;
				Vector3 itemFloorPosition = ((GrabbableObject)__instance).GetItemFloorPosition(default(Vector3));
				if ((double)Vector3.Distance(itemFloorPosition, position) <= BrackenJammer.Instance.ConfigManager.JammingDistance)
				{
					return false;
				}
				return true;
			}
			return true;
		}

		[HarmonyPatch("ItemActivate")]
		[HarmonyPrefix]
		private static void figuringOutWalkies1()
		{
			BrackenJammer.mls.LogInfo((object)"ItemActivate");
		}

		[HarmonyPatch("SetPlayerSpeakingOnWalkieTalkieServerRpc")]
		[HarmonyPrefix]
		private static void figuringOutWalkies2()
		{
			BrackenJammer.mls.LogInfo((object)"SetPlayerSpeakingOnWalkieTalkieServerRpc");
		}

		[HarmonyPatch("PlayerHoldingWalkieTalkieButton")]
		[HarmonyPrefix]
		private static void figuringOutWalkies3()
		{
			BrackenJammer.mls.LogInfo((object)"PlayerHoldingWalkieTalkieButton");
		}
	}
}