using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("UpgradeDivider_v2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UpgradeDivider_v2")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2d029eda-0817-4eb6-9d03-35546a027fac")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CoopUpgradeDivider;
[BepInPlugin("com.yourname.repo.upgradedivider", "Co-op Upgrade Divider", "2.2.0")]
public class CoopUpgradeDividerPlugin : BaseUnityPlugin
{
internal static int PlayerCount => (!((Object)(object)GameDirector.instance != (Object)null)) ? 1 : Mathf.Max(1, GameDirector.instance.PlayerList.Count);
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"✅ Co-op Upgrade Divider loaded");
Harmony val = new Harmony("com.yourname.repo.upgradedivider");
val.PatchAll();
}
}
[HarmonyPatch(typeof(ShopManager), "GetAllItemsFromStatsManager")]
public static class ShopUpgradeDividerPatch
{
private static void Postfix(ShopManager __instance)
{
int playerCount = CoopUpgradeDividerPlugin.PlayerCount;
if (playerCount <= 1)
{
return;
}
foreach (Item potentialItemUpgrade in __instance.potentialItemUpgrades)
{
if (!((Object)(object)potentialItemUpgrade?.value == (Object)null))
{
float valueMax = potentialItemUpgrade.value.valueMax;
float num = Mathf.Ceil(valueMax / (float)playerCount);
potentialItemUpgrade.value.valueMax = Mathf.Max(1f, num);
}
}
Debug.Log((object)$"[UpgradeDivider] Applied upgrade divider for {playerCount} players");
}
}