Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of DeathMinimap v1.0.0
DeathMinimap.dll
Decompiled 4 months agousing System; using System.Collections; using System.Collections.Generic; 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 BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [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: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Halichu")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+48f0d5621abec3e2ceba44fad0cad9fd4f7b5c6d")] [assembly: AssemblyProduct("DeathMinimap")] [assembly: AssemblyTitle("DeathMinimap")] [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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 DeathMinimap { public enum MinimapSize { Small, Medium, Large } [BepInPlugin("Halichu.DeathMinimap", "DeathMinimap", "1.0.0")] public class DeathMinimap : BaseUnityPlugin { private static float scaleSpeed = 5f; private static float scale = 0.5f; private static float targetScale = 1f; internal static DeathMinimap Instance { get; private set; } = null; internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } internal static ConfigEntry<MinimapSize> Size { get; private set; } = null; internal static RenderTexture? renderTexture { get; set; } = null; internal static Camera? camera { get; set; } = null; internal static bool spectating { get; set; } = false; internal static bool active { get; set; } = false; internal static bool activePrev { get; set; } = false; private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Size = ((BaseUnityPlugin)this).Config.Bind<MinimapSize>("General", "Minimap Size", MinimapSize.Small, "Size of the minimap display"); Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { if (spectating) { active = (InputManager.instance.InputToggleGet((InputKey)8) && SemiFunc.InputDown((InputKey)8)) || SemiFunc.InputHold((InputKey)8); } targetScale = (active ? 1f : 0.5f); scale = Mathf.Lerp(scale, targetScale, Time.deltaTime * scaleSpeed); UpdateCameraTransform(); } private void UpdateCameraTransform() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (spectating && Object.op_Implicit((Object)(object)SpectateCamera.instance)) { Transform transform = ((Component)SpectateCamera.instance).transform; if (!Object.op_Implicit((Object)(object)DirtFinderMapPlayer.Instance.PlayerTransform)) { Logger.LogWarning((object)"DirtFinderMapPlayer transform null."); DirtFinderMapPlayer.Instance.PlayerTransform = new GameObject().transform; } DirtFinderMapPlayer.Instance.PlayerTransform.position = transform.position; Transform playerTransform = DirtFinderMapPlayer.Instance.PlayerTransform; Quaternion rotation = transform.rotation; float y = ((Quaternion)(ref rotation)).eulerAngles.y; rotation = transform.rotation; playerTransform.rotation = Quaternion.Euler(0f, y, ((Quaternion)(ref rotation)).eulerAngles.z); PlayerController.instance.playerAvatarScript.LastNavmeshPosition = SpectateCamera.instance.player.LastNavmeshPosition; } } private void OnGUI() { //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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) if (!spectating) { return; } if (active != activePrev) { activePrev = active; Sound val = (activePrev ? PlayerAvatar.instance.mapToolController.SoundStart : PlayerAvatar.instance.mapToolController.SoundStop); if (Object.op_Implicit((Object)(object)SpectateCamera.instance)) { val.Play(((Component)SpectateCamera.instance).transform.position, 1f, 1f, 1f, 1f); } } Map.Instance.Active = active; if (!active) { targetScale = 0.5f; return; } CameraTopFade.Instance.Set(0.5f, 0.1f); (float width, float height) minimapSize = GetMinimapSize(); float item = minimapSize.width; float item2 = minimapSize.height; float num = ((float)Screen.width - item) / 2f; float num2 = ((float)Screen.height - item2) / 2f; Rect mapRect = default(Rect); ((Rect)(ref mapRect))..ctor(num, num2, item, item2); DrawMapTexture(mapRect); DrawMapFrame(mapRect); DrawMapLabel(mapRect); } private static void DrawMapTexture(Rect mapRect) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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) Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, scale * 0.9f + 0.1f); GUI.DrawTexture(mapRect, (Texture)(object)renderTexture, (ScaleMode)0, false); GUI.color = color; } private static void DrawMapFrame(Rect mapRect) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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) Color color = GUI.color; GUI.color = new Color(0.8f, 0.8f, 0.8f, scale); float num = 2f; GUI.DrawTexture(new Rect(((Rect)(ref mapRect)).x, ((Rect)(ref mapRect)).y, ((Rect)(ref mapRect)).width, num), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref mapRect)).x, ((Rect)(ref mapRect)).y + ((Rect)(ref mapRect)).height - num, ((Rect)(ref mapRect)).width, num), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref mapRect)).x, ((Rect)(ref mapRect)).y, num, ((Rect)(ref mapRect)).height), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref mapRect)).x + ((Rect)(ref mapRect)).width - num, ((Rect)(ref mapRect)).y, num, ((Rect)(ref mapRect)).height), (Texture)(object)Texture2D.whiteTexture); GUI.color = color; } private static void DrawMapLabel(Rect mapRect) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontSize = Mathf.RoundToInt(14f * scale) }; val.normal.textColor = new Color(1f, 1f, 1f, scale); GUIStyle val2 = val; Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(((Rect)(ref mapRect)).x, ((Rect)(ref mapRect)).y - 25f, ((Rect)(ref mapRect)).width, 20f); GUI.Label(val3, "Death Minimap", val2); } internal static void SetSpectating(bool isSpectating) { spectating = isSpectating; } private static (float width, float height) GetMinimapSize() { MinimapSize value = Size.Value; if (1 == 0) { } (float, float) result = value switch { MinimapSize.Small => (RenderTextureMain.instance.textureWidthSmall, RenderTextureMain.instance.textureHeightSmall), MinimapSize.Medium => (RenderTextureMain.instance.textureWidthMedium, RenderTextureMain.instance.textureHeightMedium), MinimapSize.Large => (RenderTextureMain.instance.textureWidthLarge, RenderTextureMain.instance.textureHeightLarge), _ => (RenderTextureMain.instance.textureWidthSmall, RenderTextureMain.instance.textureHeightSmall), }; if (1 == 0) { } return result; } } [HarmonyPatch(typeof(DirtFinderMapPlayer))] internal static class DirtFinderMapPlayerPatch { [HarmonyPostfix] [HarmonyPatch("Awake")] private static void Awake_Postfix(DirtFinderMapPlayer __instance) { Camera componentInChildren = ((Component)__instance).GetComponentInChildren<Camera>(); if (((Object)componentInChildren).name != "Dirt Finder Map Camera") { DeathMinimap.Logger.LogWarning((object)"Dirt Finder Map Camera not found."); } else if (!Object.op_Implicit((Object)(object)DeathMinimap.camera)) { DeathMinimap.camera = componentInChildren; } } } [HarmonyPatch(typeof(GameDirector))] internal static class GameDirectorPatch { [HarmonyPrefix] [HarmonyPatch("Revive")] private static void Revive_Prefix() { DeathMinimap.SetSpectating(isSpectating: false); } [HarmonyPrefix] [HarmonyPatch("gameStateStart")] private static void GameStateStart_Prefix() { if (DeathMinimap.spectating) { DeathMinimap.SetSpectating(isSpectating: false); } } } [HarmonyPatch(typeof(PlayerAvatar))] internal static class PlayerAvatarPatch { [CompilerGenerated] private sealed class <LoadRenderTexture>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Camera camera; private RenderTexture <renderTexture>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadRenderTexture>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <renderTexture>5__1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <renderTexture>5__1 = camera.activeTexture; break; case 1: <>1__state = -1; <renderTexture>5__1 = camera.activeTexture; break; } if (!Object.op_Implicit((Object)(object)<renderTexture>5__1)) { <>2__current = null; <>1__state = 1; return true; } DeathMinimap.renderTexture = <renderTexture>5__1; 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(); } } [HarmonyPrefix] [HarmonyPatch("SetSpectate")] private static void SetSpectate_Prefix() { Map.Instance.ActiveParent.SetActive(true); if (Object.op_Implicit((Object)(object)DeathMinimap.camera)) { ((MonoBehaviour)Map.Instance).StartCoroutine(LoadRenderTexture(DeathMinimap.camera)); } } [IteratorStateMachine(typeof(<LoadRenderTexture>d__1))] private static IEnumerator LoadRenderTexture(Camera camera) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadRenderTexture>d__1(0) { camera = camera }; } } [HarmonyPatch(typeof(SpectateCamera))] internal static class SpectateCameraPatch { [HarmonyPrefix] [HarmonyPatch("StateNormal")] private static void StateNormal_Prefix() { if ((SemiFunc.RunIsLevel() || SemiFunc.RunIsShop()) && !DeathMinimap.spectating && Object.op_Implicit((Object)(object)SpectateCamera.instance.player)) { DeathMinimap.SetSpectating(isSpectating: true); } } } }