using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using DunGen;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ComPassMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ComPassMod")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("11e5dbfc-6b93-42ba-bc03-c25d630050dc")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
public class CompassUI : MonoBehaviour
{
private Text compassText;
private float lastAngle = -1f;
private void Start()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
//IL_00a0: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("CompassCanvas");
val.AddComponent<Canvas>().renderMode = (RenderMode)0;
CanvasScaler obj = val.AddComponent<CanvasScaler>();
obj.uiScaleMode = (ScaleMode)1;
obj.referenceResolution = new Vector2(1920f, 1080f);
val.AddComponent<GraphicRaycaster>();
GameObject val2 = new GameObject("CompassText");
val2.transform.SetParent(val.transform, false);
compassText = val2.AddComponent<Text>();
compassText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
compassText.text = "N";
compassText.fontSize = 50;
((Graphic)compassText).color = Color.white;
compassText.alignment = (TextAnchor)4;
RectTransform component = ((Component)compassText).GetComponent<RectTransform>();
component.sizeDelta = new Vector2(200f, 50f);
component.anchoredPosition = new Vector2(0f, -200f);
}
private void Update()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Camera.main == (Object)null))
{
float y = ((Component)Camera.main).transform.eulerAngles.y;
if (Mathf.Abs(y - lastAngle) > 1f)
{
compassText.text = GetDirectionFromAngle(y);
lastAngle = y;
}
}
}
private string GetDirectionFromAngle(float angle)
{
if ((double)angle >= 337.5 || (double)angle < 22.5)
{
return "N";
}
if ((double)angle >= 22.5 && (double)angle < 67.5)
{
return "NE";
}
if ((double)angle >= 67.5 && (double)angle < 112.5)
{
return "E";
}
if ((double)angle >= 112.5 && (double)angle < 157.5)
{
return "SE";
}
if ((double)angle >= 157.5 && (double)angle < 202.5)
{
return "S";
}
if ((double)angle >= 202.5 && (double)angle < 247.5)
{
return "SW";
}
if ((double)angle >= 247.5 && (double)angle < 292.5)
{
return "W";
}
return "NW";
}
}
namespace CompassMod;
public static class CompassArrow
{
private static Image arrowImage;
public static void Initialize()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
//IL_003c: 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)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)arrowImage != (Object)null))
{
GameObject val = new GameObject("CompassCanvas");
val.AddComponent<Canvas>().renderMode = (RenderMode)0;
CanvasScaler obj = val.AddComponent<CanvasScaler>();
obj.uiScaleMode = (ScaleMode)1;
obj.referenceResolution = new Vector2(1920f, 1080f);
val.AddComponent<GraphicRaycaster>();
arrowImage = new GameObject("CompassArrow").AddComponent<Image>();
((Component)arrowImage).transform.SetParent(val.transform, false);
((Graphic)arrowImage).color = Color.white;
((Graphic)arrowImage).rectTransform.sizeDelta = new Vector2(50f, 50f);
((Graphic)arrowImage).rectTransform.anchoredPosition = new Vector2(0f, -200f);
}
}
public static void UpdateDirection(Vector3 direction)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)arrowImage == (Object)null)
{
Initialize();
}
float num = Mathf.Atan2(direction.z, direction.x) * 57.29578f;
((Transform)((Graphic)arrowImage).rectTransform).rotation = Quaternion.Euler(0f, 0f, 0f - num);
}
}
[BepInPlugin("com.seunome.compassmod", "Compass Mod", "1.0.0")]
public class CompassMod : BaseUnityPlugin
{
public static Text compassText;
public static Doorway exitDoorway;
private void Awake()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
new Harmony("com.seunome.compassmod").PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Compass Mod carregado!");
}
private void Update()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)exitDoorway == (Object)null)
{
FindExit();
}
if ((Object)(object)exitDoorway != (Object)null)
{
UpdateCompassUI(((Component)exitDoorway).transform.position - ((Component)Camera.main).transform.position);
}
}
public static void FindExit()
{
if ((Object)(object)exitDoorway != (Object)null)
{
return;
}
DungeonGenerator val = null;
GameObject[] array = Object.FindObjectsOfType<GameObject>();
for (int i = 0; i < array.Length; i++)
{
val = array[i].GetComponent<DungeonGenerator>();
if (val != null)
{
break;
}
}
if (val == null || (Object)(object)val.CurrentDungeon == (Object)null)
{
Debug.LogWarning((object)"DungeonGenerator não encontrado!");
return;
}
foreach (Tile allTile in val.CurrentDungeon.AllTiles)
{
if (allTile.Placement.IsOnMainPath)
{
Doorway val2 = allTile.GetExitDoorway();
if ((Object)(object)val2 != (Object)null)
{
exitDoorway = val2;
break;
}
}
}
}
public static void UpdateCompassUI(Vector3 direction)
{
//IL_00a8: 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_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)compassText == (Object)null)
{
GameObject val = new GameObject("CompassCanvas");
val.AddComponent<Canvas>().renderMode = (RenderMode)0;
compassText = new GameObject("CompassText").AddComponent<Text>();
((Component)compassText).transform.SetParent(val.transform);
compassText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
((Graphic)compassText).color = Color.white;
compassText.fontSize = 24;
compassText.alignment = (TextAnchor)4;
((Graphic)compassText).rectTransform.anchoredPosition = new Vector2(0f, -200f);
}
float value = Mathf.Atan2(direction.z, direction.x) * 57.29578f;
compassText.text = $"Direção: {value:F1}°";
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
[HarmonyPatch("Update")]
public static class PlayerPatch
{
private static void Postfix(PlayerControllerB __instance)
{
_ = ((NetworkBehaviour)__instance).IsOwner;
}
}