Decompiled source of NoBotFriendlyFire v0.0.4

NoBotFriendlyFire.dll

Decompiled 5 days ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
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 BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using ChainedPuzzles;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("NoBotFriendlyFire")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NoBotFriendlyFire")]
[assembly: AssemblyTitle("NoBotFriendlyFire")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
		}
	}
}
namespace NoBotFriendlyFire
{
	[BepInPlugin("NoBotFriendlyFire", "NoBotFriendlyFire", "0.0.4")]
	public class Plugin : BasePlugin
	{
		public class NoBotFriendlyFire : MonoBehaviour
		{
			[CompilerGenerated]
			private sealed class <ScanCheck>d__1 : IEnumerator<object>, IDisposable, IEnumerator
			{
				private int <>1__state;

				private object <>2__current;

				private PlayerAgent <plr>5__2;

				object IEnumerator<object>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <ScanCheck>d__1(int <>1__state)
				{
					this.<>1__state = <>1__state;
				}

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<plr>5__2 = null;
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_004f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0059: Expected O, but got Unknown
					//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
					//IL_01ea: Expected O, but got Unknown
					//IL_0142: Unknown result type (might be due to invalid IL or missing references)
					//IL_014d: Unknown result type (might be due to invalid IL or missing references)
					//IL_017a: Unknown result type (might be due to invalid IL or missing references)
					//IL_017f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0186: Unknown result type (might be due to invalid IL or missing references)
					//IL_0190: Unknown result type (might be due to invalid IL or missing references)
					//IL_0198: Unknown result type (might be due to invalid IL or missing references)
					//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
					//IL_01b3: Expected O, but got Unknown
					Enumerator<ChainedPuzzleInstance> enumerator;
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<plr>5__2 = PlayerManager.GetLocalPlayerAgent();
						L.LogInfo((object)"warden scan checker running");
						goto IL_0040;
					case 1:
						<>1__state = -1;
						goto IL_0069;
					case 2:
						<>1__state = -1;
						goto IL_0040;
					case 3:
						{
							<>1__state = -1;
							<plr>5__2 = null;
							return false;
						}
						IL_0040:
						if (!SNet.IsMaster)
						{
							goto IL_0069;
						}
						goto IL_0070;
						IL_0069:
						if (!SNet.IsMaster)
						{
							<>2__current = (object)new WaitForSeconds(1f);
							<>1__state = 1;
							return true;
						}
						goto IL_0070;
						IL_0070:
						enumerator = ChainedPuzzleManager.Current.m_instances.GetEnumerator();
						while (enumerator.MoveNext())
						{
							ChainedPuzzleInstance current = enumerator.Current;
							if (!current.IsActive || !current.IsExitPuzzle)
							{
								continue;
							}
							CP_Bioscan_Core val = ((Il2CppObjectBase)((Il2CppArrayBase<iChainedPuzzleCore>)(object)current.m_chainedPuzzleCores)[0]).TryCast<CP_Bioscan_Core>();
							if (!val.PlayersOnScan.Contains(<plr>5__2))
							{
								continue;
							}
							if (!once)
							{
								L.LogInfo((object)"NoBotFriendlyFire - master is in exit scan, time to make closeby bots join in");
							}
							once = true;
							List<PlayerAgent> list = new List<PlayerAgent>();
							Enumerator<PlayerAgent> enumerator2 = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
							while (enumerator2.MoveNext())
							{
								PlayerAgent current2 = enumerator2.Current;
								if (current2.Owner.IsBot)
								{
									list.Add(current2);
								}
							}
							foreach (PlayerAgent item in list)
							{
								if (Vector3.Distance(((Component)item).transform.position, ((Component)current).transform.position) < 50f)
								{
									PlayerAIBot component = ((Component)item).GetComponent<PlayerAIBot>();
									if (!val.PlayersOnScan.Contains(item))
									{
										component.StartAction((Descriptor)new Descriptor(component)
										{
											DestinationPos = ((Component)val).transform.position,
											Bot = component,
											Haste = 999f,
											Prio = 999f
										});
									}
								}
							}
						}
						<>2__current = (object)new WaitForSeconds(0.5f);
						<>1__state = 2;
						return true;
					}
				}

				bool IEnumerator.MoveNext()
				{
					//ILSpy generated this explicit interface implementation from .override directive in MoveNext
					return this.MoveNext();
				}

				[DebuggerHidden]
				void IEnumerator.Reset()
				{
					throw new NotSupportedException();
				}
			}

			public void Initialize()
			{
				CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(ScanCheck()), (Action)null);
			}

			[IteratorStateMachine(typeof(<ScanCheck>d__1))]
			private IEnumerator ScanCheck()
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <ScanCheck>d__1(0);
			}
		}

		public static bool once;

		public static ManualLogSource L;

		public override void Load()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("NoBotFriendlyFire").PatchAll();
			LG_Factory.OnFactoryBuildDone += Action.op_Implicit((Action)((BasePlugin)this).AddComponent<NoBotFriendlyFire>().Initialize);
			L = ((BasePlugin)this).Log;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(BulletWeapon), "BulletHit")]
		public static bool BulletHit(BulletWeapon __instance, WeaponHitData weaponRayData, bool doDamage, float additionalDis = 0f, uint damageSearchID = 0u)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit rayHit = weaponRayData.rayHit;
			if ((Object)(object)((RaycastHit)(ref rayHit)).collider != (Object)null)
			{
				rayHit = weaponRayData.rayHit;
				if ((Object)(object)((Component)((RaycastHit)(ref rayHit)).collider).gameObject != (Object)null && weaponRayData.owner.Owner.IsBot)
				{
					rayHit = weaponRayData.rayHit;
					if (CustomExtensions.IsInLayerMask(((Component)((RaycastHit)(ref rayHit)).collider).gameObject, LayerMask.op_Implicit(LayerMask.GetMask(new string[1] { "PlayerSynced" }))))
					{
						doDamage = false;
						return false;
					}
				}
			}
			return true;
		}
	}
	[GeneratedCode("VersionInfoGenerator", "2.0.0+git50a4b1a-master")]
	[CompilerGenerated]
	internal static class VersionInfo
	{
		public const string RootNamespace = "NoBotFriendlyFire";

		public const string Version = "1.0.0";

		public const string VersionPrerelease = null;

		public const string VersionMetadata = null;

		public const string SemVer = "1.0.0";

		public const string GitRevShort = null;

		public const string GitRevLong = null;

		public const string GitBranch = null;

		public const string GitTag = null;

		public const bool GitIsDirty = false;
	}
}