using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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 MenuLib;
using MenuLib.MonoBehaviors;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.Events;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UpgradeEveryRound")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.7")]
[assembly: AssemblyInformationalVersion("1.1.0+7c30e0e562e8613b7c025f2c1ed36f55d7e075f7")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("UpgradeEveryRound")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.7.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 UpgradeEveryRound
{
[BepInPlugin("dev.redfops.repo.upgradeeveryround", "Upgrade Every Round", "1.1.0")]
[BepInDependency("nickklmao.menulib", "2.1.3")]
public class Plugin : BaseUnityPlugin
{
public const string modGUID = "dev.redfops.repo.upgradeeveryround";
public const string modName = "Upgrade Every Round";
public const string modVersion = "1.1.0";
public static bool isOpen;
public static ConfigEntry<int> upgradesPerRound;
public static ConfigEntry<bool> limitedChoices;
public static ConfigEntry<int> numChoices;
internal static ManualLogSource Logger;
private readonly Harmony harmony = new Harmony("dev.redfops.repo.upgradeeveryround");
private void Awake()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
upgradesPerRound = ((BaseUnityPlugin)this).Config.Bind<int>("Upgrades", "Upgrades Per Round", 1, new ConfigDescription("Number of upgrades per round", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10), Array.Empty<object>()));
limitedChoices = ((BaseUnityPlugin)this).Config.Bind<bool>("Upgrades", "Limited random choices", false, new ConfigDescription("Only presents a fixed number of random options", (AcceptableValueBase)null, Array.Empty<object>()));
numChoices = ((BaseUnityPlugin)this).Config.Bind<int>("Upgrades", "Number of choices", 3, new ConfigDescription("Number of options to choose from per upgrade", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>()));
harmony.PatchAll(typeof(PlayerSpawnPatch));
harmony.PatchAll(typeof(RunManagerChangeLevelPatch));
harmony.PatchAll(typeof(RunManagerMainMenuPatch));
harmony.PatchAll(typeof(StatsManagerPatch));
harmony.PatchAll(typeof(UpgradeMapPlayerCountPatch));
harmony.PatchAll(typeof(UpgradePlayerEnergyPatch));
harmony.PatchAll(typeof(UpgradePlayerExtraJumpPatch));
harmony.PatchAll(typeof(UpgradePlayerGrabRangePatch));
harmony.PatchAll(typeof(UpgradePlayerGrabStrengthPatch));
harmony.PatchAll(typeof(UpgradePlayerHealthPatch));
harmony.PatchAll(typeof(UpgradePlayerSprintSpeedPatch));
harmony.PatchAll(typeof(UpgradePlayerTumbleLaunchPatch));
Logger.LogInfo((object)"Plugin UpgradeEveryRound is loaded!");
}
public static void ApplyUpgrade(string _steamID, REPOPopupPage popupPage)
{
StatsUI.instance.Fetch();
StatsUI.instance.ShowStats();
CameraGlitch.Instance.PlayUpgrade();
int num = ++StatsManager.instance.dictionaryOfDictionaries["playerUpgradesUsed"][_steamID];
if (GameManager.Multiplayer())
{
((Component)PunManager.instance).GetComponent<PhotonView>().RPC("UpdateStatRPC", (RpcTarget)1, new object[3] { "playerUpgradesUsed", _steamID, num });
}
int num2 = RunManager.instance.levelsCompleted * upgradesPerRound.Value;
if (num >= num2)
{
isOpen = false;
popupPage.ClosePage(true);
}
}
}
[HarmonyPatch(typeof(PlayerAvatar))]
[HarmonyPatch("SpawnRPC")]
public static class PlayerSpawnPatch
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__0_0;
internal void <Prefix>b__0_0()
{
Plugin.isOpen = false;
}
}
private static void Prefix(PhotonView ___photonView)
{
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Expected O, but got Unknown
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Expected O, but got Unknown
//IL_01da: Expected O, but got Unknown
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Expected O, but got Unknown
//IL_020b: Expected O, but got Unknown
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Expected O, but got Unknown
//IL_023c: Expected O, but got Unknown
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Expected O, but got Unknown
//IL_026d: Expected O, but got Unknown
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Expected O, but got Unknown
//IL_029e: Expected O, but got Unknown
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Expected O, but got Unknown
//IL_02cf: Expected O, but got Unknown
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_02f8: Expected O, but got Unknown
//IL_02fd: Expected O, but got Unknown
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Unknown result type (might be due to invalid IL or missing references)
//IL_0326: Expected O, but got Unknown
//IL_032b: Expected O, but got Unknown
if (((IEnumerable<Level>)(object)new Level[3]
{
RunManager.instance.levelMainMenu,
RunManager.instance.levelLobbyMenu,
RunManager.instance.levelTutorial
}).Contains(RunManager.instance.levelCurrent))
{
return;
}
string _steamID = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID(SemiFunc.PhotonViewIDPlayerAvatarLocal()));
int num = RunManager.instance.levelsCompleted * Plugin.upgradesPerRound.Value;
if (StatsManager.instance.dictionaryOfDictionaries["playerUpgradesUsed"][_steamID] >= num || (GameManager.Multiplayer() && !___photonView.IsMine))
{
return;
}
MenuManager.instance.PageCloseAll();
REPOPopupPage repoPopupPage = MenuAPI.CreateREPOPopupPage("Choose an upgrade", (PresetSide)0, false, true, 1.5f);
UnityEvent onPageEnd = repoPopupPage.menuPage.onPageEnd;
object obj = <>c.<>9__0_0;
if (obj == null)
{
UnityAction val = delegate
{
Plugin.isOpen = false;
};
<>c.<>9__0_0 = val;
obj = (object)val;
}
onPageEnd.AddListener((UnityAction)obj);
int num2 = (Plugin.limitedChoices.Value ? Plugin.numChoices.Value : 8);
List<int> list = new List<int>(8) { 0, 1, 2, 3, 4, 5, 6, 7 };
BuilderDelegate val11 = default(BuilderDelegate);
BuilderDelegate val17 = default(BuilderDelegate);
BuilderDelegate val13 = default(BuilderDelegate);
BuilderDelegate val7 = default(BuilderDelegate);
BuilderDelegate val5 = default(BuilderDelegate);
BuilderDelegate val15 = default(BuilderDelegate);
BuilderDelegate val9 = default(BuilderDelegate);
BuilderDelegate val2 = default(BuilderDelegate);
for (int i = 0; i < num2; i++)
{
int index = (Plugin.limitedChoices.Value ? Random.Range(0, list.Count) : 0);
int num3 = list[index];
list.RemoveAt(index);
switch (num3)
{
case 0:
{
REPOPopupPage obj10 = repoPopupPage;
BuilderDelegate obj11 = val11;
if (obj11 == null)
{
BuilderDelegate val12 = delegate(Transform parent)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
MenuAPI.CreateREPOButton("Stamina", (Action)delegate
{
PunManager.instance.UpgradePlayerEnergy(_steamID);
Plugin.ApplyUpgrade(_steamID, repoPopupPage);
}, parent, new Vector2(46f, 18f));
};
BuilderDelegate val4 = val12;
val11 = val12;
obj11 = val4;
}
obj10.AddElement(obj11);
break;
}
case 1:
{
REPOPopupPage obj16 = repoPopupPage;
BuilderDelegate obj17 = val17;
if (obj17 == null)
{
BuilderDelegate val18 = delegate(Transform parent)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
MenuAPI.CreateREPOButton("Extra Jump", (Action)delegate
{
PunManager.instance.UpgradePlayerExtraJump(_steamID);
Plugin.ApplyUpgrade(_steamID, repoPopupPage);
}, parent, new Vector2(186f, 18f));
};
BuilderDelegate val4 = val18;
val17 = val18;
obj17 = val4;
}
obj16.AddElement(obj17);
break;
}
case 2:
{
REPOPopupPage obj12 = repoPopupPage;
BuilderDelegate obj13 = val13;
if (obj13 == null)
{
BuilderDelegate val14 = delegate(Transform parent)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
MenuAPI.CreateREPOButton("Range", (Action)delegate
{
PunManager.instance.UpgradePlayerGrabRange(_steamID);
Plugin.ApplyUpgrade(_steamID, repoPopupPage);
}, parent, new Vector2(46f, 60f));
};
BuilderDelegate val4 = val14;
val13 = val14;
obj13 = val4;
}
obj12.AddElement(obj13);
break;
}
case 3:
{
REPOPopupPage obj6 = repoPopupPage;
BuilderDelegate obj7 = val7;
if (obj7 == null)
{
BuilderDelegate val8 = delegate(Transform parent)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
MenuAPI.CreateREPOButton("Strength", (Action)delegate
{
PunManager.instance.UpgradePlayerGrabStrength(_steamID);
Plugin.ApplyUpgrade(_steamID, repoPopupPage);
}, parent, new Vector2(186f, 60f));
};
BuilderDelegate val4 = val8;
val7 = val8;
obj7 = val4;
}
obj6.AddElement(obj7);
break;
}
case 4:
{
REPOPopupPage obj4 = repoPopupPage;
BuilderDelegate obj5 = val5;
if (obj5 == null)
{
BuilderDelegate val6 = delegate(Transform parent)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
MenuAPI.CreateREPOButton("Health", (Action)delegate
{
PunManager.instance.UpgradePlayerHealth(_steamID);
Plugin.ApplyUpgrade(_steamID, repoPopupPage);
}, parent, new Vector2(46f, 102f));
};
BuilderDelegate val4 = val6;
val5 = val6;
obj5 = val4;
}
obj4.AddElement(obj5);
break;
}
case 5:
{
REPOPopupPage obj14 = repoPopupPage;
BuilderDelegate obj15 = val15;
if (obj15 == null)
{
BuilderDelegate val16 = delegate(Transform parent)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
MenuAPI.CreateREPOButton("Sprint speed", (Action)delegate
{
PunManager.instance.UpgradePlayerSprintSpeed(_steamID);
Plugin.ApplyUpgrade(_steamID, repoPopupPage);
}, parent, new Vector2(186f, 102f));
};
BuilderDelegate val4 = val16;
val15 = val16;
obj15 = val4;
}
obj14.AddElement(obj15);
break;
}
case 6:
{
REPOPopupPage obj8 = repoPopupPage;
BuilderDelegate obj9 = val9;
if (obj9 == null)
{
BuilderDelegate val10 = delegate(Transform parent)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
MenuAPI.CreateREPOButton("Tumble Launch", (Action)delegate
{
PunManager.instance.UpgradePlayerTumbleLaunch(_steamID);
Plugin.ApplyUpgrade(_steamID, repoPopupPage);
}, parent, new Vector2(46f, 144f));
};
BuilderDelegate val4 = val10;
val9 = val10;
obj9 = val4;
}
obj8.AddElement(obj9);
break;
}
case 7:
{
REPOPopupPage obj2 = repoPopupPage;
BuilderDelegate obj3 = val2;
if (obj3 == null)
{
BuilderDelegate val3 = delegate(Transform parent)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
MenuAPI.CreateREPOButton("Map Player Count", (Action)delegate
{
PunManager.instance.UpgradeMapPlayerCount(_steamID);
Plugin.ApplyUpgrade(_steamID, repoPopupPage);
}, parent, new Vector2(186f, 144f));
};
BuilderDelegate val4 = val3;
val2 = val3;
obj3 = val4;
}
obj2.AddElement(obj3);
break;
}
}
}
repoPopupPage.OpenPage(false);
Plugin.isOpen = true;
}
}
[HarmonyPatch(typeof(StatsManager))]
[HarmonyPatch("Start")]
public static class StatsManagerPatch
{
private static void Prefix(StatsManager __instance)
{
__instance.dictionaryOfDictionaries.Add("playerUpgradesUsed", new Dictionary<string, int>());
}
}
[HarmonyPatch(typeof(PunManager))]
[HarmonyPatch("UpgradeMapPlayerCount")]
public static class UpgradeMapPlayerCountPatch
{
private static void Postfix(string _steamID, PhotonView ___photonView, StatsManager ___statsManager)
{
if (!SemiFunc.IsMasterClient() && GameManager.Multiplayer() && Plugin.isOpen)
{
___photonView.RPC("UpgradeMapPlayerCountRPC", (RpcTarget)1, new object[2]
{
_steamID,
___statsManager.playerUpgradeMapPlayerCount[_steamID]
});
}
}
}
[HarmonyPatch(typeof(PunManager))]
[HarmonyPatch("UpgradePlayerEnergy")]
public static class UpgradePlayerEnergyPatch
{
private static void Postfix(string _steamID, PhotonView ___photonView, StatsManager ___statsManager)
{
if (!SemiFunc.IsMasterClient() && GameManager.Multiplayer() && Plugin.isOpen)
{
___photonView.RPC("UpgradePlayerEnergyCountRPC", (RpcTarget)1, new object[2]
{
_steamID,
___statsManager.playerUpgradeStamina[_steamID]
});
}
}
}
[HarmonyPatch(typeof(PunManager))]
[HarmonyPatch("UpgradePlayerExtraJump")]
public static class UpgradePlayerExtraJumpPatch
{
private static void Postfix(string _steamID, PhotonView ___photonView, StatsManager ___statsManager)
{
if (!SemiFunc.IsMasterClient() && GameManager.Multiplayer() && Plugin.isOpen)
{
___photonView.RPC("UpgradePlayerExtraJumpRPC", (RpcTarget)1, new object[2]
{
_steamID,
___statsManager.playerUpgradeExtraJump[_steamID]
});
}
}
}
[HarmonyPatch(typeof(PunManager))]
[HarmonyPatch("UpgradePlayerGrabRange")]
public static class UpgradePlayerGrabRangePatch
{
private static void Postfix(string _steamID, PhotonView ___photonView, StatsManager ___statsManager)
{
if (!SemiFunc.IsMasterClient() && GameManager.Multiplayer() && Plugin.isOpen)
{
___photonView.RPC("UpgradePlayerGrabRangeRPC", (RpcTarget)1, new object[2]
{
_steamID,
___statsManager.playerUpgradeRange[_steamID]
});
}
}
}
[HarmonyPatch(typeof(PunManager))]
[HarmonyPatch("UpgradePlayerGrabStrength")]
public static class UpgradePlayerGrabStrengthPatch
{
private static void Postfix(string _steamID, PhotonView ___photonView, StatsManager ___statsManager)
{
if (!SemiFunc.IsMasterClient() && GameManager.Multiplayer() && Plugin.isOpen)
{
___photonView.RPC("UpgradePlayerGrabStrengthRPC", (RpcTarget)1, new object[2]
{
_steamID,
___statsManager.playerUpgradeStrength[_steamID]
});
}
}
}
[HarmonyPatch(typeof(PunManager))]
[HarmonyPatch("UpgradePlayerHealth")]
public static class UpgradePlayerHealthPatch
{
private static void Postfix(string playerName, PhotonView ___photonView, StatsManager ___statsManager)
{
if (!SemiFunc.IsMasterClient() && GameManager.Multiplayer() && Plugin.isOpen)
{
___photonView.RPC("UpgradePlayerHealthRPC", (RpcTarget)1, new object[2]
{
playerName,
___statsManager.playerUpgradeHealth[playerName]
});
}
}
}
[HarmonyPatch(typeof(PunManager))]
[HarmonyPatch("UpgradePlayerSprintSpeed")]
public static class UpgradePlayerSprintSpeedPatch
{
private static void Postfix(string _steamID, PhotonView ___photonView, StatsManager ___statsManager)
{
if (!SemiFunc.IsMasterClient() && GameManager.Multiplayer() && Plugin.isOpen)
{
___photonView.RPC("UpgradePlayerSprintSpeedRPC", (RpcTarget)1, new object[2]
{
_steamID,
___statsManager.playerUpgradeSpeed[_steamID]
});
}
}
}
[HarmonyPatch(typeof(PunManager))]
[HarmonyPatch("UpgradePlayerTumbleLaunch")]
public static class UpgradePlayerTumbleLaunchPatch
{
private static void Postfix(string _steamID, PhotonView ___photonView, StatsManager ___statsManager)
{
if (!SemiFunc.IsMasterClient() && GameManager.Multiplayer() && Plugin.isOpen)
{
___photonView.RPC("UpgradePlayerTumbleLaunchRPC", (RpcTarget)1, new object[2]
{
_steamID,
___statsManager.playerUpgradeLaunch[_steamID]
});
}
}
}
[HarmonyPatch(typeof(RunManager))]
[HarmonyPatch("ChangeLevel")]
public static class RunManagerChangeLevelPatch
{
private static void Prefix()
{
Plugin.isOpen = false;
}
}
[HarmonyPatch(typeof(RunManager))]
[HarmonyPatch("LeaveToMainMenu")]
public static class RunManagerMainMenuPatch
{
private static void Prefix()
{
Plugin.isOpen = false;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "UpgradeEveryRound";
public const string PLUGIN_NAME = "My first plugin";
public const string PLUGIN_VERSION = "1.1.0";
}
}