Decompiled source of Upgrade Divider v2 v1.0.1

UpgradeDivider_v2.dll

Decompiled 8 months ago
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", "1.0.2")]
public class CoopUpgradeDividerPlugin : BaseUnityPlugin
{
	public static bool SoloTestMode = false;

	public static int FakePlayerCount = 2;

	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), "UpgradeValueGet")]
public static class UpgradeDividerPatch
{
	private static void Postfix(ref float __result)
	{
		if ((Object)(object)GameDirector.instance == (Object)null)
		{
			return;
		}
		int count = GameDirector.instance.PlayerList.Count;
		int num = count;
		if (count == 1 && CoopUpgradeDividerPlugin.SoloTestMode)
		{
			num = Mathf.Max(1, CoopUpgradeDividerPlugin.FakePlayerCount);
		}
		if (num > 1)
		{
			__result = Mathf.Ceil(__result / (float)num);
			if (__result < 1f)
			{
				__result = 1f;
			}
		}
	}
}