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 SharedUpgrades Patch v1.0.2
SharedUpgradesPatch.dll
Decompiled 6 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 HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; 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("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SharedUpgradesPatch")] [assembly: AssemblyTitle("SharedUpgradesPatch")] [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 SharedUpgradesCompat { [BepInPlugin("Empress.SharedUpgradesCompat", "Shared Upgrades Compat", "1.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class SharedUpgradesCompatPlugin : BaseUnityPlugin { public const string PluginGuid = "Empress.SharedUpgradesCompat"; public const string PluginName = "Shared Upgrades Compat"; public const string PluginVersion = "1.2.0"; internal static SharedUpgradesCompatPlugin Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; private set; } private void Awake() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Harmony = new Harmony("Empress.SharedUpgradesCompat"); Harmony.PatchAll(); Logger.LogInfo((object)"Empress.SharedUpgradesCompat v1.2.0 loaded"); } private void OnDestroy() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } internal static class CompatUpgradesSynchronizer { private static readonly Dictionary<string, int> previousMax = new Dictionary<string, int>(); private static bool IsMaster() { if (!SemiFunc.IsMultiplayer()) { return true; } return PhotonNetwork.IsMasterClient; } internal static void Sync(bool forced) { if (!IsMaster()) { return; } StatsManager instance = StatsManager.instance; if ((Object)(object)instance == (Object)null) { return; } Dictionary<string, Dictionary<string, int>> dictionaryOfDictionaries = instance.dictionaryOfDictionaries; if (dictionaryOfDictionaries == null || dictionaryOfDictionaries.Count == 0 || SemiFunc.MenuLevel()) { return; } List<string> list = dictionaryOfDictionaries.Keys.Where((string k) => k?.StartsWith("playerUpgrade", StringComparison.Ordinal) ?? false).ToList(); if (list.Count == 0) { return; } Dictionary<string, int> dictionary = new Dictionary<string, int>(list.Count); foreach (string item in list) { if (dictionaryOfDictionaries.TryGetValue(item, out var value) && value != null && value.Count > 0) { dictionary[item] = value.Values.Max(); } } if (!forced && !dictionary.Any((KeyValuePair<string, int> kv) => !previousMax.TryGetValue(kv.Key, out var value2) || value2 != kv.Value)) { return; } foreach (KeyValuePair<string, int> item2 in dictionary) { instance.DictionaryFill(item2.Key, item2.Value); } SemiFunc.StatSyncAll(); previousMax.Clear(); foreach (KeyValuePair<string, int> item3 in dictionary) { previousMax[item3.Key] = item3.Value; } } internal static void ResetCache() { if (IsMaster()) { previousMax.Clear(); } } } [HarmonyPatch(typeof(RunManager))] [HarmonyAfter(new string[] { "Traktool.SharedUpgrades" })] [HarmonyPriority(0)] internal static class RunManager_ChangeLevel_CompatPatch { [HarmonyPatch("ChangeLevel")] [HarmonyPrefix] private static void Prefix() { CompatUpgradesSynchronizer.Sync(forced: true); } } [HarmonyPatch(typeof(StatsManager))] [HarmonyAfter(new string[] { "Traktool.SharedUpgrades" })] [HarmonyPriority(0)] internal static class StatsManager_ResetAllStats_CompatPatch { [HarmonyPatch("ResetAllStats")] [HarmonyPostfix] private static void Postfix() { CompatUpgradesSynchronizer.ResetCache(); } } [HarmonyPatch(typeof(StatsManager))] [HarmonyAfter(new string[] { "Traktool.SharedUpgrades" })] [HarmonyPriority(0)] internal static class StatsManager_Update_CompatPatch { [HarmonyPatch("Update")] [HarmonyPrefix] private static void Prefix() { CompatUpgradesSynchronizer.Sync(forced: false); } } [HarmonyPatch(typeof(StatsManager))] [HarmonyAfter(new string[] { "Traktool.SharedUpgrades" })] [HarmonyPriority(0)] internal static class StatsManager_PlayerAdd_CompatPatch { [HarmonyPatch("PlayerAdd")] [HarmonyPostfix] private static void Postfix() { CompatUpgradesSynchronizer.Sync(forced: true); } } }