Decompiled source of Utter Garbage v0.0.3

Plugins/UtterGarbage.dll

Decompiled 2 years 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 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 LevelGeneration;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
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.2")]
	public class Plugin : BasePlugin
	{
		public struct SniperNetInfo
		{
			public int FUNC;

			public int TAGID;

			public int ENEMYID;

			public bool FIRE;

			public static string NetworkIdentity => "SniperNetInfo";

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

		public struct SniperInfo
		{
			public int FUNC;

			public int TAGID;

			public int ENEMYID;

			public bool FIRE;

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

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

		public class Snipers : MonoBehaviour
		{
			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
				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);
				}
			}

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

			private void Update()
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
				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)
					{
						foreach (Tag tag in tags)
						{
							if ((Object)(object)tag.TaggedEnemy == (Object)(object)componentInParent)
							{
								NetworkAPI.InvokeEvent<SniperNetInfo>("SniperNetInfo", new SniperNetInfo(1, tag.index, ((Agent)componentInParent).m_replicator.Key + 1, fire: false), (SNet_ChannelType)2);
								tag.UntagEnemy();
								Debug.Log(Object.op_Implicit("Snipers - enemy untagged, released " + ((Object)tag).name));
								return;
							}
						}
						foreach (Tag tag2 in tags)
						{
							if (tag2.Free)
							{
								NetworkAPI.InvokeEvent<SniperNetInfo>("SniperNetInfo", new SniperNetInfo(0, 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"));
					}
				}
				if (SNet.IsMaster && Input.GetKeyDown((KeyCode)122))
				{
					NetworkAPI.InvokeEvent<SniperNetInfo>("SniperNetInfo", new SniperNetInfo(4, 0, 0, fire: true), (SNet_ChannelType)2);
				}
				if (SNet.IsMaster && Input.GetKeyDown((KeyCode)323))
				{
					RaycastHit val2 = default(RaycastHit);
					Physics.Raycast(Camera.current.ScreenPointToRay(Input.mousePosition), ref val2);
					Debug.Log(Object.op_Implicit("x pressed, hit " + ((Object)((Component)((RaycastHit)(ref val2)).collider).gameObject).name));
					if ((Object)(object)((Component)((RaycastHit)(ref val2)).collider).gameObject.GetComponentInParent<EnemyAgent>() != (Object)null)
					{
						NetworkAPI.InvokeEvent<SniperNetInfo>("SniperNetInfo", new SniperNetInfo(4, 0, 0, fire: true), (SNet_ChannelType)2);
					}
				}
			}

			public static void ReceiveSniperNetInfo(ulong sender, SniperNetInfo netInfo)
			{
				//IL_0166: Unknown result type (might be due to invalid IL or missing references)
				//IL_0168: 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 + " 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(val3.PlayerSlotIndex);
				}
				if (netInfo.FUNC == 3)
				{
					tag.UnassignAimer(val3.PlayerSlotIndex);
				}
				if (!SNet.IsMaster && netInfo.FUNC == 4 && netInfo.FIRE && ReadyToFire != 4)
				{
					BulletWeapon val6 = ((Il2CppObjectBase)PlayerBackpackManager.Current.m_localPlayer.Inventory.WieldedItem).TryCast<BulletWeapon>();
					if ((Object)(object)val6 != (Object)null)
					{
						val6.Fire(true);
					}
				}
			}

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

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

			private void Update()
			{
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0230: Unknown result type (might be due to invalid IL or missing references)
				//IL_0240: Unknown result type (might be due to invalid IL or missing references)
				//IL_0256: Unknown result type (might be due to invalid IL or missing references)
				//IL_0260: Unknown result type (might be due to invalid IL or missing references)
				//IL_0276: Unknown result type (might be due to invalid IL or missing references)
				//IL_0281: Unknown result type (might be due to invalid IL or missing references)
				//IL_0286: Unknown result type (might be due to invalid IL or missing references)
				//IL_028b: Unknown result type (might be due to invalid IL or missing references)
				//IL_028f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0294: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_012b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0131: Invalid comparison between Unknown and I4
				//IL_013b: 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_02e0: Unknown result type (might be due to invalid IL or missing references)
				int localPlayerSlotIndex = PlayerManager.GetLocalPlayerSlotIndex();
				if (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=green>v</color>";
				}
				if (!aimed)
				{
					((TMP_Text)tm).text = "<color=red>v</color>";
				}
				foreach (KeyValuePair<int, bool> item2 in aim)
				{
					if (item2.Value)
					{
						DebugDraw3D.DrawCone(PlayerManager.Current.GetPlayerAgentInSlot(item2.Key).GetHeadCamTransform().position, ((Component)headLimb).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 val = default(RaycastHit);
					Physics.Raycast(Camera.current.ScreenPointToRay(Input.mousePosition), ref val);
					EnemyAgent componentInParent = ((Component)((RaycastHit)(ref val)).collider).gameObject.GetComponentInParent<EnemyAgent>();
					if ((Object)(object)componentInParent != (Object)null)
					{
						if ((Object)(object)componentInParent == (Object)(object)taggedEnemy)
						{
							aim[localPlayerSlotIndex] = true;
							if (ReadyToFire != index)
							{
								NetworkAPI.InvokeEvent<SniperNetInfo>("SniperNetInfo", new SniperNetInfo(2, index, ((Agent)taggedEnemy).m_replicator.Key + 1, fire: false), (SNet_ChannelType)2);
							}
							ReadyToFire = index;
						}
						if ((Object)(object)componentInParent != (Object)(object)taggedEnemy)
						{
							aim[localPlayerSlotIndex] = false;
						}
					}
					if ((Object)(object)componentInParent == (Object)null)
					{
						aim[localPlayerSlotIndex] = false;
						if (ReadyToFire == index)
						{
							NetworkAPI.InvokeEvent<SniperNetInfo>("SniperNetInfo", new SniperNetInfo(3, index, ((Agent)taggedEnemy).m_replicator.Key + 1, fire: false), (SNet_ChannelType)2);
						}
						ReadyToFire = 4;
					}
				}
				((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 val2 = ((Component)this).transform.position - ((Component)currentCamera).transform.position;
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				normalized.y = 0f;
				((Component)this).transform.rotation = Quaternion.LookRotation(normalized);
				if (!((Agent)taggedEnemy).Alive)
				{
					for (int i = 0; i < 4; i++)
					{
						aim[i] = false;
					}
					((Component)this).transform.position = piilo;
					TaggedEnemy = null;
					Free = true;
				}
			}

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

			public void UntagEnemy()
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				for (int i = 0; i < 4; i++)
				{
					aim[i] = false;
				}
				((Component)this).transform.position = piilo;
				Free = true;
				TaggedEnemy = null;
				head = null;
				((TMP_Text)tm).text = "<color=red>v</color>";
			}

			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 static int ReadyToFire = 4;

		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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			ClassInjector.RegisterTypeInIl2Cpp<Tag>();
			new ConfigFile(Path.Combine(Paths.ConfigPath, "Snipers.cfg"), true);
			new Harmony("Snipers").PatchAll();
			NetworkAPI.RegisterEvent<SniperNetInfo>(SniperNetInfo.NetworkIdentity, (Action<ulong, SniperNetInfo>)Snipers.ReceiveSniperNetInfo);
			EventAPI.OnExpeditionStarted += ((BasePlugin)this).AddComponent<Snipers>().Initialize;
		}
	}
	[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;
	}
}