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 BalancedSharedUpgrades v0.1.2
BalancedSharedUpgrades.dll
Decompiled a week agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BalancedSharedUpgrades; using BepInEx; using BepInEx.Logging; 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("BalancedSharedUpgrades")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+92e2f7034f2ee670f66549d83324dcff8c24f49b")] [assembly: AssemblyProduct("Balanced Shared Upgrades")] [assembly: AssemblyTitle("BalancedSharedUpgrades")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 BalanceSharedUpgrades.patches { [HarmonyPatch(typeof(ShopManager))] public static class ShopManagerPatch { [HarmonyPostfix] [HarmonyPatch("UpgradeValueGet")] private static void MultiplyPrice(ref float __result, Item item) { int count = GameDirector.instance.PlayerList.Count; Plugin.Logger.LogDebug((object)$"Multiplying {((Object)item).name}'s value of {__result} by {count}"); __result *= count; } } } namespace BalancedSharedUpgrades { [HarmonyPatch(typeof(PhysGrabObjectImpactDetector))] public class PhysGrabObjectImpactDetectorPatch { public static bool suppressDestruction; [HarmonyPrefix] [HarmonyPatch("DestroyObject")] public static bool SuppressDestroy() { return !suppressDestruction; } } [BepInPlugin("mitzapper2.REPO.BalancedSharedUpgrades", "Balanced Shared Upgrades", "0.1.2")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; public const string GUID = "mitzapper2.REPO.BalancedSharedUpgrades"; public const string NAME = "Balanced Shared Upgrades"; public const string VERSION = "0.1.2"; private readonly Harmony harmony = new Harmony("mitzapper2.REPO.BalancedSharedUpgrades"); private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Balanced Shared Upgrades v0.1.2 is loaded!"); harmony.PatchAll(); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "BalancedSharedUpgrades"; public const string PLUGIN_NAME = "Balanced Shared Upgrades"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace BalancedSharedUpgrades.patches { public class ItemToggleAccess(ItemToggle toggle) { public int playerTogglePhotonID { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return new Traverse((object)toggle).Field("playerTogglePhotonID").GetValue<int>(); } set { //IL_0006: Unknown result type (might be due to invalid IL or missing references) new Traverse((object)toggle).Field("playerTogglePhotonID").SetValue((object)value); } } } [HarmonyPatch(typeof(ItemUpgrade))] public class ItemUpgradePatch { private static bool Recurse = true; private static bool Restore { get { return PhysGrabObjectImpactDetectorPatch.suppressDestruction; } set { PhysGrabObjectImpactDetectorPatch.suppressDestruction = value; } } [HarmonyPrefix] [HarmonyPatch("PlayerUpgrade")] public static bool UpgradeAll(ItemUpgrade __instance) { if (!Recurse) { return true; } Recurse = false; ItemToggle component = ((Component)__instance).GetComponent<ItemToggle>(); if ((Object)(object)component == (Object)null) { Plugin.Logger.LogError((object)$"Could not find ItemToggle neighboring {__instance}"); } ItemToggleAccess itemToggleAccess = new ItemToggleAccess(component); int playerTogglePhotonID = itemToggleAccess.playerTogglePhotonID; Plugin.Logger.LogInfo((object)$"Player with photon ID {playerTogglePhotonID} using upgrade {((Object)__instance).name}"); Restore = true; UpgradeOtherPlayers(__instance, playerTogglePhotonID); Restore = false; UpgradePlayer(__instance, playerTogglePhotonID); Recurse = true; return false; } [HarmonyPostfix] [HarmonyPatch("PlayerUpgrade")] public static void RestoreUpgradeDestruction(ItemUpgrade __instance) { if (Restore) { Plugin.Logger.LogDebug((object)"Undoing upgrade usage"); ItemUpgradeAccess itemUpgradeAccess = new ItemUpgradeAccess(__instance) { upgradeDone = false }; RestoreStatsManagerItemsPurchased(itemUpgradeAccess.itemAttributes); } } public static void UpgradeOtherPlayers(ItemUpgrade instance, int primaryPhotonId) { foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { int viewID = player.photonView.ViewID; if (viewID != primaryPhotonId) { UpgradePlayer(instance, viewID); } } } public static void UpgradePlayer(ItemUpgrade instance, int photonId) { ItemToggle component = ((Component)instance).GetComponent<ItemToggle>(); if ((Object)(object)component == (Object)null) { Plugin.Logger.LogError((object)$"Could not find ItemToggle neighboring {instance}"); return; } Plugin.Logger.LogDebug((object)$"Granting player {photonId} upgrade {((Object)instance).name}..."); new ItemToggleAccess(component).playerTogglePhotonID = photonId; instance.PlayerUpgrade(); } public static void RestoreStatsManagerItemsPurchased(ItemAttributes itemAttributes) { if (!StatsManager.instance.itemsPurchased.TryGetValue(((Object)itemAttributes.item).name, out var value)) { value = 0; } StatsManager.instance.itemsPurchased[((Object)itemAttributes.item).name] = value + 1; } } public class ItemUpgradeAccess { protected Traverse<bool> upgradeDoneField = new Traverse((object)inner).Field<bool>("upgradeDone"); protected Traverse<ItemAttributes> itemAttributesField = new Traverse((object)inner).Field<ItemAttributes>("itemAttributes"); public bool upgradeDone { get { return upgradeDoneField.Value; } set { upgradeDoneField.Value = value; } } public ItemAttributes itemAttributes => itemAttributesField.Value; public ItemUpgradeAccess(ItemUpgrade inner) { }//IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) } }