Decompiled source of NoBotFriendlyFire v0.0.3

NoBotFriendlyFire.dll

Decompiled 5 months 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.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.3")]
	public class Plugin : BasePlugin
	{
		public class NoBotFriendlyFire : MonoBehaviour
		{
			public void Initialize()
			{
				CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(ScanCheck()), (Action)null);
			}

			private IEnumerator ScanCheck()
			{
				PlayerAgent plr = PlayerManager.GetLocalPlayerAgent();
				Debug.Log(Object.op_Implicit("NoBotFriendlyFire - warden scan checker running"));
				while (true)
				{
					if (!SNet.IsMaster)
					{
						while (!SNet.IsMaster)
						{
							yield return (object)new WaitForSeconds(1f);
						}
					}
					List<ChainedPuzzleInstance> instances = ChainedPuzzleManager.Current.m_instances;
					bool flag = false;
					Enumerator<ChainedPuzzleInstance> enumerator = 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))
						{
							continue;
						}
						if (!flag)
						{
							Debug.Log(Object.op_Implicit("NoBotFriendlyFire - master is in exit scan, time to make closeby bots join in"));
						}
						flag = 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
									});
								}
							}
						}
					}
					yield return (object)new WaitForSeconds(0.5f);
				}
			}
		}

		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);
		}

		[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;
	}
}