using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; 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: AssemblyCompany("TooltipValue")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TooltipValue")] [assembly: AssemblyTitle("TooltipValue")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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; } } } namespace TooltipValue { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Harchytek.TooltipValue", "TooltipValue", "1.0.1")] public class TooltipValuePlugin : BaseUnityPlugin { public const string ModGUID = "Harchytek.TooltipValue"; public const string ModName = "TooltipValue"; public const string ModVersion = "1.0.1"; private readonly Harmony harmony = new Harmony("Harchytek.TooltipValue"); private void Awake() { harmony.PatchAll(); } } [HarmonyPatch(typeof(ObjectDB), "Awake")] public static class ApplyPricesToObjectDBPatch { private static void Postfix(ObjectDB __instance) { Dictionary dictionary = ReadTradersExtendedJsonFiles(); if (dictionary.Count == 0) { Debug.LogWarning((object)"[TooltipValue] No prices found or TradersExtended is not configured."); return; } int num = 0; ItemDrop val = default(ItemDrop); foreach (KeyValuePair item in dictionary) { string key = item.Key; int value = item.Value; GameObject itemPrefab = __instance.GetItemPrefab(key); if (itemPrefab != null && itemPrefab.TryGetComponent(ref val)) { val.m_itemData.m_shared.m_value = value; num++; } } Debug.Log((object)string.Format("[{0}] Processed {1} configured items and updates {2} items that were not previously updated.", "TooltipValue", dictionary.Count, num)); } private static Dictionary ReadTradersExtendedJsonFiles() { Dictionary dictionary = new Dictionary(); string[] array = new string[2] { Paths.ConfigPath, Path.Combine(Paths.ConfigPath, "shudnal.TradersExtended") }; string[] array2 = array; foreach (string path in array2) { if (!Directory.Exists(path)) { continue; } string[] files = Directory.GetFiles(path, "*sell.json"); string[] array3 = files; foreach (string text in array3) { if (!Path.GetFileName(text).StartsWith("shudnal.TradersExtended", StringComparison.OrdinalIgnoreCase)) { continue; } try { string input = File.ReadAllText(text); MatchCollection matchCollection = Regex.Matches(input, "\\{[^{}]+\\}"); foreach (Match item in matchCollection) { string value = item.Value; Match match2 = Regex.Match(value, "\"prefab\"\\s*:\\s*\"([^\"]+)\""); Match match3 = Regex.Match(value, "\"stack\"\\s*:\\s*(\\d+)"); Match match4 = Regex.Match(value, "\"price\"\\s*:\\s*(\\d+)"); if (!match2.Success || !match4.Success) { continue; } string value2 = match2.Groups[1].Value; int num = int.Parse(match4.Groups[1].Value); if (num > 0) { int num2 = 1; if (match3.Success) { num2 = int.Parse(match3.Groups[1].Value); } int num3 = num / num2; if (num3 <= 0) { num3 = 1; } if (!dictionary.ContainsKey(value2)) { dictionary.Add(value2, num3); } } } } catch (Exception ex) { Debug.LogError((object)("[TooltipValue] Error reading file " + text + ": " + ex.Message)); } } } return dictionary; } } }