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 SharedUpgradesChance v1.1.0
SharedUpgradesChance.dll
Decompiled a year agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; 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: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Autodesk.Fbx")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")] [assembly: IgnoresAccessChecksTo("Klattersynth")] [assembly: IgnoresAccessChecksTo("Photon3Unity3D")] [assembly: IgnoresAccessChecksTo("PhotonChat")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")] [assembly: IgnoresAccessChecksTo("PhotonVoice.API")] [assembly: IgnoresAccessChecksTo("PhotonVoice")] [assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization")] [assembly: IgnoresAccessChecksTo("Sirenix.Utilities")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("websocket-sharp")] [assembly: AssemblyCompany("khalliv")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SharedUpgradesChance")] [assembly: AssemblyTitle("SharedUpgradesChance")] [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 SharedUpgradesChance { [BepInPlugin("khalliv.SharedUpgradesChance", "SharedUpgradesChance", "1.1.0")] public class SharedUpgradesChance : BaseUnityPlugin { internal static ConfigEntry<bool> ApplyForAllUpgrades; internal static ConfigEntry<int> ChanceToWasteUpgrade; internal static ConfigEntry<int> GlobalChanceToActivate; internal static ConfigEntry<int> ChanceToActivateMapPlayerCount; internal static ConfigEntry<int> ChanceToActivatePlayerEnergy; internal static ConfigEntry<int> ChanceToActivatePlayerExtraJump; internal static ConfigEntry<int> ChanceToActivatePlayerGrabRange; internal static ConfigEntry<int> ChanceToActivatePlayerGrabStrength; internal static ConfigEntry<int> ChanceToActivatePlayerGrabThrow; internal static ConfigEntry<int> ChanceToActivatePlayerHealth; internal static ConfigEntry<int> ChanceToActivatePlayerSprintSpeed; internal static ConfigEntry<int> ChanceToActivatePlayerTumbleLaunch; internal static SharedUpgradesChance Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; SetupConfigs(); Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(typeof(UpgradesPatches)); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void SetupConfigs() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Expected O, but got Unknown //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Expected O, but got Unknown //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected O, but got Unknown //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Expected O, but got Unknown ApplyForAllUpgrades = ((BaseUnityPlugin)this).Config.Bind<bool>("Global", "UseOneChanceForAll", true, new ConfigDescription("If true, the GlobalChanceForActivate will be used for all upgrades", (AcceptableValueBase)null, Array.Empty<object>())); GlobalChanceToActivate = ((BaseUnityPlugin)this).Config.Bind<int>("Global", "GlobalChanceToActivate", 25, new ConfigDescription("% Chance to activate the upgrade for every player", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToWasteUpgrade = ((BaseUnityPlugin)this).Config.Bind<int>("Global", "ChanceToWasteUpgrade", 0, new ConfigDescription("% Chance to waste the upgrade and activate it for nobody", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivateMapPlayerCount = ((BaseUnityPlugin)this).Config.Bind<int>("SpecificUpgrades", "ChanceToActivateMapPlayerCount", 25, new ConfigDescription("% Chance to activate the upgrade for every player", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerEnergy = ((BaseUnityPlugin)this).Config.Bind<int>("SpecificUpgrades", "ChanceToActivatePlayerEnergy", 25, new ConfigDescription("% Chance to activate the upgrade for every player", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerExtraJump = ((BaseUnityPlugin)this).Config.Bind<int>("SpecificUpgrades", "ChanceToActivatePlayerExtraJump", 25, new ConfigDescription("% Chance to activate the upgrade for every player", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerGrabRange = ((BaseUnityPlugin)this).Config.Bind<int>("SpecificUpgrades", "ChanceToActivatePlayerGrabRange", 25, new ConfigDescription("% Chance to activate the upgrade for every player", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerGrabStrength = ((BaseUnityPlugin)this).Config.Bind<int>("SpecificUpgrades", "ChanceToActivatePlayerGrabStrength", 25, new ConfigDescription("% Chance to activate the upgrade for every player", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerGrabThrow = ((BaseUnityPlugin)this).Config.Bind<int>("SpecificUpgrades", "ChanceToActivatePlayerGrabThrow", 25, new ConfigDescription("% Chance to activate the upgrade for every player", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerHealth = ((BaseUnityPlugin)this).Config.Bind<int>("SpecificUpgrades", "ChanceToActivatePlayerHealth", 25, new ConfigDescription("% Chance to activate the upgrade for every player", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerSprintSpeed = ((BaseUnityPlugin)this).Config.Bind<int>("SpecificUpgrades", "ChanceToActivatePlayerSprintSpeed", 25, new ConfigDescription("% Chance to activate the upgrade for every player", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerTumbleLaunch = ((BaseUnityPlugin)this).Config.Bind<int>("SpecificUpgrades", "ChanceToActivatePlayerTumbleLaunch", 25, new ConfigDescription("% Chance to activate the upgrade for every player", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); } } internal class UpgradesPatches { private static bool ShouldUpgradeForAllPlayers(string upgradeType, int threshold = -1) { threshold = ((threshold == -1) ? SharedUpgradesChance.GlobalChanceToActivate.Value : threshold); if (threshold < 1) { return false; } int num = Random.Range(1, 101); bool flag = num <= threshold; SharedUpgradesChance.Logger.LogInfo((object)($"{upgradeType}: Shared upgrade roll was {num}; Needed for activation is <={threshold};" + (flag ? " Awarding upgrade for everyone!" : " Only the activating player gets the upgrade."))); return flag; } private static bool ShouldWasteUpgrade(string upgradeType) { if (SharedUpgradesChance.ChanceToWasteUpgrade.Value < 1) { return false; } int num = Random.Range(1, 101); bool flag = num <= SharedUpgradesChance.ChanceToWasteUpgrade.Value; string text = $"{upgradeType}: Waste upgrade roll was {num}; Needed for activation is <={SharedUpgradesChance.ChanceToWasteUpgrade.Value}; "; text += (flag ? "Upgrade wasted, nobody gets it." : "Upgrade not wasted, activating player gets it."); SharedUpgradesChance.Logger.LogInfo((object)text); return flag; } [HarmonyPatch(typeof(ItemUpgradeMapPlayerCount), "Upgrade")] [HarmonyPrefix] private static bool UpgradeMapPlayerCountPatch(ItemUpgradeMapPlayerCount __instance) { string upgradeType = "Map player count"; if (ShouldWasteUpgrade(upgradeType)) { return false; } string text = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID(__instance.itemToggle.playerTogglePhotonID)); PunManager.instance.UpgradeMapPlayerCount(text); int threshold = (SharedUpgradesChance.ApplyForAllUpgrades.Value ? (-1) : SharedUpgradesChance.ChanceToActivateMapPlayerCount.Value); if (!ShouldUpgradeForAllPlayers(upgradeType, threshold)) { return false; } foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { string text2 = SemiFunc.PlayerGetSteamID(item); if (!(text2 == text)) { PunManager.instance.UpgradeMapPlayerCount(text2); } } return false; } [HarmonyPatch(typeof(ItemUpgradePlayerEnergy), "Upgrade")] [HarmonyPrefix] private static bool UpgradePlayerEnergyPatch(ItemUpgradePlayerEnergy __instance) { string upgradeType = "Player energy"; if (ShouldWasteUpgrade(upgradeType)) { return false; } string text = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID(__instance.itemToggle.playerTogglePhotonID)); PunManager.instance.UpgradePlayerEnergy(text); int threshold = (SharedUpgradesChance.ApplyForAllUpgrades.Value ? (-1) : SharedUpgradesChance.ChanceToActivatePlayerEnergy.Value); if (!ShouldUpgradeForAllPlayers(upgradeType, threshold)) { return false; } foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { string text2 = SemiFunc.PlayerGetSteamID(item); if (!(text2 == text)) { PunManager.instance.UpgradePlayerEnergy(text2); } } return false; } [HarmonyPatch(typeof(ItemUpgradePlayerExtraJump), "Upgrade")] [HarmonyPrefix] private static bool UpgradePlayerExtraJumpPatch(ItemUpgradePlayerExtraJump __instance) { string upgradeType = "Player extra jump"; if (ShouldWasteUpgrade(upgradeType)) { return false; } string text = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID(__instance.itemToggle.playerTogglePhotonID)); PunManager.instance.UpgradePlayerExtraJump(text); int threshold = (SharedUpgradesChance.ApplyForAllUpgrades.Value ? (-1) : SharedUpgradesChance.ChanceToActivatePlayerExtraJump.Value); if (!ShouldUpgradeForAllPlayers(upgradeType, threshold)) { return false; } foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { string text2 = SemiFunc.PlayerGetSteamID(item); if (!(text2 == text)) { PunManager.instance.UpgradePlayerExtraJump(text2); } } return false; } [HarmonyPatch(typeof(ItemUpgradePlayerGrabRange), "Upgrade")] [HarmonyPrefix] private static bool UpgradePlayerGrabRangePatch(ItemUpgradePlayerGrabRange __instance) { string upgradeType = "Player grab range"; if (ShouldWasteUpgrade(upgradeType)) { return false; } string text = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID(__instance.itemToggle.playerTogglePhotonID)); PunManager.instance.UpgradePlayerGrabRange(text); int threshold = (SharedUpgradesChance.ApplyForAllUpgrades.Value ? (-1) : SharedUpgradesChance.ChanceToActivatePlayerGrabRange.Value); if (!ShouldUpgradeForAllPlayers(upgradeType, threshold)) { return false; } foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { string text2 = SemiFunc.PlayerGetSteamID(item); if (!(text2 == text)) { PunManager.instance.UpgradePlayerGrabRange(text2); } } return false; } [HarmonyPatch(typeof(ItemUpgradePlayerGrabStrength), "Upgrade")] [HarmonyPrefix] private static bool UpgradePlayerGrabStrengthPatch(ItemUpgradePlayerGrabStrength __instance) { string upgradeType = "Player grab strength"; if (ShouldWasteUpgrade(upgradeType)) { return false; } string text = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID(__instance.itemToggle.playerTogglePhotonID)); PunManager.instance.UpgradePlayerGrabStrength(text); int threshold = (SharedUpgradesChance.ApplyForAllUpgrades.Value ? (-1) : SharedUpgradesChance.ChanceToActivatePlayerGrabStrength.Value); if (!ShouldUpgradeForAllPlayers(upgradeType, threshold)) { return false; } foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { string text2 = SemiFunc.PlayerGetSteamID(item); if (!(text2 == text)) { PunManager.instance.UpgradePlayerGrabStrength(text2); } } return false; } [HarmonyPatch(typeof(ItemUpgradePlayerGrabThrow), "Upgrade")] [HarmonyPrefix] private static bool UpgradePlayerGrabThrowPatch(ItemUpgradePlayerGrabThrow __instance) { string upgradeType = "Player grab throw"; if (ShouldWasteUpgrade(upgradeType)) { return false; } string text = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID(__instance.itemToggle.playerTogglePhotonID)); PunManager.instance.UpgradePlayerThrowStrength(text); int threshold = (SharedUpgradesChance.ApplyForAllUpgrades.Value ? (-1) : SharedUpgradesChance.ChanceToActivatePlayerGrabThrow.Value); if (!ShouldUpgradeForAllPlayers(upgradeType, threshold)) { return false; } foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { string text2 = SemiFunc.PlayerGetSteamID(item); if (!(text2 == text)) { PunManager.instance.UpgradePlayerThrowStrength(text2); } } return false; } [HarmonyPatch(typeof(ItemUpgradePlayerHealth), "Upgrade")] [HarmonyPrefix] private static bool UpgradePlayerHealthPatch(ItemUpgradePlayerHealth __instance) { string upgradeType = "Player health"; if (ShouldWasteUpgrade(upgradeType)) { return false; } string text = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID(__instance.itemToggle.playerTogglePhotonID)); PunManager.instance.UpgradePlayerHealth(text); int threshold = (SharedUpgradesChance.ApplyForAllUpgrades.Value ? (-1) : SharedUpgradesChance.ChanceToActivatePlayerHealth.Value); if (!ShouldUpgradeForAllPlayers(upgradeType, threshold)) { return false; } foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { string text2 = SemiFunc.PlayerGetSteamID(item); if (!(text2 == text)) { PunManager.instance.UpgradePlayerHealth(text2); } } return false; } [HarmonyPatch(typeof(ItemUpgradePlayerSprintSpeed), "Upgrade")] [HarmonyPrefix] private static bool UpgradePlayerSprintSpeedPatch(ItemUpgradePlayerSprintSpeed __instance) { string upgradeType = "Player sprint speed"; if (ShouldWasteUpgrade(upgradeType)) { return false; } string text = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID(__instance.itemToggle.playerTogglePhotonID)); PunManager.instance.UpgradePlayerSprintSpeed(text); int threshold = (SharedUpgradesChance.ApplyForAllUpgrades.Value ? (-1) : SharedUpgradesChance.ChanceToActivatePlayerSprintSpeed.Value); if (!ShouldUpgradeForAllPlayers(upgradeType, threshold)) { return false; } foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { string text2 = SemiFunc.PlayerGetSteamID(item); if (!(text2 == text)) { PunManager.instance.UpgradePlayerSprintSpeed(text2); } } return false; } [HarmonyPatch(typeof(ItemUpgradePlayerTumbleLaunch), "Upgrade")] [HarmonyPrefix] private static bool UpgradePlayerTumbleLaunchPatch(ItemUpgradePlayerTumbleLaunch __instance) { string upgradeType = "Player tumble launch"; if (ShouldWasteUpgrade(upgradeType)) { return false; } string text = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID(__instance.itemToggle.playerTogglePhotonID)); PunManager.instance.UpgradePlayerTumbleLaunch(text); int threshold = (SharedUpgradesChance.ApplyForAllUpgrades.Value ? (-1) : SharedUpgradesChance.ChanceToActivatePlayerTumbleLaunch.Value); if (!ShouldUpgradeForAllPlayers(upgradeType, threshold)) { return false; } foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { string text2 = SemiFunc.PlayerGetSteamID(item); if (!(text2 == text)) { PunManager.instance.UpgradePlayerTumbleLaunch(text2); } } return false; } } }