Decompiled source of Snipers v0.0.6

Plugins/Snipers.dll

Decompiled 3 weeks ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AIGraph;
using Agents;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using Enemies;
using FluffyUnderware.DevTools.Extensions;
using GTFO.API;
using GameData;
using Gear;
using Globals;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using LevelGeneration;
using Localization;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using Snipers.BotTag;
using Snipers.TagObject;
using TMPro;
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("Snipers")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Snipers")]
[assembly: AssemblyTitle("Snipers")]
[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 Snipers
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Snipers", "Snipers", "0.0.8")]
	public class Plugin : BasePlugin
	{
		public struct SniperNetInfo
		{
			public int FUNC;

			public int SLOT;

			public int TAGID;

			public int ENEMYID;

			public bool FIRE;

			public static string NetworkIdentity => "SniperNetInfo";

			public SniperNetInfo(int func, int slot, int tagid, int enemyid, bool fire)
			{
				this = default(SniperNetInfo);
				FUNC = func;
				SLOT = slot;
				TAGID = tagid;
				ENEMYID = enemyid;
				FIRE = fire;
				Debug.Log(Object.op_Implicit($"Snipers - sent a package {func} - {slot} - {tagid} - {enemyid} - {fire}"));
			}
		}

		public struct SniperInfo
		{
			public int FUNC;

			public int SLOT;

			public int TAGID;

			public int ENEMYID;

			public bool FIRE;

			public SniperInfo(int func, int slot, int tagid, int enemyid, bool fire)
			{
				this = default(SniperInfo);
				FUNC = func;
				SLOT = slot;
				TAGID = tagid;
				ENEMYID = enemyid;
				FIRE = fire;
			}

			public SniperInfo(SniperNetInfo network)
			{
				this = default(SniperInfo);
				FUNC = network.FUNC;
				SLOT = network.SLOT;
				TAGID = network.TAGID;
				ENEMYID = network.ENEMYID;
				FIRE = network.FIRE;
			}
		}

		public class Snipers : MonoBehaviour
		{
			public void BotTags()
			{
				CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(BotTagging()), (Action)null);
			}

			public void Initialize()
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Invalid comparison between Unknown and I4
				//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: Invalid comparison between Unknown and I4
				Tag tag = new GameObject().AddComponent<Tag>();
				Tag tag2 = new GameObject().AddComponent<Tag>();
				Tag tag3 = new GameObject().AddComponent<Tag>();
				Tag tag4 = new GameObject().AddComponent<Tag>();
				tag.index = 0;
				tag2.index = 1;
				tag3.index = 2;
				tag4.index = 3;
				tags = new List<Tag> { tag, tag2, tag3, tag4 };
				foreach (Tag tag5 in tags)
				{
					((Component)tag5).transform.position = piilo;
				}
				pActiveExpedition activeExpeditionData = RundownManager.GetActiveExpeditionData();
				if ((int)activeExpeditionData.tier == 1 && activeExpeditionData.expeditionIndex == 0)
				{
					CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(Tutorial()), (Action)null);
				}
				if ((int)activeExpeditionData.tier == 1 && activeExpeditionData.expeditionIndex == 1)
				{
					CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(Level()), (Action)null);
				}
			}

			private void Start()
			{
				Debug.Log(Object.op_Implicit("Snipers - plugin active"));
			}

			private void Update()
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Invalid comparison between Unknown and I4
				//IL_0024: 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_02cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_015d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0162: Unknown result type (might be due to invalid IL or missing references)
				if ((int)FocusStateManager.CurrentState != 4)
				{
					return;
				}
				if (SNet.IsMaster && Input.GetKeyDown((KeyCode)120))
				{
					RaycastHit val = default(RaycastHit);
					Physics.Raycast(Camera.current.ScreenPointToRay(Input.mousePosition), ref val);
					Debug.Log(Object.op_Implicit("x pressed, hit " + ((Object)((Component)((RaycastHit)(ref val)).collider).gameObject).name));
					EnemyAgent componentInParent = ((Component)((RaycastHit)(ref val)).collider).gameObject.GetComponentInParent<EnemyAgent>();
					if ((Object)(object)componentInParent != (Object)null)
					{
						pPlayerData_Session session;
						foreach (Tag tag in tags)
						{
							if ((Object)(object)tag.TaggedEnemy == (Object)(object)componentInParent)
							{
								session = SNet.LocalPlayer.Session;
								int playerSlotIndex = ((pPlayerData_Session)(ref session)).playerSlotIndex;
								NetworkAPI.InvokeEvent<SniperNetInfo>("SniperNetInfo", new SniperNetInfo(1, playerSlotIndex, tag.index, ((Agent)componentInParent).m_replicator.Key + 1, fire: false), (SNet_ChannelType)2);
								tag.UntagEnemy();
								Debug.Log(Object.op_Implicit($"Snipers - enemy untagged, released tag {tag.index}"));
								return;
							}
						}
						foreach (Tag tag2 in tags)
						{
							if (tag2.Free)
							{
								session = SNet.LocalPlayer.Session;
								int playerSlotIndex2 = ((pPlayerData_Session)(ref session)).playerSlotIndex;
								NetworkAPI.InvokeEvent<SniperNetInfo>("SniperNetInfo", new SniperNetInfo(0, playerSlotIndex2, tag2.index, ((Agent)componentInParent).m_replicator.Key + 1, fire: false), (SNet_ChannelType)2);
								tag2.TagEnemy(componentInParent);
								Debug.Log(Object.op_Implicit($"Snipers - enemy tagged with {tag2.index}"));
								return;
							}
						}
						Debug.Log(Object.op_Implicit("Snipers - no available tags to tag enemy"));
					}
				}
				Enumerator<PlayerAgent> enumerator2;
				if (SNet.IsMaster && Input.GetKeyDown((KeyCode)122))
				{
					List<PlayerAgent> list = new List<PlayerAgent>();
					enumerator2 = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
					while (enumerator2.MoveNext())
					{
						PlayerAgent current3 = enumerator2.Current;
						if (current3.Owner.IsBot)
						{
							list.Add(current3);
						}
					}
					foreach (PlayerAgent item in list)
					{
						BotTagging component = ((Component)item).GetComponent<BotTagging>();
						if (component.aiming)
						{
							component.Fire();
						}
					}
					NetworkAPI.InvokeEvent<SniperNetInfo>("SniperNetInfo", new SniperNetInfo(4, 0, 0, 0, fire: true), (SNet_ChannelType)2);
				}
				if (!SNet.IsMaster || !Input.GetKeyDown((KeyCode)323))
				{
					return;
				}
				RaycastHit val2 = default(RaycastHit);
				Physics.Raycast(Camera.current.ScreenPointToRay(Input.mousePosition), ref val2);
				if (!((Object)(object)((Component)((RaycastHit)(ref val2)).collider).gameObject.GetComponentInParent<EnemyAgent>() != (Object)null))
				{
					return;
				}
				List<PlayerAgent> list2 = new List<PlayerAgent>();
				enumerator2 = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
				while (enumerator2.MoveNext())
				{
					PlayerAgent current4 = enumerator2.Current;
					if (current4.Owner.IsBot)
					{
						list2.Add(current4);
					}
				}
				foreach (PlayerAgent item2 in list2)
				{
					BotTagging component2 = ((Component)item2).GetComponent<BotTagging>();
					if (component2.aiming)
					{
						component2.Fire();
					}
				}
				NetworkAPI.InvokeEvent<SniperNetInfo>("SniperNetInfo", new SniperNetInfo(4, 0, 0, 0, fire: true), (SNet_ChannelType)2);
			}

			public static void ReceiveSniperNetInfo(ulong sender, SniperNetInfo netInfo)
			{
				//IL_017f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0181: Unknown result type (might be due to invalid IL or missing references)
				//IL_0220: Unknown result type (might be due to invalid IL or missing references)
				//IL_0225: Unknown result type (might be due to invalid IL or missing references)
				EnemyAgent val = null;
				Debug.Log(Object.op_Implicit("received data from sender " + sender + ": func:" + netInfo.FUNC + " slot:" + netInfo.SLOT + " tagid:" + netInfo.TAGID + " enemyid:" + netInfo.ENEMYID + " fire:" + netInfo.FIRE));
				int num = 4;
				for (int i = 0; i < PlayerManager.PlayerAgentsInLevel.Count; i++)
				{
					PlayerAgent val2 = PlayerManager.PlayerAgentsInLevel[i];
					if (sender == ((Agent)val2).m_replicator.OwningPlayer.Lookup)
					{
						num = i;
					}
				}
				if (num == 4)
				{
					return;
				}
				PlayerAgent val3 = PlayerManager.PlayerAgentsInLevel[num];
				Debug.Log(Object.op_Implicit($"Snipers - player {val3.PlayerName} is sender {val3.Sync.Replicator.OwningPlayer.Lookup} in slot {val3.PlayerSlotIndex}"));
				if (netInfo.ENEMYID > 0)
				{
					pReplicator pRep = default(pReplicator);
					pRep.keyPlusOne = (ushort)netInfo.ENEMYID;
					pAgent val4 = default(pAgent);
					val4.pRep = pRep;
					Agent val5 = default(Agent);
					((pAgent)(ref val4)).TryGet(ref val5);
					val = ((Il2CppObjectBase)val5).TryCast<EnemyAgent>();
				}
				Tag tag = tags[netInfo.TAGID];
				if (netInfo.FUNC == 0 && (Object)(object)val != (Object)null)
				{
					tag.TagEnemy(val);
				}
				if (netInfo.FUNC == 1)
				{
					tag.UntagEnemy();
				}
				if (netInfo.FUNC == 2)
				{
					tag.AssignAimer(netInfo.SLOT);
				}
				if (netInfo.FUNC == 3)
				{
					tag.UnassignAimer(netInfo.SLOT);
				}
				if (SNet.IsMaster || netInfo.FUNC != 4 || !netInfo.FIRE)
				{
					return;
				}
				RaycastHit val6 = default(RaycastHit);
				Physics.Raycast(Camera.current.ScreenPointToRay(Input.mousePosition), ref val6);
				EnemyAgent componentInParent = ((Component)((RaycastHit)(ref val6)).collider).gameObject.GetComponentInParent<EnemyAgent>();
				if (!((Object)(object)componentInParent != (Object)null))
				{
					return;
				}
				foreach (Tag tag2 in tags)
				{
					if ((Object)(object)tag2.TaggedEnemy == (Object)(object)componentInParent)
					{
						BulletWeapon val7 = ((Il2CppObjectBase)PlayerBackpackManager.Current.m_localPlayer.Inventory.WieldedItem).TryCast<BulletWeapon>();
						if ((Object)(object)val7 != (Object)null && val7.m_clip > 0)
						{
							val7.Fire(true);
						}
					}
				}
			}

			private static IEnumerator BotTagging()
			{
				while (!SNet.IsMaster)
				{
					yield return (object)new WaitForSeconds(5f);
				}
				for (int slot = 0; slot < 4; slot++)
				{
					SlotPermission orig = ((Il2CppArrayBase<SlotPermission>)(object)SNet.Slots.m_playerSlotPermissions)[slot];
					if ((int)orig == 2 || (int)orig == 3)
					{
						((Il2CppArrayBase<SlotPermission>)(object)SNet.Slots.m_playerSlotPermissions)[slot] = (SlotPermission)1;
						yield return (object)new WaitForSeconds(1f);
						((Il2CppArrayBase<SlotPermission>)(object)SNet.Slots.m_playerSlotPermissions)[slot] = orig;
					}
				}
				yield return (object)new WaitForSeconds(5f);
				while (SNet.IsMaster)
				{
					List<PlayerAgent> list = new List<PlayerAgent>();
					Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
					while (enumerator.MoveNext())
					{
						PlayerAgent current = enumerator.Current;
						if (current.Owner.IsBot)
						{
							list.Add(current);
						}
					}
					foreach (PlayerAgent item in list)
					{
						if ((Object)(object)((Component)item).GetComponent<BotTagging>() == (Object)null)
						{
							((Component)item).gameObject.AddComponent<BotTagging>();
						}
					}
					foreach (Tag tag in tags)
					{
						if (tag.Free || !((Object)(object)tag.assignedbot == (Object)null) || list.Count <= 0)
						{
							continue;
						}
						foreach (PlayerAgent item2 in list)
						{
							if ((Object)(object)item2 != (Object)null && (Object)(object)((Component)item2).GetComponent<BotTagging>().aimtag == (Object)null && (Object)(object)tag.assignedbot == (Object)null && (Object)(object)item2 != (Object)null)
							{
								tag.assignedbot = item2;
								((Component)item2).GetComponent<BotTagging>().aimtag = tag;
								((Component)item2).GetComponent<BotTagging>().aimtagindex = tag.index;
								((Component)item2).GetComponent<BotTagging>().tagtime = Time.realtimeSinceStartup;
								Debug.Log(Object.op_Implicit($"Snipers - bot {item2.PlayerName} has been assigned tag {tag.index}"));
							}
						}
					}
					yield return (object)new WaitForSeconds(1f);
				}
			}

			private static IEnumerator Tutorial()
			{
				Global.EnemyPlayerDetectionEnabled = false;
				AIG_CourseNode node = Builder.CurrentFloor.allZones[0].m_courseNodes[1];
				while (true)
				{
					if (SNet.IsMaster)
					{
						Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
						while (enumerator.MoveNext())
						{
							PlayerBackpackManager.GiveAmmoToPlayer(((Agent)enumerator.Current).m_replicator.OwningPlayer, 1f, 1f, 1f);
						}
						EnemyAllocator.Current.SpawnEnemy(28u, node, (AgentMode)4, new Vector3(-6f, -2.2f, 60f), new Quaternion(0f, 0f, 0f, 0f), (EnemyGroup)null, -1);
						EnemyAllocator.Current.SpawnEnemy(28u, node, (AgentMode)4, new Vector3(-2f, -2.2f, 60f), new Quaternion(0f, 0f, 0f, 0f), (EnemyGroup)null, -1);
						EnemyAllocator.Current.SpawnEnemy(28u, node, (AgentMode)4, new Vector3(2f, -2.2f, 60f), new Quaternion(0f, 0f, 0f, 0f), (EnemyGroup)null, -1);
						EnemyAllocator.Current.SpawnEnemy(28u, node, (AgentMode)4, new Vector3(6f, -2.2f, 60f), new Quaternion(0f, 0f, 0f, 0f), (EnemyGroup)null, -1);
						yield return (object)new WaitForSeconds(1f);
					}
					while (node.m_enemiesInNode.Count > 0)
					{
						yield return (object)new WaitForSeconds(3f);
					}
					yield return (object)new WaitForSeconds(1f);
				}
			}

			private static IEnumerator Level()
			{
				Global.EnemyPlayerDetectionEnabled = true;
				LocalizedText teksti = new LocalizedText();
				yield return (object)new WaitForSeconds(5f);
				teksti.UntranslatedText = "cleanup enemies to advance into next area";
				WorldEventManager.ExecuteEvent(new WardenObjectiveEventData
				{
					Type = (eWardenObjectiveEventType)0,
					WardenIntel = teksti
				}, 0f);
				Dimension val = default(Dimension);
				Builder.CurrentFloor.GetDimension((eDimensionIndex)1, ref val);
				foreach (AIG_CourseNode item in new List<AIG_CourseNode>
				{
					val.CourseGraph.m_nodes[0],
					val.CourseGraph.m_nodes[2],
					val.CourseGraph.m_nodes[3],
					val.CourseGraph.m_nodes[4]
				})
				{
					Il2CppArrayBase<Transform> componentsInChildren = item.gameObject.GetComponentsInChildren<Transform>(true);
					if (componentsInChildren == null)
					{
						continue;
					}
					foreach (Transform item2 in componentsInChildren)
					{
						if (((Component)item2).gameObject.transform.position.y > 207.7f && ((Component)item2).gameObject.active)
						{
							((Component)item2).gameObject.active = false;
						}
					}
				}
				bool warped = false;
				if (!SNet.IsMaster)
				{
					while (!SNet.IsMaster)
					{
						if (WorldEventManager.GetCondition(1) && !warped)
						{
							teksti.UntranslatedText = "continue mission upstairs";
							WorldEventManager.ExecuteEvent(new WardenObjectiveEventData
							{
								Type = (eWardenObjectiveEventType)8,
								DimensionIndex = (eDimensionIndex)1,
								WardenIntel = teksti
							}, 0f);
							WorldEventManager.ExecuteEvent(new WardenObjectiveEventData
							{
								Type = (eWardenObjectiveEventType)6,
								FogSetting = 18u,
								DimensionIndex = (eDimensionIndex)1
							}, 0f);
							yield return (object)new WaitForSeconds(1f);
							WorldEventManager.ExecuteEvent(new WardenObjectiveEventData
							{
								Type = (eWardenObjectiveEventType)6,
								FogSetting = 18u,
								DimensionIndex = (eDimensionIndex)1
							}, 0f);
							yield return (object)new WaitForSeconds(1f);
							EffectLight obj = ((Component)PlayerManager.GetLocalPlayerAgent()).gameObject.AddComponent<EffectLight>();
							((LightBase)obj).Intensity = 0.2f;
							((LightBase)obj).Range = 200f;
							((LightBase)obj).Color = new Color(1f, 1f, 0.78431f) * 0.65f;
							warped = true;
						}
						if (WorldEventManager.GetCondition(2))
						{
							WardenObjectiveManager.ForceCompleteObjective((LG_LayerType)0);
							WorldEventManager.ExecuteEvent(new WardenObjectiveEventData
							{
								Type = (eWardenObjectiveEventType)12,
								Layer = (LG_LayerType)0
							}, 0f);
							SNet.Sync.SessionCommand((eSessionCommandType)3, 2);
							yield break;
						}
						yield return (object)new WaitForSeconds(5f);
					}
				}
				for (int i = 0; i < Builder.CurrentFloor.allZones.Count; i++)
				{
					bool flag = false;
					List<EnemyAgent> enemiesinzone = new List<EnemyAgent>();
					LG_Zone zone = Builder.CurrentFloor.allZones[i];
					Enumerator<AIG_CourseNode> enumerator3 = zone.m_courseNodes.GetEnumerator();
					while (enumerator3.MoveNext())
					{
						Enumerator<EnemyAgent> enumerator4 = enumerator3.Current.m_enemiesInNode.GetEnumerator();
						while (enumerator4.MoveNext())
						{
							EnemyAgent current2 = enumerator4.Current;
							enemiesinzone.Add(current2);
						}
					}
					while (!flag)
					{
						int num = 0;
						foreach (EnemyAgent item3 in enemiesinzone)
						{
							if ((Object)(object)item3 != (Object)null && ((Agent)item3).Alive)
							{
								num++;
							}
						}
						if (num == 0)
						{
							flag = true;
						}
						yield return (object)new WaitForSeconds(1f);
					}
					int nextindex = i + 1;
					if ((int)zone.DimensionIndex == 0 && i < 8)
					{
						teksti.UntranslatedText = "next zone reachable";
						WorldEventManager.ExecuteEvent(new WardenObjectiveEventData
						{
							Type = (eWardenObjectiveEventType)1,
							LocalIndex = (eLocalZoneIndex)nextindex,
							WardenIntel = teksti
						}, 0f);
					}
					if ((int)zone.DimensionIndex == 0 && nextindex == 9)
					{
						WorldEventManager.SetCondition(1, true);
						teksti.UntranslatedText = "continue mission upstairs";
						WorldEventManager.ExecuteEvent(new WardenObjectiveEventData
						{
							Type = (eWardenObjectiveEventType)8,
							DimensionIndex = (eDimensionIndex)1,
							WardenIntel = teksti
						}, 0f);
						WorldEventManager.ExecuteEvent(new WardenObjectiveEventData
						{
							Type = (eWardenObjectiveEventType)6,
							FogSetting = 18u,
							DimensionIndex = (eDimensionIndex)1
						}, 0f);
						yield return (object)new WaitForSeconds(1f);
						WorldEventManager.ExecuteEvent(new WardenObjectiveEventData
						{
							Type = (eWardenObjectiveEventType)6,
							FogSetting = 18u,
							DimensionIndex = (eDimensionIndex)1
						}, 0f);
						EffectLight obj2 = ((Component)PlayerManager.GetLocalPlayerAgent()).gameObject.AddComponent<EffectLight>();
						((LightBase)obj2).Intensity = 0.2f;
						((LightBase)obj2).Range = 200f;
						((LightBase)obj2).Color = new Color(1f, 1f, 0.78431f) * 0.65f;
						yield return (object)new WaitForSeconds(1f);
					}
					if ((int)zone.DimensionIndex == 1 && nextindex == 13)
					{
						teksti.UntranslatedText = "congratulations, mission accomplished";
						WorldEventManager.ExecuteEvent(new WardenObjectiveEventData
						{
							Type = (eWardenObjectiveEventType)0,
							WardenIntel = teksti
						}, 0f);
						yield return (object)new WaitForSeconds(4f);
						WorldEventManager.SetCondition(2, true);
						WardenObjectiveManager.ForceCompleteObjective((LG_LayerType)0);
						WorldEventManager.ExecuteEvent(new WardenObjectiveEventData
						{
							Type = (eWardenObjectiveEventType)12,
							Layer = (LG_LayerType)0
						}, 0f);
						SNet.Sync.SessionCommand((eSessionCommandType)3, 2);
						break;
					}
					if ((int)zone.DimensionIndex == 1 && nextindex > 8)
					{
						teksti.UntranslatedText = "next zone reachable";
						WorldEventManager.ExecuteEvent(new WardenObjectiveEventData
						{
							Type = (eWardenObjectiveEventType)1,
							DimensionIndex = (eDimensionIndex)1,
							LocalIndex = (eLocalZoneIndex)(nextindex - 9),
							WardenIntel = teksti
						}, 0f);
					}
				}
			}
		}

		[HarmonyPatch]
		private class SniperPatches
		{
			[HarmonyPrefix]
			[HarmonyPatch(typeof(AIG_GeomorphNodeVolume), "TryGetGeomorphVolume")]
			public static bool Prefix(AIG_GeomorphNodeVolume __instance, int floorNR, eDimensionIndex dimensionIndex, Vector3 pos)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Invalid comparison between Unknown and I4
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				if ((int)dimensionIndex == 1 && pos.z > 290f)
				{
					return false;
				}
				return true;
			}
		}

		public static Dictionary<Tag, EnemyAgent> tagged = new Dictionary<Tag, EnemyAgent>();

		public static List<Tag> tags = new List<Tag>();

		public static Vector3 piilo = new Vector3(0f, -50f, 0f);

		public override void Load()
		{
			//IL_0005: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("snipers").PatchAll();
			ClassInjector.RegisterTypeInIl2Cpp<Tag>();
			ClassInjector.RegisterTypeInIl2Cpp<BotTagging>();
			new ConfigFile(Path.Combine(Paths.ConfigPath, "Snipers.cfg"), true);
			new Harmony("Snipers").PatchAll();
			NetworkAPI.RegisterEvent<SniperNetInfo>(SniperNetInfo.NetworkIdentity, (Action<ulong, SniperNetInfo>)Snipers.ReceiveSniperNetInfo);
			Snipers @object = ((BasePlugin)this).AddComponent<Snipers>();
			EventAPI.OnExpeditionStarted += @object.Initialize;
			EventAPI.OnExpeditionStarted += @object.BotTags;
		}
	}
	[GeneratedCode("VersionInfoGenerator", "2.0.0+git50a4b1a-master")]
	[CompilerGenerated]
	internal static class VersionInfo
	{
		public const string RootNamespace = "Snipers";

		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;
	}
}
namespace Snipers.TagObject
{
	public class Tag : MonoBehaviour
	{
		public Dictionary<int, bool> aim = new Dictionary<int, bool>
		{
			{ 0, false },
			{ 1, false },
			{ 2, false },
			{ 3, false }
		};

		public int index;

		public EnemyAgent? TaggedEnemy;

		private Dam_EnemyDamageLimb head;

		public bool Free = true;

		public bool aimed;

		public TextMeshPro tm;

		public PlayerAgent plr = PlayerManager.GetLocalPlayerAgent();

		public PlayerAgent assignedbot;

		private bool Ready;

		private int myslot;

		private void Update()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Invalid comparison between Unknown and I4
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			if ((int)FocusStateManager.CurrentState != 4 || Free)
			{
				return;
			}
			EnemyAgent taggedEnemy = TaggedEnemy;
			Dam_EnemyDamageLimb headLimb = taggedEnemy.m_headLimb;
			aimed = false;
			foreach (KeyValuePair<int, bool> item in aim)
			{
				if (item.Value)
				{
					aimed = true;
				}
			}
			if (!aimed)
			{
				((TMP_Text)tm).text = "<color=red>v</color>";
			}
			if (aimed)
			{
				((TMP_Text)tm).text = "<color=green>v</color>";
				RaycastHit val = default(RaycastHit);
				foreach (KeyValuePair<int, bool> item2 in aim)
				{
					if (!item2.Value)
					{
						continue;
					}
					PlayerAgent playerAgentInSlot = PlayerManager.Current.GetPlayerAgentInSlot(item2.Key);
					if (item2.Key == myslot)
					{
						if ((Object)(object)playerAgentInSlot.Inventory.WieldedItem.GearPartHolder.SightPart != (Object)null)
						{
							Physics.Raycast(Camera.current.ScreenPointToRay(Input.mousePosition), ref val);
							DebugDraw3D.DrawCone(playerAgentInSlot.Inventory.WieldedItem.GearPartHolder.SightPart.transform.position, ((RaycastHit)(ref val)).point, 0.02f, Color.red, 0f, "");
						}
					}
					else if ((Object)(object)playerAgentInSlot.Inventory.WieldedItem.GearPartHolder.SightPart != (Object)null)
					{
						DebugDraw3D.DrawCone(playerAgentInSlot.Inventory.WieldedItem.GearPartHolder.SightPart.transform.position, ((Component)head).transform.position, 0.02f, Color.red, 0f, "");
					}
				}
			}
			if ((Object)(object)taggedEnemy == (Object)null)
			{
				UntagEnemy();
			}
			if ((Object)(object)taggedEnemy != (Object)null && (int)FocusStateManager.CurrentState == 4)
			{
				RaycastHit val2 = default(RaycastHit);
				Physics.Raycast(Camera.current.ScreenPointToRay(Input.mousePosition), ref val2);
				EnemyAgent componentInParent = ((Component)((RaycastHit)(ref val2)).collider).gameObject.GetComponentInParent<EnemyAgent>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					if ((Object)(object)componentInParent == (Object)(object)taggedEnemy)
					{
						aim[myslot] = true;
						if (!Ready)
						{
							NetworkAPI.InvokeEvent<Plugin.SniperNetInfo>("SniperNetInfo", new Plugin.SniperNetInfo(2, myslot, index, ((Agent)taggedEnemy).m_replicator.Key + 1, fire: false), (SNet_ChannelType)2);
						}
						Ready = true;
					}
					if ((Object)(object)componentInParent != (Object)(object)taggedEnemy)
					{
						aim[myslot] = false;
					}
				}
				if ((Object)(object)componentInParent == (Object)null)
				{
					aim[myslot] = false;
					if (Ready)
					{
						NetworkAPI.InvokeEvent<Plugin.SniperNetInfo>("SniperNetInfo", new Plugin.SniperNetInfo(3, myslot, index, ((Agent)taggedEnemy).m_replicator.Key + 1, fire: false), (SNet_ChannelType)2);
					}
					Ready = false;
				}
			}
			((Component)this).transform.position = new Vector3(((Component)headLimb).transform.position.x, ((Component)headLimb).transform.position.y + 0.8f, ((Component)headLimb).transform.position.z);
			Camera currentCamera = CameraManager.GetCurrentCamera();
			Vector3 val3 = ((Component)this).transform.position - ((Component)currentCamera).transform.position;
			Vector3 normalized = ((Vector3)(ref val3)).normalized;
			normalized.y = 0f;
			((Component)this).transform.rotation = Quaternion.LookRotation(normalized);
			if (!((Agent)taggedEnemy).Alive)
			{
				UntagEnemy();
			}
		}

		public void TagEnemy(EnemyAgent enemy)
		{
			Free = false;
			TaggedEnemy = enemy;
			head = enemy.m_headLimb;
		}

		public void UntagEnemy()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 4; i++)
			{
				aim[i] = false;
			}
			aimed = false;
			((Component)this).transform.position = Plugin.piilo;
			Free = true;
			TaggedEnemy = null;
			head = null;
			((TMP_Text)tm).text = "<color=red>v</color>";
			if ((Object)(object)assignedbot != (Object)null)
			{
				((Component)assignedbot).GetComponent<BotTagging>().aimtag = null;
				((Component)assignedbot).GetComponent<BotTagging>().tagtime = 0f;
				((Component)assignedbot).GetComponent<BotTagging>().hasfired = false;
				assignedbot = null;
			}
		}

		public void AssignAimer(int slot)
		{
			aim[slot] = true;
		}

		public void UnassignAimer(int slot)
		{
			aim[slot] = false;
		}

		public void Awake()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = ComponentExt.AddChildGameObject((Component)(object)this, "jee");
			val.AddComponent<MeshRenderer>();
			MeshFilter val2 = val.AddComponent<MeshFilter>();
			Mesh val3 = new Mesh();
			Vector3[] array = (Vector3[])(object)new Vector3[4]
			{
				new Vector3(0f, 0f, 0f),
				new Vector3(0.25f, 0f, 0f),
				new Vector3(0f, 0.5f, 0f),
				new Vector3(0.25f, 0.5f, 0f)
			};
			val3.vertices = Il2CppStructArray<Vector3>.op_Implicit(array);
			int[] array2 = new int[6] { 0, 2, 1, 2, 3, 1 };
			val3.triangles = Il2CppStructArray<int>.op_Implicit(array2);
			val3.RecalculateNormals();
			Vector2[] array3 = (Vector2[])(object)new Vector2[4]
			{
				new Vector2(0f, 0f),
				new Vector2(1f, 0f),
				new Vector2(0f, 1f),
				new Vector2(1f, 1f)
			};
			val3.uv = Il2CppStructArray<Vector2>.op_Implicit(array3);
			val2.mesh = val3;
			TextMeshPro val4 = (tm = val.AddComponent<TextMeshPro>());
			((TMP_Text)val4).overflowMode = (TextOverflowModes)3;
			((TMP_Text)val4).autoSizeTextContainer = false;
			((TMP_Text)val4).verticalAlignment = (VerticalAlignmentOptions)512;
			((TMP_Text)val4).horizontalAlignment = (HorizontalAlignmentOptions)2;
			val4.transform.localScale = Vector3.one;
			((TMP_Text)val4).isTextObjectScaleStatic = true;
			((TMP_Text)val4).fontSize = 6f;
			((TMP_Text)val4).text = "<color=red>v</color>";
		}

		public Tag()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			pPlayerData_Session session = SNet.LocalPlayer.Session;
			myslot = ((pPlayerData_Session)(ref session)).playerSlotIndex;
			((MonoBehaviour)this)..ctor();
		}
	}
}
namespace Snipers.BotTag
{
	public class BotTagging : MonoBehaviour
	{
		public bool aiming;

		public Tag aimtag;

		public int aimtagindex;

		public PlayerAgent bot;

		public int slot;

		public float tagtime;

		public float checktime;

		public PlayerAIBot ai;

		public Vector3 eyepos;

		public bool hasfired;

		internal void Awake()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			bot = ((Component)this).GetComponent<PlayerAgent>();
			slot = bot.PlayerSlotIndex;
			aimtag = null;
			aimtagindex = 4;
			aiming = false;
			ai = ((Component)bot).GetComponent<PlayerAIBot>();
			eyepos = bot.GetHeadCamTransform().position;
			hasfired = false;
		}

		public void Fire()
		{
			if (SNet.IsMaster)
			{
				BulletWeapon val = ((Il2CppObjectBase)bot.Inventory.WieldedItem).TryCast<BulletWeapon>();
				if ((Object)(object)val != (Object)null && val.m_clip > 0)
				{
					val.Fire(true);
					hasfired = true;
				}
				Debug.Log(Object.op_Implicit("Snipers - bot " + bot.PlayerName + " asked to fire."));
			}
		}

		public void Update()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_044f: Expected O, but got Unknown
			//IL_0535: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0542: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_056f: Unknown result type (might be due to invalid IL or missing references)
			//IL_057a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0586: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a3: Expected O, but got Unknown
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			if (!SNet.IsMaster || (int)FocusStateManager.CurrentState != 4)
			{
				return;
			}
			if ((Object)(object)aimtag == (Object)null && aiming)
			{
				tagtime = 0f;
				aiming = false;
				NetworkAPI.InvokeEvent<Plugin.SniperNetInfo>("SniperNetInfo", new Plugin.SniperNetInfo(3, slot, aimtagindex, 0, fire: false), (SNet_ChannelType)2);
				List<PlayerBotActionBase> list = new List<PlayerBotActionBase>();
				Enumerator<PlayerBotActionBase> enumerator = ai.Actions.GetEnumerator();
				while (enumerator.MoveNext())
				{
					PlayerBotActionBase current = enumerator.Current;
					if (((MemberInfo)((Object)current).GetIl2CppType()).Name == "PlayerBotActionUseFirearm")
					{
						list.Add(current);
					}
				}
				if (list.Count > 0)
				{
					foreach (PlayerBotActionBase item in list)
					{
						if (item != null)
						{
							item.Stop();
						}
					}
				}
			}
			if ((Object)(object)aimtag == (Object)null)
			{
				return;
			}
			if ((Object)(object)aimtag != (Object)null && (Object)(object)aimtag.TaggedEnemy != (Object)null && !((Agent)aimtag.TaggedEnemy).Alive)
			{
				aimtag = null;
				tagtime = 0f;
				aimtagindex = 4;
				hasfired = false;
				return;
			}
			if (hasfired && (Object)(object)aimtag.TaggedEnemy != (Object)null && ((Agent)aimtag.TaggedEnemy).Alive)
			{
				bool flag = false;
				if (aimtag.TaggedEnemy.EnemyDataID == 28)
				{
					flag = true;
				}
				if (aimtag.TaggedEnemy.EnemyDataID == 16)
				{
					flag = true;
				}
				if (aimtag.TaggedEnemy.EnemyDataID == 18)
				{
					flag = true;
				}
				if (aimtag.TaggedEnemy.EnemyDataID == 33)
				{
					flag = true;
				}
				if (flag)
				{
					aimtag.TaggedEnemy.Damage.BulletDamage(((Dam_SyncedDamageBase)aimtag.TaggedEnemy.Damage).DamageMax, (Agent)(object)bot, Vector3.back, Vector3.zero, Vector3.zero, false, 0, 1f, 1f, 0u);
				}
				hasfired = false;
				return;
			}
			bot.Sync.WantsToWieldSlot((InventorySlot)2, false);
			if (Time.realtimeSinceStartup - checktime < 1f)
			{
				return;
			}
			checktime = Time.realtimeSinceStartup;
			eyepos = bot.GetHeadCamTransform().position;
			if (aiming && ai.CanSeeObject(eyepos, ((Component)aimtag.TaggedEnemy.m_headLimb).gameObject))
			{
				return;
			}
			Debug.Log(Object.op_Implicit($"Snipers - bot {bot.PlayerName} move or look, assigned tag {aimtag.index}"));
			if (!ai.CanSeeObject(eyepos, ((Component)aimtag.TaggedEnemy.m_headLimb).gameObject))
			{
				Debug.Log(Object.op_Implicit($"Snipers - bot {bot.PlayerName} cannot see its target at tag {aimtag.index}"));
				if (aiming)
				{
					aiming = false;
					NetworkAPI.InvokeEvent<Plugin.SniperNetInfo>("SniperNetInfo", new Plugin.SniperNetInfo(3, slot, aimtag.index, ((Agent)aimtag.TaggedEnemy).m_replicator.Key + 1, fire: false), (SNet_ChannelType)2);
					aimtag.UnassignAimer(slot);
				}
				aimtag.aim[slot] = false;
				ai.StartAction((Descriptor)new Descriptor(ai)
				{
					Bot = ai,
					DestinationType = (DestinationEnum)1,
					DestinationObject = ((Component)aimtag.TaggedEnemy.m_headLimb).gameObject,
					Haste = 999f,
					Prio = 999f
				});
			}
			else if (ai.CanSeeObject(eyepos, ((Component)aimtag.TaggedEnemy.m_headLimb).gameObject))
			{
				Debug.Log(Object.op_Implicit($"Snipers - bot {bot.PlayerName} can see its target at {aimtag.index}"));
				if (!aiming)
				{
					aiming = true;
					aimtag.AssignAimer(slot);
					NetworkAPI.InvokeEvent<Plugin.SniperNetInfo>("SniperNetInfo", new Plugin.SniperNetInfo(2, slot, aimtag.index, ((Agent)aimtag.TaggedEnemy).m_replicator.Key + 1, fire: false), (SNet_ChannelType)2);
					Descriptor val = new Descriptor(ai)
					{
						RequiredLayers = (AccessLayers)16,
						TargetObj = ((Component)aimtag.TaggedEnemy.m_headLimb).transform,
						OpenFire = true,
						Haste = 1f,
						Prio = 5f,
						Bot = ai,
						Weapon = ((Il2CppObjectBase)bot.Inventory.WieldedItem).TryCast<BulletWeaponSynced>()
					};
					ai.StartAction((Descriptor)(object)val);
				}
			}
		}
	}
}