Decompiled source of ITawtITaw v0.1.2

plugins/ITawtITaw.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ITawtITaw")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ITawtITaw")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("59a069a9-8bdb-4dcf-80bc-5c56ba868f42")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ITawtITaw;

[BepInPlugin("com.oathorse.ITIT", "I Tawt I Taw", "0.1.2")]
public class ITawtITaw : BaseUnityPlugin
{
	[HarmonyPatch(typeof(BaseAI), "OnEnable")]
	public static class BaseAI_OnEnable_Patch
	{
		public static void Postfix(BaseAI __instance)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (!m_aiObjects.ContainsKey(__instance))
			{
				if (m_showEverything)
				{
					PinData value = Minimap.instance.AddPin(((Component)__instance).gameObject.transform.position, (PinType)3, ((Object)((Component)__instance).gameObject).name, true, false, 0L, "");
					m_aiObjects.Add(__instance, value);
				}
				else
				{
					m_aiObjects.Add(__instance, null);
				}
			}
		}
	}

	[HarmonyPatch(typeof(BaseAI), "OnDisable")]
	public static class BaseAI_OnDestroy_Patch
	{
		public static void Postfix(BaseAI __instance)
		{
			object? obj = m_aiObjects[__instance];
			PinData val = (PinData)((obj is PinData) ? obj : null);
			if (val != null && m_showEverything)
			{
				Minimap.instance.RemovePin(val);
			}
			m_aiObjects.Remove(__instance);
		}
	}

	[HarmonyPatch(typeof(BaseAI), "UpdateAI")]
	public static class BaseAI_UpdateAI_Patch
	{
		public static void Postfix(BaseAI __instance)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_0099: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			m_checkTimer += Time.deltaTime;
			if (!(m_checkTimer > m_checkFrequency))
			{
				return;
			}
			Character component = ((Component)__instance).GetComponent<Character>();
			if (Object.op_Implicit((Object)(object)component) && (m_showEverything || m_listOfPuddyTats.Contains(component.GetHoverName())) && (Object)(object)Player.m_localPlayer != (Object)null)
			{
				Vector3 position = ((Component)Player.m_localPlayer).transform.position;
				Vector3 position2 = ((Component)component).transform.position;
				float num = Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)component).transform.position);
				if (m_showEverything || num < Minimap.instance.m_exploreRadius)
				{
					Vector3 val = Vector3.Normalize(position2 - position);
					Vector3 lookDir = ((Character)Player.m_localPlayer).GetLookDir();
					float num2 = Vector3.Dot(lookDir, val);
					float num3 = (float)Math.Acos(num2);
					float num4 = num3 * 180f / (float)Math.PI;
					if (m_showEverything || (num2 > 0f && num4 < GameCamera.instance.m_fov / 2f))
					{
						if (m_aiObjects.ContainsKey(__instance))
						{
							object? obj = m_aiObjects[__instance];
							PinData val2 = (PinData)((obj is PinData) ? obj : null);
							if (val2 != null)
							{
								Minimap.instance.RemovePin(val2);
							}
							m_aiObjects.Remove(__instance);
						}
						PinData value = Minimap.instance.AddPin(((Component)__instance).gameObject.transform.position, (PinType)3, component.GetHoverName(), true, false, 0L, "");
						m_aiObjects.Add(__instance, value);
					}
				}
			}
			m_checkTimer = 0f;
		}
	}

	public const string PluginGUID = "com.oathorse.ITIT";

	public const string PluginName = "I Tawt I Taw";

	public const string PluginVersion = "0.1.2";

	private readonly Harmony harmony = new Harmony("com.oathorse.ITIT");

	public static Hashtable m_aiObjects = new Hashtable();

	private static float m_checkTimer = 0f;

	private static float m_checkFrequency = 2f;

	private static bool m_showEverything = false;

	private static List<string> m_listOfPuddyTats = new List<string>();

	private ConfigEntry<bool> m_configShowEverything;

	private ConfigEntry<string> m_configListOfPuddyTats;

	private ConfigEntry<float> m_configCheckFrequency;

	private void Awake()
	{
		harmony.PatchAll();
		Debug.LogWarning((object)"I Tawt I Taw is running.");
		m_configListOfPuddyTats = ((BaseUnityPlugin)this).Config.Bind<string>("General", "ListOfPuddyTats", "Serpent,BonemawSerpent", "List of Characters to watch for, separated by commas. Defaults to 'Serpent,BonemawSerpent'");
		m_configShowEverything = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowEverything", false, "When enabled, will display all nearby characters on the minimap as they Enable/Disable. Default: FALSE");
		m_configCheckFrequency = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CheckFrequency", 2f, "Number of seconds between checks to see if you taw a puddy tat");
		m_showEverything = m_configShowEverything.Value;
		m_checkFrequency = m_configCheckFrequency.Value;
		string value = m_configListOfPuddyTats.Value;
		m_listOfPuddyTats = value.Split(new char[1] { ',' }).ToList();
	}
}