using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using MelonLoader;
using Microsoft.CodeAnalysis;
using MiniMap;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "MiniMap", "1.0.0", "ToxesFoxes", null)]
[assembly: MelonGame("ReLUGames", "MIMESIS")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Minimap")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+9757acaecdbfa2beb88f13e833349f96f7abef5b")]
[assembly: AssemblyProduct("Minimap")]
[assembly: AssemblyTitle("Minimap")]
[assembly: NeutralResourcesLanguage("en-US")]
[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;
}
}
}
namespace MiniMap
{
public class Core : MelonMod
{
[CompilerGenerated]
private sealed class <RecreateMinimapAfterDelay>d__13 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RecreateMinimapAfterDelay>d__13(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = null;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
CreateCamera();
CreateUI();
MelonLogger.Msg("Minimap recreated successfully after scene load.");
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static Camera mapCamera;
private static RenderTexture mapTexture;
private static GameObject mapCanvasObj;
private static RawImage mapImage;
private static Transform playerTransform;
private static bool isVisible = false;
private static bool isInDungeon = false;
private static InputAction toggleAction;
private static float cameraYOffset = 3f;
private static float nearClipPlane = 1f;
private static float farClipPlane = 20f;
public override void OnInitializeMelon()
{
MelonLogger.Msg("MiniMap initialized. Press F4 to toggle minimap.");
SetupInput();
SceneManager.sceneLoaded += OnSceneLoaded;
MelonLogger.Msg("MiniMap setup complete.");
}
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
MelonLogger.Msg($"Scene loaded: {((Scene)(ref scene)).name}, minimap was visible: {isVisible}");
playerTransform = null;
DestroyUI();
DestroyCamera();
if (isVisible)
{
MelonLogger.Msg("Recreating minimap after scene load...");
MelonCoroutines.Start(RecreateMinimapAfterDelay());
}
}
[IteratorStateMachine(typeof(<RecreateMinimapAfterDelay>d__13))]
private static IEnumerator RecreateMinimapAfterDelay()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RecreateMinimapAfterDelay>d__13(0);
}
private static void SetupInput()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
InputActionMap val = new InputActionMap("MiniMap");
toggleAction = InputActionSetupExtensions.AddAction(val, "Toggle", (InputActionType)0, "<Keyboard>/f4", (string)null, (string)null, (string)null, (string)null);
toggleAction.performed += delegate
{
ToggleMap();
};
val.Enable();
}
private static void DestroyUI()
{
if ((Object)(object)mapCanvasObj != (Object)null)
{
Object.Destroy((Object)(object)mapCanvasObj);
mapCanvasObj = null;
mapImage = null;
}
MelonLogger.Msg("MiniMap UI destroyed.");
}
private static void DestroyCamera()
{
if ((Object)(object)mapCamera != (Object)null)
{
if ((Object)(object)((Component)mapCamera).gameObject != (Object)null)
{
Object.Destroy((Object)(object)((Component)mapCamera).gameObject);
}
mapCamera = null;
mapTexture = null;
}
MelonLogger.Msg("MiniMap Camera destroyed.");
}
private static void ToggleMap()
{
isVisible = !isVisible;
MelonLogger.Msg("Toggling MiniMap: " + (isVisible ? "Enabled" : "Disabled"));
if (isVisible)
{
if ((Object)(object)mapCanvasObj == (Object)null)
{
CreateCamera();
CreateUI();
}
if ((Object)(object)mapCamera != (Object)null)
{
((Behaviour)mapCamera).enabled = true;
}
}
else
{
DestroyUI();
DestroyCamera();
}
}
private static void CreateCamera()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Expected O, but got Unknown
if (!((Object)(object)mapCamera != (Object)null))
{
mapCamera = new GameObject("MiniMapCamera").AddComponent<Camera>();
mapCamera.orthographic = true;
mapCamera.orthographicSize = 10f;
mapCamera.clearFlags = (CameraClearFlags)2;
mapCamera.backgroundColor = new Color(0f, 0f, 0f, 0f);
mapCamera.cullingMask = -1;
mapTexture = new RenderTexture(512, 512, 16, (RenderTextureFormat)0);
mapTexture.Create();
mapCamera.targetTexture = mapTexture;
mapCamera.nearClipPlane = (isInDungeon ? nearClipPlane : 0.1f);
mapCamera.farClipPlane = (isInDungeon ? farClipPlane : 100f);
MelonLogger.Msg("MiniMap Camera created successfully with FullBright lighting.");
}
}
private static void CreateUI()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
//IL_007f: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)mapCanvasObj != (Object)null))
{
mapCanvasObj = new GameObject("MiniMapCanvas");
mapCanvasObj.AddComponent<Canvas>().renderMode = (RenderMode)0;
mapCanvasObj.AddComponent<CanvasScaler>();
mapCanvasObj.AddComponent<GraphicRaycaster>();
GameObject val = new GameObject("MiniMapBG");
val.transform.SetParent(mapCanvasObj.transform, false);
Image obj = val.AddComponent<Image>();
((Graphic)obj).color = new Color(0f, 0f, 0f, 0.4f);
RectTransform component = ((Component)obj).GetComponent<RectTransform>();
component.anchorMin = new Vector2(1f, 0f);
component.anchorMax = new Vector2(1f, 0f);
component.pivot = new Vector2(1f, 0f);
component.anchoredPosition = new Vector2(-10f, 10f);
component.sizeDelta = new Vector2(256f, 256f);
GameObject val2 = new GameObject("MiniMapImage");
val2.transform.SetParent(val.transform, false);
mapImage = val2.AddComponent<RawImage>();
mapImage.texture = (Texture)(object)mapTexture;
RectTransform component2 = val2.GetComponent<RectTransform>();
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.offsetMin = new Vector2(5f, 5f);
component2.offsetMax = new Vector2(-5f, -5f);
MelonLogger.Msg("MiniMap UI created successfully with green filter applied.");
}
}
public override void OnLateUpdate()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Expected O, but got Unknown
//IL_00af: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
if (!isVisible || (Object)(object)mapCamera == (Object)null)
{
return;
}
if ((Object)(object)playerTransform == (Object)null)
{
GameObject val = GameObject.FindWithTag("Player");
if (!((Object)(object)val != (Object)null))
{
return;
}
playerTransform = val.transform;
}
Vector3 position = playerTransform.position;
float num = position.y + cameraYOffset;
Vector3 position2 = default(Vector3);
((Vector3)(ref position2))..ctor(position.x, Mathf.Round(num), position.z);
if (position.y < -10f)
{
isInDungeon = true;
Material val2 = new Material(Shader.Find("UI/Default"));
val2.color = new Color(0f, 1f, 0f, 1f);
((Graphic)mapImage).material = val2;
}
else
{
isInDungeon = false;
((Graphic)mapImage).material = null;
}
((Component)mapCamera).transform.position = position2;
((Component)mapCamera).transform.rotation = Quaternion.Euler(90f, playerTransform.eulerAngles.y, 0f);
mapCamera.nearClipPlane = (isInDungeon ? nearClipPlane : 0.1f);
mapCamera.farClipPlane = (isInDungeon ? farClipPlane : 100f);
}
}
}