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 RandomValueLib v1.0.3
plugins/RandomValueModLib.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("RandomValueModLib")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("RandomValueModLib")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("246d11df-ddf0-40bf-9d24-9860ab131ee9")] [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 RandomValueLib; public class RandomizationConfig { public float MinMultiplier { get; set; } = 0.5f; public float MaxMultiplier { get; set; } = 2f; public bool EnableBlacklist { get; set; } = true; public List<string> BlacklistKeywords { get; set; } = new List<string>(); public bool EnableWhitelist { get; set; } = false; public List<string> WhitelistKeywords { get; set; } = new List<string>(); public bool ExcludeHighValueItems { get; set; } = false; public float HighValueThreshold { get; set; } = 50000f; public bool RandomizeCashBags { get; set; } = false; } public static class RandomValueService { private static FieldInfo dollarValueCurrentField; private static FieldInfo dollarValueOriginalField; static RandomValueService() { Type typeFromHandle = typeof(ValuableObject); dollarValueCurrentField = typeFromHandle.GetField("dollarValueCurrent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); dollarValueOriginalField = typeFromHandle.GetField("dollarValueOriginal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } public static float GetItemPrice(ValuableObject vo) { if (dollarValueCurrentField == null) { return 0f; } return (float)dollarValueCurrentField.GetValue(vo); } public static void SetItemPrice(ValuableObject vo, float newPrice) { dollarValueCurrentField?.SetValue(vo, newPrice); dollarValueOriginalField?.SetValue(vo, newPrice); } public static float GetRandomPrice(int instanceID, float originalPrice, RandomizationConfig config, int? extraSeed = null) { float num = Math.Max(0.1f, config.MinMultiplier); float num2 = Math.Max(num + 0.1f, config.MaxMultiplier); int num3 = instanceID; if (extraSeed.HasValue) { num3 ^= extraSeed.Value; } Random random = new Random(num3); float num4 = (float)(random.NextDouble() * (double)(num2 - num) + (double)num); float result = originalPrice; if (originalPrice > 0f) { result = originalPrice * num4; result = Mathf.Clamp(result, 1f, 1000000f); } return result; } public static bool ShouldRandomize(GameObject obj, RandomizationConfig config) { string name = ((Object)obj).name.ToLower(); if (name.Contains("surplus") && !config.RandomizeCashBags) { return false; } if (config.ExcludeHighValueItems) { ValuableObject component = obj.GetComponent<ValuableObject>(); if ((Object)(object)component != (Object)null && GetItemPrice(component) >= config.HighValueThreshold) { return false; } } if (config.EnableBlacklist && config.BlacklistKeywords.Any((string k) => name.Contains(k))) { return false; } if (config.EnableWhitelist && !config.WhitelistKeywords.Any((string k) => name.Contains(k))) { return false; } return true; } public static float ApplyRandomPrice(ValuableObject vo, RandomizationConfig config, int? extraSeed = null) { if ((Object)(object)vo == (Object)null) { return 0f; } int instanceID = ((Object)((Component)vo).gameObject).GetInstanceID(); float itemPrice = GetItemPrice(vo); if (itemPrice <= 0f) { return itemPrice; } if (!ShouldRandomize(((Component)vo).gameObject, config)) { return itemPrice; } float randomPrice = GetRandomPrice(instanceID, itemPrice, config, extraSeed); SetItemPrice(vo, randomPrice); return randomPrice; } } public static class ValuableObjectExtensions { public static float ApplyRandomPrice(this ValuableObject vo, RandomizationConfig config, int? extraSeed = null) { return RandomValueService.ApplyRandomPrice(vo, config, extraSeed); } }