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 LootValueOnMap v1.0.1
LootValueOnMap.dll
Decompiled a day agousing System; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [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("MyMods")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("LootValueOnMap")] [assembly: AssemblyTitle("LootValueOnMap")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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; } } } [BepInPlugin("MyMods.LootValueOnMap", "LootValueOnMap", "1.0.1")] public sealed class LootValueOnMap : BaseUnityPlugin { public const string PluginGuid = "MyMods.LootValueOnMap"; public const string PluginName = "LootValueOnMap"; public const string PluginVersion = "1.0.1"; internal static ManualLogSource? ModLogger; internal static LootValueOnMap? Instance; internal static Color LabelColor = Color.yellow; internal static float LabelCharacterSize = 0.03f; internal static int LabelFontResolution = 64; internal static bool LabelBold = true; private Harmony? harmony; private bool settingsOpen; private Rect windowRect = new Rect(25f, 25f, 360f, 450f); private bool previousCursorVisible; private CursorLockMode previousCursorLockState; private void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown Instance = this; ModLogger = ((BaseUnityPlugin)this).Logger; harmony = new Harmony("MyMods.LootValueOnMap"); harmony.PatchAll(); ModLogger.LogInfo((object)"LootValueOnMap v1.0.1 has loaded!"); ModLogger.LogInfo((object)"Press F12 to open or close LootValueOnMap settings."); } private void Update() { if (Input.GetKeyDown((KeyCode)293)) { ToggleSettingsWindow(); } } private void LateUpdate() { if (settingsOpen) { ForceCursorVisible(); } } private void OnGUI() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (settingsOpen) { windowRect = GUI.Window(((Object)this).GetInstanceID(), windowRect, new WindowFunction(DrawSettingsWindow), "LootValueOnMap Settings"); } } private void DrawSettingsWindow(int windowId) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label("Settings apply to all active price labels.", Array.Empty<GUILayoutOption>()); GUILayout.Space(5f); Color labelColor = LabelColor; float labelCharacterSize = LabelCharacterSize; int labelFontResolution = LabelFontResolution; bool labelBold = LabelBold; GUILayout.Label("Color Presets:", Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Red", Array.Empty<GUILayoutOption>())) { ApplyColorPreset(Color.red); } if (GUILayout.Button("Green", Array.Empty<GUILayoutOption>())) { ApplyColorPreset(Color.green); } if (GUILayout.Button("Yellow", Array.Empty<GUILayoutOption>())) { ApplyColorPreset(Color.yellow); } if (GUILayout.Button("White", Array.Empty<GUILayoutOption>())) { ApplyColorPreset(Color.white); } if (GUILayout.Button("Black", Array.Empty<GUILayoutOption>())) { ApplyColorPreset(Color.black); } GUILayout.EndHorizontal(); float r = LabelColor.r; float g = LabelColor.g; float b = LabelColor.b; float a = LabelColor.a; GUILayout.Label("Text Red: " + r.ToString("0.00", CultureInfo.InvariantCulture), Array.Empty<GUILayoutOption>()); r = GUILayout.HorizontalSlider(r, 0f, 1f, Array.Empty<GUILayoutOption>()); GUILayout.Label("Text Green: " + g.ToString("0.00", CultureInfo.InvariantCulture), Array.Empty<GUILayoutOption>()); g = GUILayout.HorizontalSlider(g, 0f, 1f, Array.Empty<GUILayoutOption>()); GUILayout.Label("Text Blue: " + b.ToString("0.00", CultureInfo.InvariantCulture), Array.Empty<GUILayoutOption>()); b = GUILayout.HorizontalSlider(b, 0f, 1f, Array.Empty<GUILayoutOption>()); GUILayout.Label("Opacity: " + a.ToString("0.00", CultureInfo.InvariantCulture), Array.Empty<GUILayoutOption>()); a = GUILayout.HorizontalSlider(a, 0f, 1f, Array.Empty<GUILayoutOption>()); GUILayout.Space(4f); GUILayout.Label("Text Size: " + LabelCharacterSize.ToString("0.00", CultureInfo.InvariantCulture), Array.Empty<GUILayoutOption>()); LabelCharacterSize = GUILayout.HorizontalSlider(LabelCharacterSize, 0.02f, 0.4f, Array.Empty<GUILayoutOption>()); GUILayout.Label("Font Resolution: " + LabelFontResolution, Array.Empty<GUILayoutOption>()); LabelFontResolution = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)LabelFontResolution, 16f, 256f, Array.Empty<GUILayoutOption>())); LabelBold = GUILayout.Toggle(LabelBold, "Bold text", Array.Empty<GUILayoutOption>()); GUILayout.Space(8f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Reset defaults", Array.Empty<GUILayoutOption>())) { r = 1f; g = 1f; b = 0f; a = 1f; LabelCharacterSize = 0.03f; LabelFontResolution = 64; LabelBold = true; } if (GUILayout.Button("Close (F12)", Array.Empty<GUILayoutOption>())) { ToggleSettingsWindow(); } GUILayout.EndHorizontal(); LabelColor = new Color(r, g, b, a); if (labelColor != LabelColor || !Mathf.Approximately(labelCharacterSize, LabelCharacterSize) || labelFontResolution != LabelFontResolution || labelBold != LabelBold) { RefreshAll(); } GUI.DragWindow(new Rect(0f, 0f, 10000f, 24f)); } private void ToggleSettingsWindow() { //IL_0049: 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_002c: Unknown result type (might be due to invalid IL or missing references) settingsOpen = !settingsOpen; if (settingsOpen) { previousCursorVisible = Cursor.visible; previousCursorLockState = Cursor.lockState; ForceCursorVisible(); } else { Cursor.visible = previousCursorVisible; Cursor.lockState = previousCursorLockState; } } private void ForceCursorVisible() { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } private static void ApplyColorPreset(Color preset) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) LabelColor = new Color(preset.r, preset.g, preset.b, LabelColor.a); RefreshAll(); } internal static void RefreshAll() { MapValuablePriceLabelUpdater[] array = Object.FindObjectsOfType<MapValuablePriceLabelUpdater>(true); MapValuablePriceLabelUpdater[] array2 = array; foreach (MapValuablePriceLabelUpdater mapValuablePriceLabelUpdater in array2) { if ((Object)(object)mapValuablePriceLabelUpdater != (Object)null) { mapValuablePriceLabelUpdater.RefreshAppearance(); } } } internal static string FormatValue(float value) { if (float.IsNaN(value) || float.IsInfinity(value)) { return "?"; } float num = Mathf.Abs(value); if (num >= 1000000f) { return (value / 1000000f).ToString("0.#", CultureInfo.InvariantCulture) + "M"; } if (num >= 1000f) { return (value / 1000f).ToString("0.#", CultureInfo.InvariantCulture) + "K"; } return Mathf.RoundToInt(value).ToString(CultureInfo.InvariantCulture); } private void OnDestroy() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (harmony != null) { harmony.UnpatchSelf(); } if (settingsOpen) { Cursor.visible = previousCursorVisible; Cursor.lockState = previousCursorLockState; } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } [HarmonyPatch(typeof(MapValuable), "Start")] internal static class MapValuablePricePatch { private static void Postfix(MapValuable __instance) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_00c3: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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 ((Object)(object)__instance == (Object)null || (Object)(object)__instance.target == (Object)null || (Object)(object)((Component)__instance).GetComponentInChildren<MapValuablePriceLabelUpdater>(true) != (Object)null) { return; } SpriteRenderer val = __instance.spriteRenderer; if ((Object)(object)val == (Object)null) { val = ((Component)__instance).GetComponentInChildren<SpriteRenderer>(true); } if ((Object)(object)val == (Object)null) { ManualLogSource? modLogger = LootValueOnMap.ModLogger; if (modLogger != null) { modLogger.LogWarning((object)"Could not create a price label because the map marker has no SpriteRenderer."); } return; } GameObject val2 = new GameObject("LootValueOnMap_PriceLabel"); val2.layer = ((Component)val).gameObject.layer; val2.transform.SetParent(((Component)__instance).transform, false); val2.transform.localPosition = ((Component)__instance).transform.InverseTransformPoint(((Component)val).transform.position); val2.transform.localRotation = Quaternion.Inverse(((Component)__instance).transform.rotation) * ((Component)val).transform.rotation; val2.transform.localScale = ((Component)val).transform.localScale; TextMesh val3 = val2.AddComponent<TextMesh>(); val3.anchor = (TextAnchor)4; val3.alignment = (TextAlignment)1; val3.richText = false; val3.text = "..."; Font builtinResource = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf"); if ((Object)(object)builtinResource == (Object)null) { builtinResource = Resources.GetBuiltinResource<Font>("Arial.ttf"); } if ((Object)(object)builtinResource != (Object)null) { val3.font = builtinResource; } MeshRenderer component = val2.GetComponent<MeshRenderer>(); if ((Object)(object)component != (Object)null) { ((Renderer)component).sortingLayerID = ((Renderer)val).sortingLayerID; ((Renderer)component).sortingOrder = ((Renderer)val).sortingOrder + 100; } MapValuablePriceLabelUpdater mapValuablePriceLabelUpdater = val2.AddComponent<MapValuablePriceLabelUpdater>(); mapValuablePriceLabelUpdater.Initialize(__instance, val3, val); ManualLogSource? modLogger2 = LootValueOnMap.ModLogger; if (modLogger2 != null) { modLogger2.LogInfo((object)("Created live price label for " + ((Object)__instance.target).name)); } } } internal sealed class MapValuablePriceLabelUpdater : MonoBehaviour { private MapValuable? marker; private TextMesh? priceText; private SpriteRenderer? sourceSprite; private static readonly FieldInfo? CurrentValueField = AccessTools.Field(typeof(ValuableObject), "dollarValueCurrent"); internal void Initialize(MapValuable mapMarker, TextMesh textMesh, SpriteRenderer originalSprite) { marker = mapMarker; priceText = textMesh; sourceSprite = originalSprite; HideOriginalMarker(); UpdateLabelTransform(); RefreshAppearance(); RefreshPrice(); } private void LateUpdate() { if ((Object)(object)marker == (Object)null || (Object)(object)marker.target == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } HideOriginalMarker(); UpdateLabelTransform(); RefreshPrice(); } private void HideOriginalMarker() { if ((Object)(object)sourceSprite != (Object)null) { ((Renderer)sourceSprite).enabled = false; } if ((Object)(object)marker != (Object)null && (Object)(object)marker.spriteRenderer != (Object)null) { ((Renderer)marker.spriteRenderer).enabled = false; } } private void UpdateLabelTransform() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)marker == (Object)null) && !((Object)(object)sourceSprite == (Object)null)) { ((Component)this).transform.localPosition = ((Component)marker).transform.InverseTransformPoint(((Component)sourceSprite).transform.position); ((Component)this).transform.localRotation = Quaternion.Inverse(((Component)marker).transform.rotation) * ((Component)sourceSprite).transform.rotation; } } internal void RefreshAppearance() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)priceText == (Object)null) { return; } priceText.color = LootValueOnMap.LabelColor; priceText.characterSize = LootValueOnMap.LabelCharacterSize; priceText.fontSize = LootValueOnMap.LabelFontResolution; priceText.fontStyle = (FontStyle)(LootValueOnMap.LabelBold ? 1 : 0); if ((Object)(object)sourceSprite != (Object)null) { MeshRenderer component = ((Component)priceText).GetComponent<MeshRenderer>(); if ((Object)(object)component != (Object)null) { ((Renderer)component).sortingLayerID = ((Renderer)sourceSprite).sortingLayerID; ((Renderer)component).sortingOrder = ((Renderer)sourceSprite).sortingOrder + 100; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; } } } private void RefreshPrice() { MapValuable val = marker; TextMesh val2 = priceText; if ((Object)(object)val == (Object)null || (Object)(object)val.target == (Object)null || (Object)(object)val2 == (Object)null) { return; } if (CurrentValueField == null) { val2.text = "?"; return; } try { object value = CurrentValueField.GetValue(val.target); if (value != null) { float value2 = Convert.ToSingle(value, CultureInfo.InvariantCulture); string text = LootValueOnMap.FormatValue(value2); if (val2.text != text) { val2.text = text; } } } catch (Exception ex) { ManualLogSource? modLogger = LootValueOnMap.ModLogger; if (modLogger != null) { modLogger.LogDebug((object)("Could not refresh a valuable price: " + ex.Message)); } } } }