Decompiled source of Lyse Minimap v1.0.0

LysyMod_Mapa.dll

Decompiled 21 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LysyMod_Mapa")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Zaktualizowany mod do R.E.P.O")]
[assembly: AssemblyFileVersion("1.5.1.0")]
[assembly: AssemblyInformationalVersion("1.5.1")]
[assembly: AssemblyProduct("LysyMod_Mapa")]
[assembly: AssemblyTitle("LysyMod_Mapa")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.5.1.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;
		}
	}
}
namespace LyseMinimap
{
	public enum MapPosition
	{
		LewyGorny,
		PrawyGorny,
		LewyDolny,
		PrawyDolny
	}
	[BepInPlugin("com.qubi.lyseminimap", "Lyse Minimap", "3.0.0")]
	public class LyseMinimapPlugin : BaseUnityPlugin
	{
		public static ConfigEntry<float> MapSize;

		public static ConfigEntry<float> MapOpacity;

		public static ConfigEntry<float> MapZoom;

		public static ConfigEntry<MapPosition> MapPos;

		private void Awake()
		{
			MapSize = ((BaseUnityPlugin)this).Config.Bind<float>("1_Wyglad", "Wielkosc", 250f, "Rozmiar mapy w pikselach na ekranie");
			MapOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("1_Wyglad", "Przezroczystosc", 0.8f, "Widocznosc mapy (0.0 - 1.0)");
			MapZoom = ((BaseUnityPlugin)this).Config.Bind<float>("2_Kamera", "Przyblizenie", 3f, "Zoom kamery (mniejsza wartosc = wieksze przyblizenie)");
			MapPos = ((BaseUnityPlugin)this).Config.Bind<MapPosition>("3_Pozycja", "RogEkranu", MapPosition.PrawyDolny, "W ktorym rogu ma byc mapa?");
			((Component)this).gameObject.AddComponent<MinimapControl>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Lyse Minimap v3.0 (Konfiguracja UI) Zaladowana!");
		}
	}
	public class MinimapControl : MonoBehaviour
	{
		private RawImage mapDisplay;

		private GameObject canvasObj;

		private Camera customMapCamera;

		private RenderTexture customMapTexture;

		private void Update()
		{
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)PlayerController.instance == (Object)null || (Object)(object)Map.Instance == (Object)null)
			{
				if ((Object)(object)canvasObj != (Object)null && canvasObj.activeSelf)
				{
					canvasObj.SetActive(false);
				}
				return;
			}
			Map.Instance.ActiveSet(true);
			if ((Object)(object)canvasObj == (Object)null)
			{
				CreateUI();
			}
			else if (!canvasObj.activeSelf)
			{
				canvasObj.SetActive(true);
			}
			if ((Object)(object)customMapCamera == (Object)null)
			{
				SetupCustomCamera();
			}
			if ((Object)(object)customMapCamera != (Object)null)
			{
				customMapCamera.orthographicSize = LyseMinimapPlugin.MapZoom.Value;
				if ((Object)(object)Map.Instance.PlayerGraphicTransform != (Object)null)
				{
					((Component)customMapCamera).transform.position = Map.Instance.PlayerGraphicTransform.position + Vector3.up * 20f;
				}
				else if ((Object)(object)Map.Instance.ActiveParent != (Object)null)
				{
					((Component)customMapCamera).transform.position = Map.Instance.ActiveParent.transform.position + Vector3.up * 20f;
				}
			}
		}

		private void SetupCustomCamera()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_0128: Expected O, but got Unknown
			GameObject val = new GameObject("LyseCustomMapCamera");
			customMapCamera = val.AddComponent<Camera>();
			customMapCamera.orthographic = true;
			customMapCamera.orthographicSize = LyseMinimapPlugin.MapZoom.Value;
			customMapCamera.clearFlags = (CameraClearFlags)2;
			customMapCamera.backgroundColor = new Color(0f, 0f, 0f, 0.4f);
			((Component)customMapCamera).transform.rotation = Quaternion.Euler(90f, 0f, 0f);
			customMapCamera.cullingMask = ~((1 << LayerMask.NameToLayer("UI")) | (1 << LayerMask.NameToLayer("Player")));
			if ((Object)(object)Map.Instance.ActiveParent != (Object)null)
			{
				int layer = Map.Instance.ActiveParent.gameObject.layer;
				if (layer != 0)
				{
					customMapCamera.cullingMask = 1 << layer;
				}
			}
			customMapTexture = new RenderTexture((int)LyseMinimapPlugin.MapSize.Value, (int)LyseMinimapPlugin.MapSize.Value, 16);
			customMapCamera.targetTexture = customMapTexture;
			if ((Object)(object)mapDisplay != (Object)null)
			{
				mapDisplay.texture = (Texture)(object)customMapTexture;
			}
		}

		private void CreateUI()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			canvasObj = new GameObject("LyseMinimapCanvas");
			Canvas val = canvasObj.AddComponent<Canvas>();
			val.renderMode = (RenderMode)0;
			val.sortingOrder = 999;
			canvasObj.AddComponent<CanvasScaler>();
			GameObject val2 = new GameObject("MapTexture");
			val2.transform.SetParent(canvasObj.transform);
			mapDisplay = val2.AddComponent<RawImage>();
			RectTransform rectTransform = ((Graphic)mapDisplay).rectTransform;
			rectTransform.sizeDelta = new Vector2(LyseMinimapPlugin.MapSize.Value, LyseMinimapPlugin.MapSize.Value);
			switch (LyseMinimapPlugin.MapPos.Value)
			{
			case MapPosition.LewyGorny:
				rectTransform.anchorMin = new Vector2(0f, 1f);
				rectTransform.anchorMax = new Vector2(0f, 1f);
				rectTransform.pivot = new Vector2(0f, 1f);
				rectTransform.anchoredPosition = new Vector2(20f, -20f);
				break;
			case MapPosition.PrawyGorny:
				rectTransform.anchorMin = new Vector2(1f, 1f);
				rectTransform.anchorMax = new Vector2(1f, 1f);
				rectTransform.pivot = new Vector2(1f, 1f);
				rectTransform.anchoredPosition = new Vector2(-20f, -20f);
				break;
			case MapPosition.LewyDolny:
				rectTransform.anchorMin = new Vector2(0f, 0f);
				rectTransform.anchorMax = new Vector2(0f, 0f);
				rectTransform.pivot = new Vector2(0f, 0f);
				rectTransform.anchoredPosition = new Vector2(20f, 20f);
				break;
			case MapPosition.PrawyDolny:
				rectTransform.anchorMin = new Vector2(1f, 0f);
				rectTransform.anchorMax = new Vector2(1f, 0f);
				rectTransform.pivot = new Vector2(1f, 0f);
				rectTransform.anchoredPosition = new Vector2(-20f, 20f);
				break;
			}
			((Graphic)mapDisplay).color = new Color(1f, 1f, 1f, LyseMinimapPlugin.MapOpacity.Value);
		}
	}
}