Decompiled source of ScaredBaboon v1.0.1

ScaredBaboon.dll

Decompiled 2 months ago
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.Logging;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;

[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: AssemblyCompany("LCSpawnOnPlayerFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Ever got an Eyeless Dog or Forest Giant spawn directly on top of you? Yeah... This mod fixes that.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LCSpawnOnPlayerFix")]
[assembly: AssemblyTitle("LCSpawnOnPlayerFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[BepInPlugin("com.woah25.scaredbaboon", "Scared Baboon", "1.0.1")]
public class BaboonHawkFearMod : BaseUnityPlugin
{
	[HarmonyPatch(typeof(BaboonBirdAI), "DetectNoise")]
	public class BaboonBirdAI_detectnoise_patch
	{
		private static void Prefix(BaboonBirdAI __instance, Vector3 noisePosition, float noiseLoudness)
		{
			if (noiseLoudness > skibidiThreshold.Value)
			{
				Debug.Log((object)$"loud noise detected! baboon hawk is fleeing. (threshold: {skibidiThreshold.Value})");
				Traverse.Create((object)__instance).Method("SetAggressiveMode", new object[1] { 0 }).GetValue();
				Traverse.Create((object)__instance).Method("SwitchToBehaviourState", new object[1] { 1 }).GetValue();
			}
		}

		private static void Postfix(BaboonBirdAI __instance)
		{
			if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
			if ((Object)(object)((EnemyAI)__instance).agent != (Object)null && ((EnemyAI)__instance).agent.isOnNavMesh)
			{
				((EnemyAI)__instance).agent.isStopped = false;
			}
		}
	}

	private static ConfigEntry<float> skibidiThreshold;

	private void Awake()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		skibidiThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Settings", 0.8f, "The sound loudness threshold at which the Baboon Hawk flees ;) (0.0 to 1.0)");
		new Harmony("com.woah25.scaredbaboon").PatchAll();
	}
}
namespace ScaredBaboon
{
	[BepInPlugin("com.woah25.scaredbaboon", "Scared Baboon", "1.0.1")]
	internal class Plugin : BaseUnityPlugin
	{
		private const string PLUGIN_GUID = "com.woah25.scaredbaboon";

		private const string PLUGIN_NAME = "Scared Baboon";

		private const string PLUGIN_VERSION = "1.0.1";

		private readonly Harmony _harmony;

		internal static ManualLogSource Logger { get; private set; }

		protected Plugin()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			_harmony = new Harmony("com.woah25.scaredbaboon");
		}

		protected void Awake()
		{
			ManualLogSource logger = Logger;
			if (logger != null)
			{
				logger.LogInfo((object)"Plugin Scared Baboon is loaded!");
			}
			ManualLogSource logger2 = Logger;
			if (logger2 != null)
			{
				logger2.LogDebug((object)"Patching harmony...");
			}
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LCSpawnOnPlayerFix";

		public const string PLUGIN_NAME = "LCSpawnOnPlayerFix";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}