Decompiled source of Solos Ring Compass TWEAKED v1.0.2

plugins/SoloCompass/SolosRingCompass.dll

Decompiled 10 months ago
using System;
using System.Collections;
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 UnityEngine;
using UnityEngine.SceneManagement;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("SolosRingCompass")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Solo's Ring Compass")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SolosRingCompass")]
[assembly: AssemblyTitle("SolosRingCompass")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SolosRingCompass;

[BepInPlugin("SolosRingCompass", "Solo's Ring Compass", "1.0")]
public class Plugin : BaseUnityPlugin
{
	private GameObject player = null;

	private GameObject GameObject;

	private GameObject OriginalSticky;

	private GameObject NewSticky;

	private Image Compass;

	private string[] invalidscenes = new string[3] { "MainMenu", "InitScene", "InitSceneLaunchOptions" };

	private bool showtext = true;

	private float Rotation = MathF.PI / 4f;

	private RectTransform RectT;

	private float Add135 = MathF.PI * 3f / 8f;

	private Texture2D tex = null;

	private Texture2D tex2 = null;

	private byte[] fileData;

	private Vector3 doodoo;

	private static Plugin Instance;

	public void Awake()
	{
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Expected O, but got Unknown
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Expected O, but got Unknown
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
		}
		else if ((Object)(object)Instance != (Object)(object)this)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
		if (File.Exists(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/Compass.png"))
		{
			fileData = File.ReadAllBytes(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/Compass.png");
			tex = new Texture2D(2, 2);
			ImageConversion.LoadImage(tex, fileData);
		}
		if (File.Exists(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/NewSticky.png"))
		{
			fileData = File.ReadAllBytes(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/NewSticky.png");
			tex2 = new Texture2D(2, 2);
			ImageConversion.LoadImage(tex2, fileData);
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin SolosRingCompass is loaded!");
		SceneManager.sceneLoaded += OnSceneLoaded;
	}

	public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		showtext = true;
		for (int i = 0; i < invalidscenes.Length; i++)
		{
			if (((Scene)(ref scene)).name == invalidscenes[i])
			{
				showtext = false;
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"SetFalse: {i}");
			}
		}
		if (showtext)
		{
			((MonoBehaviour)this).StartCoroutine(LoadCompass());
		}
	}

	private IEnumerator LoadCompass()
	{
		yield return (object)new WaitForSeconds(5f);
		player = ((Component)StartOfRound.Instance.localPlayerController).gameObject;
		if ((Object)GameObject == (Object)null)
		{
			GameObject = new GameObject("Image Object");
		}
		if ((Object)Compass == (Object)null)
		{
			Compass = GameObject.AddComponent<Image>();
		}
		GameObject.transform.SetParent(GameObject.Find("Systems/UI/Canvas").transform, false);
		((Object)GameObject.transform).name = "CompassImage";
		RectT = GameObject.GetComponent<RectTransform>();
		RectT.SetSizeWithCurrentAnchors((Axis)1, 2500f);
		RectT.SetSizeWithCurrentAnchors((Axis)0, 2500f);
		((Graphic)Compass).material = new Material(((Graphic)Compass).material);
		((Graphic)Compass).color = new Color(1f, 1f, 1f);
		((Graphic)Compass).material.mainTexture = (Texture)(object)tex;
		OriginalSticky = GameObject.Find("Environment/HangarShip/StickyNoteItem");
		doodoo = new Vector3(10.6496f, 3.0436f, -15.2289f);
		if (File.Exists(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/GhostOfTheStickyNote.txt"))
		{
			NewSticky = Object.Instantiate<GameObject>(OriginalSticky, doodoo, Quaternion.Euler(350.8127f, 265.4557f, 351.3032f), GameObject.Find("Environment/HangarShip").transform);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"not chummin' rn /:");
		}
		else
		{
			NewSticky = Object.Instantiate<GameObject>(OriginalSticky, doodoo, Quaternion.Euler(350.8127f, 265.4557f, 351.3032f));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"OH FUCK IM CHUMMING");
		}
		NewSticky.GetComponent<Renderer>().material = new Material(NewSticky.GetComponent<Renderer>().material);
		NewSticky.GetComponent<Renderer>().material.mainTexture = (Texture)(object)tex2;
	}

	public void Update()
	{
		//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_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)player == (Object)null))
		{
			Quaternion rotation = player.transform.rotation;
			Quaternion val = rotation;
			Rotation = ((Quaternion)(ref val)).eulerAngles.y / 180f * MathF.PI;
			RectT = GameObject.GetComponent<RectTransform>();
			((Transform)RectT).SetLocalPositionAndRotation(new Vector3(0f, 1470f, 0f), new Quaternion(MathF.Cos(Rotation * -1f / 2f + Add135), MathF.Sin(Rotation * -1f / 2f + Add135), 0f, 0f));
		}
	}
}
public static class PluginInfo
{
	public const string PLUGIN_GUID = "SolosRingCompass";

	public const string PLUGIN_NAME = "SolosRingCompass";

	public const string PLUGIN_VERSION = "1.0.0";
}