Decompiled source of MimesisMinimap v1.0.0

MimesisMinimap.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using MelonLoader;
using Mimic.Actors;
using MyMimesisMinimap;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(MinimapMod), "簡易小地圖", "1.0.0", "YourName", null)]
[assembly: MelonGame("ReLUGames", "MIMESIS")]
[assembly: AssemblyTitle("類別庫 (.NET Framework)")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("類別庫 (.NET Framework)")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b0f16656-1c85-4dce-bf2a-58b23ecfe30a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MyMimesisMinimap;

public class MinimapMod : MelonMod
{
	private Texture2D bgTexture;

	private Texture2D playerTexture;

	private Texture2D teammateTexture;

	private Texture2D enemyTexture;

	private float mapSize = 200f;

	private float zoomScale = 3f;

	public override void OnInitializeMelon()
	{
		//IL_0019: 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_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		bgTexture = MakeTexture(2, 2, new Color(0f, 0f, 0f, 0.6f));
		playerTexture = MakeTexture(2, 2, Color.green);
		teammateTexture = MakeTexture(2, 2, Color.cyan);
		enemyTexture = MakeTexture(2, 2, Color.red);
		MelonLogger.Msg("簡易雷達小地圖已載入!");
	}

	private Texture2D MakeTexture(int width, int height, Color col)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Expected O, but got Unknown
		Color[] array = (Color[])(object)new Color[width * height];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = col;
		}
		Texture2D val = new Texture2D(width, height);
		val.SetPixels(array);
		val.Apply();
		return val;
	}

	public override void OnGUI()
	{
		//IL_00e7: 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_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		GUI.depth = -100;
		if ((Object)(object)Hub.s == (Object)null || (Object)(object)Hub.Main == (Object)null)
		{
			return;
		}
		FieldInfo field = typeof(Hub).GetField("pdata", BindingFlags.Instance | BindingFlags.NonPublic);
		if (field == null)
		{
			return;
		}
		object value = field.GetValue(Hub.s);
		if (value == null)
		{
			return;
		}
		int num = (int)value.GetType().GetField("MyActorID").GetValue(value);
		ProtoActor actorByActorID = Hub.Main.GetActorByActorID(num);
		VPlayer localPlayer = ExtractVPlayer(actorByActorID);
		if (localPlayer == null || ((VActor)localPlayer).VRoom == null)
		{
			return;
		}
		Vector3 centerPos = ((VActor)localPlayer).Position.pos;
		float mapX = (float)Screen.width - mapSize - 20f;
		float mapY = 20f;
		GUI.DrawTexture(new Rect(mapX, mapY, mapSize, mapSize), (Texture)(object)bgTexture);
		float num2 = mapX + mapSize / 2f;
		float num3 = mapY + mapSize / 2f;
		GUI.DrawTexture(new Rect(num2 - 5f, num3 - 5f, 10f, 10f), (Texture)(object)playerTexture);
		((VActor)localPlayer).VRoom.IterateAllPlayer((Action<VPlayer>)delegate(VPlayer p)
		{
			//IL_0026: 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)
			if (((VActor)p).ObjectID != ((VActor)localPlayer).ObjectID)
			{
				DrawPointOnMap(((VActor)p).Position.pos, centerPos, mapX, mapY, teammateTexture, 8f);
			}
		});
		((VActor)localPlayer).VRoom.IterateAllMonster((Action<VActor>)delegate(VActor m)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (m.IsAliveStatus())
			{
				DrawPointOnMap(m.Position.pos, centerPos, mapX, mapY, enemyTexture, 8f);
			}
		});
	}

	private void DrawPointOnMap(Vector3 targetWorldPos, Vector3 centerWorldPos, float mapX, float mapY, Texture2D dotTexture, float dotSize)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		float num = targetWorldPos.x - centerWorldPos.x;
		float num2 = targetWorldPos.z - centerWorldPos.z;
		float num3 = mapX + mapSize / 2f + num * zoomScale;
		float num4 = mapY + mapSize / 2f - num2 * zoomScale;
		if (num3 > mapX && num3 < mapX + mapSize && num4 > mapY && num4 < mapY + mapSize)
		{
			GUI.DrawTexture(new Rect(num3 - dotSize / 2f, num4 - dotSize / 2f, dotSize, dotSize), (Texture)(object)dotTexture);
		}
	}

	private VPlayer ExtractVPlayer(object protoActor)
	{
		if (protoActor == null)
		{
			return null;
		}
		BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
		FieldInfo[] fields = protoActor.GetType().GetFields(bindingAttr);
		foreach (FieldInfo fieldInfo in fields)
		{
			if (fieldInfo.FieldType == typeof(VPlayer) || fieldInfo.FieldType == typeof(VActor) || fieldInfo.FieldType.Name == "VCreature")
			{
				object? value = fieldInfo.GetValue(protoActor);
				VPlayer val = (VPlayer)((value is VPlayer) ? value : null);
				if (val != null)
				{
					return val;
				}
			}
		}
		PropertyInfo[] properties = protoActor.GetType().GetProperties(bindingAttr);
		foreach (PropertyInfo propertyInfo in properties)
		{
			if (propertyInfo.PropertyType == typeof(VPlayer) || propertyInfo.PropertyType == typeof(VActor) || propertyInfo.PropertyType.Name == "VCreature")
			{
				object? value2 = propertyInfo.GetValue(protoActor);
				VPlayer val2 = (VPlayer)((value2 is VPlayer) ? value2 : null);
				if (val2 != null)
				{
					return val2;
				}
			}
		}
		return null;
	}
}