using 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 HarmonyLib;
using Microsoft.CodeAnalysis;
using NikkiUpgrades.UpgradeManager;
using Photon.Pun;
using REPOLib.Modules;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Events;
[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("Nikki")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © 2025 Nikki")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d1f83f06fe4ba7e3c5ca8ecf1200b638cbfcdf07")]
[assembly: AssemblyProduct("NikkiUpgrades")]
[assembly: AssemblyTitle("NikkiUpgrades")]
[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 NikkiUpgrades
{
[BepInPlugin("NikkiUpgrades", "NikkiUpgrades", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class NikkiUpgradesPlugin : BaseUnityPlugin
{
public static ManualLogSource mls;
public static ConfigEntry<bool> staminaRegenUpgradeEnabled;
public static ConfigEntry<float> staminaRegenUpgradeAmount;
public static ConfigEntry<bool> investorUpgradeEnabled;
public static ConfigEntry<float> investorUpgradeAmount;
public static ConfigEntry<int> investorUpgradeMax;
public static ConfigEntry<bool> unstableUpgradeEnabled;
public static ConfigEntry<int> unstableUpgradeDamage;
public static ConfigEntry<float> unstableUpgradeRadius;
public static ConfigEntry<bool> unstableUpgradeInstability;
public static ConfigEntry<bool> unstableUpgradeTumbleMissile;
public static PlayerUpgrade staminaRegenRegister;
public static PlayerUpgrade investorRegister;
public static PlayerUpgrade unstableCoreRegister;
private static float initialStamina;
private static bool initialStaminaSet;
public static bool investorUsed;
public static bool investorTriggered;
public static GameObject unstableexplosion;
private readonly Harmony harmony = new Harmony("nikkiupgrades.mod");
private void Awake()
{
mls = Logger.CreateLogSource("NikkiUpgrades");
string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
string text = Path.Combine(directoryName, "nikkiupgrades_assets");
AssetBundle val = AssetBundle.LoadFromFile(text);
investorUpgradeEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Investor Upgrade", "Enabled", true, "Should the Investor upgrade be enabled?");
investorUpgradeAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Investor Upgrade", "Investor Upgrade Power", 10f, "How much should the Investor upgrade multiply your total money, per upgrade? Base value is 10%.");
investorUpgradeMax = ((BaseUnityPlugin)this).Config.Bind<int>("Investor Upgrade", "Investor Upgrade Purchase Maximum", 3, "How many Investor upgrades should be purchasable before they stop spawning? Base value is 3.");
staminaRegenUpgradeEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Stamina Regen Upgrade", "Enabled", true, "Should the Stamina Regen Upgrade be enabled?");
staminaRegenUpgradeAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina Regen Upgrade", "Stamina Regen Upgrade Power", 1f, "How much should Stamina Regen increase per upgrade? Base stamina regen is 2. The base value means it takes 2 upgrades to double your stamina regen.");
unstableUpgradeEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Unstable Core Upgrade", "Enabled", true, "Should the Unstable Core Upgrade be enabled?");
unstableUpgradeDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Unstable Core Upgrade", "Unstable Core Upgrade Power", 250, "How much damage should the Unstable Core Upgrade do per upgrade? Base value is 250. This value is multiplied by 0.4 for players (default 100).");
unstableUpgradeRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Unstable Core Upgrade", "Unstable Core Upgrade Radius", 3f, "How big should the radius of the Unstable Core Upgrade explosion be? Base value is 3f.");
unstableUpgradeInstability = ((BaseUnityPlugin)this).Config.Bind<bool>("Unstable Core Upgrade", "Unstable Core Upgrade Stability", true, "Should the Unstable Core upgrade become more dangerous and unstable after 3+ upgrades on the same player?");
unstableUpgradeTumbleMissile = ((BaseUnityPlugin)this).Config.Bind<bool>("Unstable Core Upgrade", "Unstable Core Upgrade Tumble Missile", true, "Should the Unstable Core upgrade allow you to become a tumble missile after 3+ upgrades on the same player?");
harmony.PatchAll(typeof(NikkiUpgradesPlugin));
if (staminaRegenUpgradeEnabled.Value)
{
Item val2 = val.LoadAsset<Item>("Item Upgrade Player Stamina Regen");
Items.RegisterItem(val2);
staminaRegenRegister = Upgrades.RegisterUpgrade("StaminaRegen", val2, (Action<PlayerAvatar, int>)InitStaminaUpgrade, (Action<PlayerAvatar, int>)UseStaminaUpgrade);
}
if (investorUpgradeEnabled.Value)
{
Item val3 = val.LoadAsset<Item>("Item Upgrade Player Investor");
GameObject val4 = val.LoadAsset<GameObject>("Investor Manager");
Items.RegisterItem(val3);
NetworkPrefabs.RegisterNetworkPrefab("investormanager", val4);
investorRegister = Upgrades.RegisterUpgrade("Investor", val3, (Action<PlayerAvatar, int>)InitInvestorUpgrade, (Action<PlayerAvatar, int>)UseInvestorUpgrade);
val3.maxPurchaseAmount = investorUpgradeMax.Value;
}
if (unstableUpgradeEnabled.Value)
{
Item val5 = val.LoadAsset<Item>("Item Upgrade Player Unstable Core");
unstableexplosion = val.LoadAsset<GameObject>("Unstable Explosion");
NetworkPrefabs.RegisterNetworkPrefab("UnstableExplosion", unstableexplosion);
Items.RegisterItem(val5);
unstableCoreRegister = Upgrades.RegisterUpgrade("UnstableCore", val5, (Action<PlayerAvatar, int>)InitUnstableUpgrade, (Action<PlayerAvatar, int>)UseUnstableUpgrade);
}
}
private static void InitStaminaUpgrade(PlayerAvatar player, int level)
{
if (player.isLocal)
{
PlayerController instance = PlayerController.instance;
Traverse val = Traverse.Create((object)instance).Field("sprintRechargeAmount");
if (!initialStaminaSet)
{
initialStaminaSet = true;
initialStamina = (float)val.GetValue();
}
val.SetValue((object)CalculateStaminaRegen(level));
}
}
private static void UseStaminaUpgrade(PlayerAvatar player, int level)
{
if (player.isLocal)
{
PlayerController instance = PlayerController.instance;
Traverse val = Traverse.Create((object)instance).Field("sprintRechargeAmount");
float num = CalculateStaminaRegen(level);
mls.LogDebug((object)$"Sprint Recharge Amount now at {num}.");
val.SetValue((object)num);
}
}
private static float CalculateStaminaRegen(int level)
{
return initialStamina + staminaRegenUpgradeAmount.Value * (float)level;
}
private static void InitInvestorUpgrade(PlayerAvatar player, int level)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.IsMasterClientOrSingleplayer() && (SemiFunc.RunIsLobby() || SemiFunc.RunIsShop()))
{
NetworkPrefabs.SpawnNetworkPrefab("investormanager", Vector3.zero, Quaternion.identity, (byte)0, (object[])null);
}
}
private static void UseInvestorUpgrade(PlayerAvatar player, int level)
{
investorUsed = true;
if (SemiFunc.RunIsLobby())
{
int num = SemiFunc.StatGetRunCurrency();
float num2 = investorUpgradeAmount.Value * 0.01f + 1f;
mls.LogInfo((object)$"Money being multiplied by {num2}.");
SemiFunc.StatSetRunCurrency((int)Math.Round((float)num * num2));
mls.LogInfo((object)$"Previous money was {num}. New total is {SemiFunc.StatGetRunCurrency()}.");
investorTriggered = true;
}
}
public static int CalculateInvestmentLevel(int totalLevel = 0)
{
foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
{
if (Upgrades.GetUpgrade("Investor").GetLevel(item) > 0)
{
totalLevel += Upgrades.GetUpgrade("Investor").GetLevel(item);
}
}
mls.LogDebug((object)$"Total Investment Level is {totalLevel}.");
return totalLevel;
}
private static void InitExtraLifeUpgrade(PlayerAvatar player, int level)
{
if (SemiFunc.IsMasterClientOrSingleplayer() && Upgrades.GetUpgrade("LifeInsurance").GetLevel(player) > 0 && SemiFunc.RunIsLevel())
{
mls.LogDebug((object)(player.playerName + " has life insurance!"));
}
}
private static void UseExtraLifeUpgrade(PlayerAvatar player, int level)
{
if (SemiFunc.IsMasterClientOrSingleplayer() && Upgrades.GetUpgrade("LifeInsurance").GetLevel(player) > 0 && SemiFunc.RunIsLevel())
{
mls.LogDebug((object)(player.playerName + " has life insurance!"));
}
}
private static void InitUnstableUpgrade(PlayerAvatar playerInit, int level)
{
foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
{
if (Upgrades.GetUpgrade("UnstableCore").GetLevel(item) > 0 && !Object.op_Implicit((Object)(object)((Component)item).gameObject.GetComponent<UnstableCoreManager>()))
{
((Component)item).gameObject.AddComponent<UnstableCoreManager>();
mls.LogDebug((object)(item.playerName + " is unstable!"));
}
}
}
private static void UseUnstableUpgrade(PlayerAvatar playerUse, int level)
{
foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
{
if (Upgrades.GetUpgrade("UnstableCore").GetLevel(item) > 0 && !Object.op_Implicit((Object)(object)((Component)item).gameObject.GetComponent<UnstableCoreManager>()))
{
((Component)item).gameObject.AddComponent<UnstableCoreManager>();
mls.LogDebug((object)(item.playerName + " is unstable!"));
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "NikkiUpgrades";
public const string PLUGIN_NAME = "NikkiUpgrades";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace NikkiUpgrades.UpgradeManager
{
public class InvestorManager : MonoBehaviour
{
private void Update()
{
if (SemiFunc.IsMasterClientOrSingleplayer() && NikkiUpgradesPlugin.investorUpgradeEnabled.Value && NikkiUpgradesPlugin.investorUsed)
{
if (SemiFunc.RunIsShop() && NikkiUpgradesPlugin.investorTriggered)
{
NikkiUpgradesPlugin.investorTriggered = false;
((Behaviour)this).enabled = false;
}
else if (SemiFunc.RunIsLobby() && !NikkiUpgradesPlugin.investorTriggered)
{
int num = SemiFunc.StatGetRunCurrency();
int num2 = NikkiUpgradesPlugin.CalculateInvestmentLevel();
float num3 = NikkiUpgradesPlugin.investorUpgradeAmount.Value * ((float)num2 * 0.01f) + 1f;
NikkiUpgradesPlugin.mls.LogInfo((object)$"Money being multiplied by {num3}.");
SemiFunc.StatSetRunCurrency((int)Math.Round((float)num * num3));
NikkiUpgradesPlugin.mls.LogInfo((object)$"Previous money was {num}. New total is {SemiFunc.StatGetRunCurrency()}.");
NikkiUpgradesPlugin.investorTriggered = true;
}
}
}
}
public class UnstableCoreManager : MonoBehaviour
{
[HideInInspector]
public PlayerAvatar player;
private SyncedEventRandom syncedRandomNumber;
private bool explosionTriggered = false;
private GameObject explosion;
private UnstableCoreExplosion explosionScript;
private PhotonView photon;
private void Start()
{
photon = ((Component)this).GetComponent<PhotonView>();
syncedRandomNumber = ComponentHolderProtocol.GetOrAddComponent<SyncedEventRandom>((Object)(object)((Component)this).gameObject);
player = ((Component)this).GetComponent<PlayerAvatar>();
explosion = NikkiUpgradesPlugin.unstableexplosion;
explosionTriggered = false;
}
private void FixedUpdate()
{
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Expected O, but got Unknown
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Expected O, but got Unknown
if (SemiFunc.RunIsLobbyMenu() || SemiFunc.IsMainMenu())
{
return;
}
if (!player.deadSet && !player.isTumbling && explosionTriggered)
{
explosionTriggered = false;
ExplodeResetImpulse();
return;
}
if (Upgrades.GetUpgrade("UnstableCore").GetLevel(player) >= 3)
{
if (NikkiUpgradesPlugin.unstableUpgradeInstability.Value && player.playerHealth.hurtFreeze)
{
syncedRandomNumber.RandomRangeInt(1, 1000);
if (syncedRandomNumber.resultRandomRangeInt <= Upgrades.GetUpgrade("UnstableCore").GetLevel(player))
{
ExplodeImpulse();
}
}
if (NikkiUpgradesPlugin.unstableUpgradeTumbleMissile.Value)
{
player.tumble.hurtCollider.onImpactEnemy.AddListener(new UnityAction(ExplodeImpulse));
player.tumble.hurtCollider.onImpactPlayer.AddListener(new UnityAction(ExplodeImpulse));
}
}
if (player.deadSet && !explosionTriggered)
{
ExplodeImpulse();
}
if (Upgrades.GetUpgrade("UnstableCore").GetLevel(player) == 0)
{
Object.Destroy((Object)(object)this);
}
}
public void ExplodeImpulse()
{
if (SemiFunc.IsMasterClientOrSingleplayer())
{
if (SemiFunc.IsMultiplayer())
{
photon.RPC("ExplodeRPC", (RpcTarget)0, Array.Empty<object>());
}
else
{
Explode();
}
}
}
[PunRPC]
public void ExplodeRPC()
{
Explode();
}
public void Explode()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
if (!explosionTriggered)
{
if (SemiFunc.IsMasterClientOrSingleplayer())
{
explosion = NetworkPrefabs.SpawnNetworkPrefab("UnstableExplosion", ((Component)this).transform.position, ((Component)this).transform.rotation, (byte)0, (object[])null);
}
explosionScript = explosion.GetComponent<UnstableCoreExplosion>();
explosionScript.player = player;
explosionTriggered = true;
}
}
public void ExplodeResetImpulse()
{
if (SemiFunc.IsMultiplayer())
{
photon.RPC("ExplodeResetRPC", (RpcTarget)0, Array.Empty<object>());
}
else
{
explosionTriggered = false;
}
}
[PunRPC]
public void ExplodeResetRPC()
{
explosionTriggered = false;
}
private void OnDestroy()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Expected O, but got Unknown
if ((Object)(object)player != (Object)null && (Object)(object)player.tumble != (Object)null && (Object)(object)player.tumble.hurtCollider != (Object)null)
{
player.tumble.hurtCollider.onImpactEnemy.RemoveListener(new UnityAction(Explode));
player.tumble.hurtCollider.onImpactPlayer.RemoveListener(new UnityAction(Explode));
}
}
}
public class UnstableCoreExplosion : MonoBehaviour
{
public ParticleSystem particleExplosion;
public HurtCollider hurtCollider;
public Sound explosionSound;
public Sound explosionSoundGlobal;
public PlayerAvatar player;
private PhotonView photonView;
private float explosionTime = 7.5f;
private void Start()
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
photonView = ((Component)this).GetComponent<PhotonView>();
explosionTime = 7.5f;
if ((Object)(object)player == (Object)null)
{
NikkiUpgradesPlugin.mls.LogError((object)"Error passing along player! Grabbing local value as failsafe! This will likely cause unintended side effects if not in singleplayer!");
player = SemiFunc.PlayerAvatarLocal();
}
NikkiUpgradesPlugin.mls.LogDebug((object)"Spawning explosion!");
int level = Upgrades.GetUpgrade("UnstableCore").GetLevel(player);
int num = NikkiUpgradesPlugin.unstableUpgradeDamage.Value * level;
((Component)this).gameObject.transform.localScale = Vector3.one * (NikkiUpgradesPlugin.unstableUpgradeRadius.Value * 2f) * (float)level;
NikkiUpgradesPlugin.mls.LogDebug((object)$"Explosion with diameter {((Component)this).gameObject.transform.localScale} and {num} damage spawned at {((Component)this).gameObject.transform.position}!");
MainModule main = particleExplosion.main;
hurtCollider.playerDamage = (int)Mathf.Round((float)num * 0.4f);
hurtCollider.enemyDamage = num;
((MainModule)(ref main)).startSpeedMultiplier = 0.5f + 0.5f * (float)level;
main.m_ParticleSystem.Play();
explosionSound.Play(((Component)this).gameObject.transform.position, 2f, 0.2f, 2f, 0.4f);
explosionSoundGlobal.Play(((Component)this).gameObject.transform.position, 2f, 0.2f, 2f, 0.4f);
SemiFunc.CameraShakeDistance(((Component)this).gameObject.transform.position, (float)level * 10f, 1f + (float)level * 0.5f, NikkiUpgradesPlugin.unstableUpgradeRadius.Value * 2f, NikkiUpgradesPlugin.unstableUpgradeRadius.Value * 5f);
}
private void Update()
{
explosionTime -= Time.deltaTime;
if (explosionTime <= 7.3f && ((Behaviour)hurtCollider).enabled)
{
NikkiUpgradesPlugin.mls.LogDebug((object)"Disabling HurtCollider.");
((Behaviour)hurtCollider).enabled = false;
}
if (explosionTime <= 0f)
{
NikkiUpgradesPlugin.mls.LogDebug((object)"Destroying explosion GameObject.");
Object.Destroy((Object)(object)this);
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}