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 MultiplayerItemHandicap v1.1.1
MultiplayerEncumberment.dll
Decompiled a year agousing System; using System.Diagnostics; using System.IO; 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 Microsoft.CodeAnalysis; using On.RoR2; using R2API; using RoR2; 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("MultiplayerEncumberment")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+b6439867d5001cbf9d3e5f412d0be70fead8b6bb")] [assembly: AssemblyProduct("MultiplayerEncumberment")] [assembly: AssemblyTitle("MultiplayerEncumberment")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MultiplayerEncumbermentMod { public static class Asset { public static AssetBundle mainBundle; public const string bundleName = "itemweightmod"; public static string AssetBundlePath => Path.Combine(Path.GetDirectoryName(MultiplayerEncumberment.PInfo.Location), "itemweightmod"); public static void Init() { mainBundle = AssetBundle.LoadFromFile(AssetBundlePath); } } public class ItemTierArray { public int Tier1 = 0; public int Tier2 = 0; public int Tier3 = 0; public int Lunar = 0; public int Boss = 0; public TeamIndex team; } public class GetItemTierArray { public static ItemTierArray GetPlayerItemCount(PlayerCharacterMasterController self) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected I4, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) ItemTierArray itemTierArray = new ItemTierArray(); if ((Object)(object)self == (Object)null || (Object)(object)self.body == (Object)null || (Object)(object)self.body.inventory == (Object)null) { return itemTierArray; } GenericStaticEnumerable<ItemIndex, AllItemsEnumerator> allItems = ItemCatalog.allItems; AllItemsEnumerator enumerator = allItems.GetEnumerator(); try { while (((AllItemsEnumerator)(ref enumerator)).MoveNext()) { ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current; ItemTier tier = ItemCatalog.GetItemDef(current).tier; ItemTier val = tier; switch ((int)val) { case 0: case 6: itemTierArray.Tier1 += self.body.inventory.GetItemCount(current); break; case 1: case 7: itemTierArray.Tier2 += self.body.inventory.GetItemCount(current) * MultiplayerEncumberment.greenItemWeight.Value; break; case 2: case 8: itemTierArray.Tier3 += self.body.inventory.GetItemCount(current) * MultiplayerEncumberment.redItemWeight.Value; break; case 4: case 9: itemTierArray.Boss += self.body.inventory.GetItemCount(current) * MultiplayerEncumberment.bossItemWeight.Value; break; case 3: itemTierArray.Lunar += self.body.inventory.GetItemCount(current) * MultiplayerEncumberment.lunarItemWeight.Value; break; } } } finally { ((IDisposable)(AllItemsEnumerator)(ref enumerator)).Dispose(); } return itemTierArray; } public static ItemTierArray GetTeamItemCount(TeamIndex team) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected I4, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) ItemTierArray itemTierArray = new ItemTierArray(); itemTierArray.team = team; foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList) { if (readOnlyInstances.teamComponent.teamIndex != team || !readOnlyInstances.isPlayerControlled || readOnlyInstances.master.IsDeadAndOutOfLivesServer()) { continue; } GenericStaticEnumerable<ItemIndex, AllItemsEnumerator> allItems = ItemCatalog.allItems; AllItemsEnumerator enumerator2 = allItems.GetEnumerator(); try { while (((AllItemsEnumerator)(ref enumerator2)).MoveNext()) { ItemIndex current2 = ((AllItemsEnumerator)(ref enumerator2)).Current; ItemTier tier = ItemCatalog.GetItemDef(current2).tier; ItemTier val = tier; switch ((int)val) { case 0: case 6: itemTierArray.Tier1 += readOnlyInstances.inventory.GetItemCount(current2); break; case 1: case 7: itemTierArray.Tier2 += readOnlyInstances.inventory.GetItemCount(current2) * MultiplayerEncumberment.greenItemWeight.Value; break; case 2: case 8: itemTierArray.Tier3 += readOnlyInstances.inventory.GetItemCount(current2) * MultiplayerEncumberment.redItemWeight.Value; break; case 4: case 9: itemTierArray.Boss += readOnlyInstances.inventory.GetItemCount(current2) * MultiplayerEncumberment.bossItemWeight.Value; break; case 3: itemTierArray.Lunar += readOnlyInstances.inventory.GetItemCount(current2) * MultiplayerEncumberment.lunarItemWeight.Value; break; } } } finally { ((IDisposable)(AllItemsEnumerator)(ref enumerator2)).Dispose(); } } return itemTierArray; } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } [BepInPlugin("Offbeatsofa.MultiplayerItemHandicap", "MultiplayerItemHandicap", "1.1.0")] public class MultiplayerEncumberment : BaseUnityPlugin { public const string PluginGUID = "Offbeatsofa.MultiplayerItemHandicap"; public const string PluginAuthor = "Offbeatsofa"; public const string PluginName = "MultiplayerItemHandicap"; public const string PluginVersion = "1.1.0"; public static BuffDef itemWeightBuff; public static ItemTierArray teamItemTierCounts = new ItemTierArray(); public static PluginInfo PInfo { get; private set; } public static ConfigEntry<bool> multipleScalingTypes { get; set; } public static ConfigEntry<int> earlyGameItemNum { get; set; } public static ConfigEntry<int> midGameItemNum { get; set; } public static ConfigEntry<bool> itemWeighting { get; set; } public static ConfigEntry<int> greenItemWeight { get; set; } public static ConfigEntry<int> redItemWeight { get; set; } public static ConfigEntry<int> bossItemWeight { get; set; } public static ConfigEntry<int> lunarItemWeight { get; set; } public void Awake() { PInfo = ((BaseUnityPlugin)this).Info; Log.Init(((BaseUnityPlugin)this).Logger); multipleScalingTypes = ((BaseUnityPlugin)this).Config.Bind<bool>("Scaling", "multipleScalingTypes", true, "Whether scaling is changed depending on the stage of the game"); earlyGameItemNum = ((BaseUnityPlugin)this).Config.Bind<int>("Scaling", "earlyGameItemNum", 7, "Number of items (per player) that encompasses early game scaling. Only used if multipleScalingTypes is true."); midGameItemNum = ((BaseUnityPlugin)this).Config.Bind<int>("Scaling", "midGameItemNum", 30, "Number of items (per player) that encompasses mid game scaling. Only used if multipleScalingTypes is true."); itemWeighting = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "itemWeighting", true, "Whether your weight is based of item rarity or not"); greenItemWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "greenItemWeight", 2, "How much a green item affects your rate (as a multiple of white items)"); redItemWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "redItemWeight", 5, "How much a red item affects your rate (as a multiple of white items)"); bossItemWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "bossItemWeight", 2, "How much a boss item affects your rate (as a multiple of white items)"); lunarItemWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "lunarItemWeight", 2, "How much a lunar item affects your rate (as a multiple of white items)"); AddContent(); } private void OnEnable() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown CharacterBody.RecalculateStats += new hook_RecalculateStats(CharacterBody_RecalculateStats); } private void OnDisable() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown CharacterBody.RecalculateStats += new hook_RecalculateStats(CharacterBody_RecalculateStats); } private void AddContent() { SetupBuff(); ContentAddition.AddBuffDef(itemWeightBuff); } private void SetupBuff() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) Asset.Init(); itemWeightBuff = ScriptableObject.CreateInstance<BuffDef>(); ((Object)itemWeightBuff).name = "ItemWeightBuff"; itemWeightBuff.canStack = true; itemWeightBuff.isCooldown = false; itemWeightBuff.isDebuff = true; itemWeightBuff.buffColor = Color.white; itemWeightBuff.iconSprite = Asset.mainBundle.LoadAsset<Sprite>("texItemWeightModBuffIcon.png"); } private void CharacterBody_RecalculateStats(orig_RecalculateStats orig, CharacterBody self) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); if (self.isPlayerControlled && !((Object)(object)self.master.playerCharacterMasterController == (Object)null)) { ItemTierArray playerItemCount = GetItemTierArray.GetPlayerItemCount(self.master.playerCharacterMasterController); ItemTierArray teamItemCount = GetItemTierArray.GetTeamItemCount(self.teamComponent.teamIndex); SetPlayerSpeed(playerItemCount.Tier1 + playerItemCount.Tier2 + playerItemCount.Tier3 + playerItemCount.Boss + playerItemCount.Lunar, teamItemCount.Tier1 + teamItemCount.Tier2 + teamItemCount.Tier3 + teamItemCount.Boss + teamItemCount.Lunar, self); } } private void SetPlayerSpeed(int playerItemCount, int teamItemCount, CharacterBody self) { //IL_01df: Unknown result type (might be due to invalid IL or missing references) int num = 0; foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList) { if (readOnlyInstances.isPlayerControlled) { num++; } } Log.Debug($"Alive Player Count: {num}"); float num2 = (float)teamItemCount / (float)num; float num3 = (float)playerItemCount / num2 * 100f; float num4 = ((!multipleScalingTypes.Value) ? ((float)Math.Min(Math.Max(-0.0001 * Math.Pow(num3 - 100f, 3.0) + 1.0, 0.25), 2.1)) : ((teamItemCount <= 7 * PlayerCharacterMasterController.instances.Count) ? ((float)Math.Min(Math.Max((double)((float)playerItemCount - num2) / -6.6666 + 1.0, 0.25), 2.1)) : ((teamItemCount < 30 * PlayerCharacterMasterController.instances.Count) ? ((float)Math.Min(Math.Max(((float)playerItemCount - num2) / -20f + 1f, 0.25), 2.1)) : ((float)Math.Min(Math.Max(-0.0001 * Math.Pow(num3 - 100f, 3.0) + 1.0, 0.1), 2.1))))); self.moveSpeed *= num4; int num5 = Convert.ToInt32(num4 * 100f); self.SetBuffCount(itemWeightBuff.buffIndex, num5); } } }