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 ScrapAveragesUtility v1.0.1
BepInEx/plugins/ScrapAveragesUtility/com.github.xuuxiaolan.scrapaveragesutility.dll
Decompiled 4 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using Dawn; using Dawn.Internal; using Dawn.Utils; using Microsoft.CodeAnalysis; using MonoMod.RuntimeDetour; using On; using ScrapAveragesUtility.Patches; using UnityEngine; using com.github.xuuxiaolan.scrapaveragesutility.NetcodePatcher; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("com.github.teamxiaolan.dawnlib")] [assembly: AssemblyCompany("com.github.xuuxiaolan.scrapaveragesutility")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("ScrapAveragesUtility")] [assembly: AssemblyTitle("com.github.xuuxiaolan.scrapaveragesutility")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] 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 ScrapAveragesUtility { [BepInPlugin("com.github.xuuxiaolan.scrapaveragesutility", "ScrapAveragesUtility", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ScrapAveragesUtility : BaseUnityPlugin { internal static ManualLogSource Logger { get; private set; } internal static PersistentDataContainer PersistentData { get; private set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; PersistentData = BepInPluginExtensions.GetPersistentDataContainer((BaseUnityPlugin)(object)this); TerminalPatches.Init(); ((DataContainer)PersistentData).Set<string>(ScrapAveragesUtilityKeys.LastVersion, "1.0.1"); Logger.LogInfo((object)"com.github.xuuxiaolan.scrapaveragesutility v1.0.1 has loaded!"); } } public static class ScrapAveragesUtilityKeys { public const string Namespace = "scrap_averages_utility"; internal static NamespacedKey LastVersion = NamespacedKey.From("scrap_averages_utility", "last_version"); } public class WeightedItem : IWeighted { public Item item; public int weight; public int GetWeight() { return weight; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.github.xuuxiaolan.scrapaveragesutility"; public const string PLUGIN_NAME = "ScrapAveragesUtility"; public const string PLUGIN_VERSION = "1.0.1"; } } namespace ScrapAveragesUtility.Patches { internal static class TerminalPatches { [CompilerGenerated] private static class <>O { public static hook_Start <0>__Terminal_Start; public static hook_TextPostProcess <1>__Terminal_TextPostProcess; } private static bool doneAlready; public static void Init() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_003b: 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) //IL_0046: Expected O, but got Unknown DetourContext val = new DetourContext(9999); try { object obj = <>O.<0>__Terminal_Start; if (obj == null) { hook_Start val2 = Terminal_Start; <>O.<0>__Terminal_Start = val2; obj = (object)val2; } Terminal.Start += (hook_Start)obj; object obj2 = <>O.<1>__Terminal_TextPostProcess; if (obj2 == null) { hook_TextPostProcess val3 = Terminal_TextPostProcess; <>O.<1>__Terminal_TextPostProcess = val3; obj2 = (object)val3; } Terminal.TextPostProcess += (hook_TextPostProcess)obj2; } finally { ((IDisposable)val)?.Dispose(); } } private static string Terminal_TextPostProcess(orig_TextPostProcess orig, Terminal self, string modifiedDisplayText, TerminalNode node) { if (((Object)node).name.StartsWith("STestResult_")) { int displayPlanetInfo = node.displayPlanetInfo; SelectableLevel val = StartOfRound.Instance.levels[displayPlanetInfo]; List<WeightedItem> list = new List<WeightedItem>(); foreach (SpawnableItemWithRarity item in val.spawnableScrap) { list.Add(new WeightedItem { item = item.spawnableItem, weight = item.rarity }); } int num = 500; float num2 = 0f; Random random = new Random(Random.Range(0, int.MaxValue)); for (int i = 0; i < num; i++) { int num3 = Random.Range(val.minScrap, val.maxScrap + 1); for (int j = 0; j < num3; j++) { WeightedItem weightedItem = RandomExtensions.NextWeighted<WeightedItem>(random, (IList<WeightedItem>)list); num2 += (float)Random.Range(weightedItem.item.minValue, weightedItem.item.maxValue) * 0.4f; } } modifiedDisplayText = modifiedDisplayText.Replace("[calculated value here]", $"{num2 / (float)num:0.00}"); } return orig.Invoke(self, modifiedDisplayText, node); } private static void Terminal_Start(orig_Start orig, Terminal self) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown orig.Invoke(self); if (!doneAlready) { TerminalKeyword val = new TerminalKeywordBuilder("STest", "stest", (DawnKeywordType)8).SetIsVerb(true).Build(); List<CompatibleNoun> list = new List<CompatibleNoun>(); TerminalKeyword routeKeyword = TerminalRefs.RouteKeyword; CompatibleNoun[] compatibleNouns = routeKeyword.compatibleNouns; foreach (CompatibleNoun val2 in compatibleNouns) { list.Add(new CompatibleNoun { noun = val2.noun, result = new TerminalNodeBuilder("STestResult_" + StartOfRound.Instance.levels[val2.result.terminalOptions[1].result.buyRerouteToMoon].PlanetName).SetClearPreviousText(true).SetDisplayText("Average scrap value on " + StartOfRound.Instance.levels[val2.result.terminalOptions[1].result.buyRerouteToMoon].PlanetName + ": [calculated value here]\n\n").Build() }); list[list.Count - 1].result.displayPlanetInfo = val2.result.terminalOptions[1].result.buyRerouteToMoon; } val.compatibleNouns = list.ToArray(); List<TerminalKeyword> list2 = TerminalRefs.Instance.terminalNodes.allKeywords.ToList(); list2.Add(val); TerminalRefs.Instance.terminalNodes.allKeywords = list2.ToArray(); doneAlready = true; } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace com.github.xuuxiaolan.scrapaveragesutility.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }