Decompiled source of RuleZero v0.1.1

plugins/com.github.SyserQ.RuleZero.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.SyserQ.RuleZero")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1")]
[assembly: AssemblyProduct("com.github.SyserQ.RuleZero")]
[assembly: AssemblyTitle("RuleZero")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace RuleZero
{
	[BepInPlugin("com.github.SyserQ.RuleZero", "RuleZero", "0.1.1")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("com.github.SyserQ.RuleZero");

		public const string Id = "com.github.SyserQ.RuleZero";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "RuleZero";

		public static string Version => "0.1.1";

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			Log.LogInfo((object)("Plugin " + Name + " successfully patched!"));
		}
	}
}
namespace RuleZero.Patches
{
	[HarmonyPatch(typeof(Scoutmaster))]
	internal class ScoutmasterPatch
	{
		[HarmonyPatch("LookForTarget")]
		[HarmonyPrefix]
		private static bool LookForTargetPatch(Scoutmaster __instance)
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.ViableTargets() < 2 || __instance.sinceLookForTarget < 30f)
			{
				return false;
			}
			__instance.sinceLookForTarget = 0f;
			if (!(Random.value > 0.1f))
			{
				Character highestCharacter = __instance.GetHighestCharacter((Character)null);
				List<Character> allCharacters = Character.AllCharacters;
				Character val = null;
				foreach (Character item in allCharacters)
				{
					if (!item.isBot && !item.data.dead && !item.data.fullyPassedOut && !((Object)(object)item == (Object)(object)highestCharacter) && ((Object)(object)val == (Object)null || item.Center.y < val.Center.y))
					{
						val = item;
					}
				}
				Character val2 = val;
				if (highestCharacter.Center.y > val2.Center.y + __instance.attackHeightDelta && highestCharacter.Center.y < __instance.maxAggroHeight)
				{
					Plugin.Log.LogInfo((object)("Scoutmaster found target " + highestCharacter.characterName));
					__instance.SetCurrentTarget(highestCharacter, 0f);
				}
			}
			return false;
		}

		[HarmonyPatch("VerifyTarget")]
		[HarmonyPrefix]
		private static bool VerifyTargetPatch(Scoutmaster __instance)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.ViableTargets() < 2)
			{
				__instance.SetCurrentTarget((Character)null, 0f);
				return false;
			}
			Character highestCharacter = __instance.GetHighestCharacter((Character)null);
			List<Character> allCharacters = Character.AllCharacters;
			Character val = null;
			foreach (Character item in allCharacters)
			{
				if (!item.isBot && !item.data.dead && !item.data.fullyPassedOut && !((Object)(object)item == (Object)(object)highestCharacter) && ((Object)(object)val == (Object)null || item.Center.y < val.Center.y))
				{
					val = item;
				}
			}
			Character val2 = val;
			if (highestCharacter.Center.y > __instance.maxAggroHeight)
			{
				__instance.SetCurrentTarget((Character)null, 0f);
			}
			else if ((Object)(object)__instance.currentTarget != (Object)(object)highestCharacter)
			{
				__instance.SetCurrentTarget((Character)null, 0f);
			}
			else if (highestCharacter.Center.y < val2.Center.y + __instance.attackHeightDelta - 20f)
			{
				__instance.SetCurrentTarget((Character)null, 0f);
			}
			return false;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}