Decompiled source of ACompass v1.1.1

BepInEx/plugins/Compass.dll

Decompiled 10 months ago
using System;
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 BepInEx;
using HarmonyLib;
using LC_API.BundleAPI;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")]
[assembly: AssemblyCompany("Compass")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Compass")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Compass")]
[assembly: AssemblyTitle("Compass")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class CompassUpdater : MonoBehaviour
{
	public RawImage CompassImage;

	public Transform toFollow;

	public void setFollow(Transform user)
	{
		toFollow = user;
	}

	private void LateUpdate()
	{
		UpdateCompassHeading();
	}

	private void UpdateCompassHeading()
	{
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)GameNetworkManager.Instance == (Object)null) && !((Object)(object)GameNetworkManager.Instance.localPlayerController?.turnCompassCamera == (Object)null))
		{
			toFollow = ((Component)GameNetworkManager.Instance.localPlayerController.turnCompassCamera).transform;
			if (!((Object)(object)CompassImage == (Object)null) && !((Object)(object)toFollow == (Object)null))
			{
				Vector2 right = Vector2.right;
				Quaternion rotation = toFollow.rotation;
				Vector2 val = right * ((((Quaternion)(ref rotation)).eulerAngles.y + 45f) / 360f);
				CompassImage.uvRect = new Rect(val, Vector2.one);
			}
		}
	}
}
namespace Compass
{
	[BepInPlugin("Compass", "Compass", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public Harmony harmonymain;

		private void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			harmonymain = new Harmony("Compass");
			harmonymain.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Compass is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Compass";

		public const string PLUGIN_NAME = "Compass";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace Compass.Patches
{
	[HarmonyPatch]
	internal class Patches
	{
		private static CompassUpdater updater;

		[HarmonyPatch(typeof(HUDManager), "Awake")]
		[HarmonyPostfix]
		public static void AddCompass(HUDManager __instance)
		{
			Transform transform = __instance.HUDContainer.transform;
			Debug.Log((object)("Attaching compass to :" + (object)transform));
			GameObject val = BundleLoader.GetLoadedAsset<GameObject>("assets/compass/mask.prefab");
			if ((Object)(object)val == (Object)null)
			{
				string text = Path.Combine(Paths.PluginPath, "alekso56-ACompass", "compass");
				LoadedAssetBundle val2 = BundleLoader.LoadAssetBundle(text, false);
				val = val2.GetAsset<GameObject>("assets/compass/mask.prefab");
			}
			val = Object.Instantiate<GameObject>(val, transform);
			val.transform.SetParent(((Component)transform).transform, false);
			Debug.Log((object)"Compass attached, setting target.");
			updater = val.AddComponent<CompassUpdater>();
			Debug.Log((object)"Updater loaded");
			updater.CompassImage = ((Component)val.transform.GetChild(0)).GetComponentInChildren<RawImage>();
		}
	}
}