Decompiled source of CompassWaypointsonscreen v1.0.1

CompassWaypointsOnScreen.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using CompassWaypointsOnScreen;
using MelonLoader;
using ScheduleOne.DevUtilities;
using ScheduleOne.PlayerScripts;
using ScheduleOne.UI.Compass;
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: ComVisible(false)]
[assembly: MelonInfo(typeof(Plugin), "CompassWaypointsOnScreen", "9.28.2996", "Coolpaca", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: Guid("f85e11ed-2a8b-4b8c-8a14-84a017c570c1")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("CompassWaypointsOnScreen")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e5bfd5d47809b6b1e291f06895222a1721c8c878")]
[assembly: AssemblyProduct("CompassWaypointsOnScreen")]
[assembly: AssemblyTitle("CompassWaypointsOnScreen")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace CompassWaypointsOnScreen
{
	public class Plugin : MelonMod
	{
		public static CompassManager manager;

		public static PlayerCamera cam;

		public static Sprite texture;

		public static Dictionary<Element, GameObject> dict = new Dictionary<Element, GameObject>();

		public static AssetBundle elementBundle;

		public override void OnInitializeMelon()
		{
			((MelonBase)this).OnInitializeMelon();
			MelonLogger.Msg("Loaded!");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			elementBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "onscreenelementprefab"));
			texture = LoadImage("DEAL.png");
		}

		public override void OnUpdate()
		{
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			((MelonBase)this).OnUpdate();
			if ((Object)(object)Singleton<CompassManager>.Instance != (Object)null)
			{
				manager = Singleton<CompassManager>.Instance;
			}
			if ((Object)(object)PlayerSingleton<PlayerCamera>.Instance != (Object)null)
			{
				cam = PlayerSingleton<PlayerCamera>.Instance;
			}
			if ((Object)(object)manager == (Object)null || (Object)(object)cam == (Object)null)
			{
				return;
			}
			foreach (Element element in manager.elements)
			{
				if (!dict.ContainsKey(element) && element.Visible)
				{
					GameObject val = elementBundle.LoadAsset<GameObject>("Assets/OnScreenElementPrefab.prefab");
					RectTransform elementUIContainer = manager.ElementUIContainer;
					dict.Add(element, Object.Instantiate<GameObject>(val, (Transform)(object)elementUIContainer));
				}
				if (dict.ContainsKey(element) && !element.Visible)
				{
					Object.Destroy((Object)(object)dict[element]);
					dict.Remove(element);
				}
			}
			Image val2 = default(Image);
			foreach (KeyValuePair<Element, GameObject> item in dict)
			{
				if ((Object)(object)item.Value != (Object)null)
				{
					if ((Object)(object)cam == (Object)null || (Object)(object)cam.Camera == (Object)null || (Object)(object)item.Key.Transform == (Object)null)
					{
						break;
					}
					dict[item.Key].transform.position = cam.Camera.WorldToScreenPoint(item.Key.Transform.position);
					if (dict[item.Key].TryGetComponent<Image>(ref val2))
					{
						val2.sprite = texture;
					}
					if (dict[item.Key].transform.position.z >= 0f)
					{
						Random random = new Random(((Object)dict[item.Key]).GetInstanceID());
						((Graphic)val2).color = new Color((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble());
					}
					else
					{
						((Graphic)val2).color = Color.clear;
					}
				}
			}
		}

		public static Sprite LoadImage(string Name)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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)
			string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + Name;
			byte[] array = File.ReadAllBytes(path);
			Texture2D val = new Texture2D(2, 2);
			if (!ImageConversion.LoadImage(val, array))
			{
				MelonLogger.Error("Failed to load image. Make sure its named \"" + Name + "\" exactly.");
				return null;
			}
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.one / 2f);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}