using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using SS2;
using SS2.Components;
using UnityEngine;
[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("AlternativeGoldScaling")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AlternativeGoldScaling")]
[assembly: AssemblyTitle("AlternativeGoldScaling")]
[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 AlternativeGoldScaling
{
public static class ConfigOptions
{
private const string _wrbGoldRewardSectionName = "WRB - Enemy gold reward scaling";
public static ConfigEntry<bool> EnableWRBGoldScaling;
public static ConfigEntry<float> BaseGoldScalingMultiplier;
public static ConfigEntry<float> LoopMultiplier;
public static ConfigEntry<float> StageDivisor;
public static ConfigEntry<float> StageClearCountMultiplier;
public static ConfigEntry<float> StageMultiplier;
public static ConfigEntry<float> SquareRootMultiplier;
public static ConfigEntry<float> StageAndLoopMultiplier;
private const string _wrbMultiplayerCostSectionName = "WRB - Multiplayer cost scaling";
public static ConfigEntry<bool> EnableWRBMultiplayerCostScaling;
public static ConfigEntry<float> BaseMultiplayerCostMultiplier;
public static ConfigEntry<float> PerPlayerCostMultiplier;
private const string _ss2EntireSectionName = "Starstorm 2 - Late-game elites support";
public static ConfigEntry<bool> EnableSS2Support;
private const string _ss2EmpyreanSectionName = "Starstorm 2 - Empyrean Gold Reward";
public static ConfigEntry<bool> SS2Empyrean_EnableChange;
public static ConfigEntry<float> SS2Empyrean_NerfBaseMultiplier;
public static ConfigEntry<int> SS2Empyrean_StageOfNerfStart;
public static ConfigEntry<float> SS2Empyrean_NerfPerStageMultiplier;
private const string _ss2EtherealSectionName = "Starstorm 2 - Ethereal Gold Reward";
public static ConfigEntry<bool> SS2Ethereal_EnableChange;
public static ConfigEntry<float> SS2Ethereal_NerfBaseMultiplier;
public static ConfigEntry<float> SS2Ethereal_EtherealsUsedMultiplier;
public static ConfigEntry<int> SS2Ethereal_StageOfNerfStart;
public static ConfigEntry<float> SS2Ethereal_NerfPerStageMultiplier;
private const string _ss2UltraSectionName = "Starstorm 2 - Ultra Gold Reward";
public static ConfigEntry<bool> SS2Ultra_EnableChange;
public static ConfigEntry<float> SS2Ultra_NerfBaseMultiplier;
public static ConfigEntry<float> SS2Ultra_EtherealsUsedMultiplier;
public static ConfigEntry<int> SS2Ultra_StageOfNerfStart;
public static ConfigEntry<float> SS2Ultra_NerfPerStageMultiplier;
internal static void BindConfigOptions(ConfigFile config)
{
EnableWRBGoldScaling = config.Bind<bool>("WRB - Enemy gold reward scaling", "Enable", true, "Enable using the formula from Well-Rounded Balance (WRB) for scaling gold from enemy kills?\n\nFormula for gold reward: Minimum value between Vanilla Gold Reward * Base Multiplier and Base Multiplier * ((Vanilla Gold Reward / (Stage Divisor + (Stage Clear Count * Stage Clear Count Multiplier))) + Square Root(Square Root Multiplier * (Stage And Loop Multiplier + (Stage Clear Count * Stage Multiplier + Loop Clear Count * Loop Multiplier))))");
BaseGoldScalingMultiplier = config.Bind<float>("WRB - Enemy gold reward scaling", "Base Multiplier", 1f, "WRB's default value is 0.75");
LoopMultiplier = config.Bind<float>("WRB - Enemy gold reward scaling", "Loop Multiplier", -700f, "WRB's default value is unchanged");
StageDivisor = config.Bind<float>("WRB - Enemy gold reward scaling", "Stage Divisor", 2f, "WRB's default value is 3");
StageClearCountMultiplier = config.Bind<float>("WRB - Enemy gold reward scaling", "Stage Clear Count Multiplier", 0.5f, "WRB's default value is 0.25");
StageMultiplier = config.Bind<float>("WRB - Enemy gold reward scaling", "Stage Multiplier", 150f, "WRB's default value is unchanged");
SquareRootMultiplier = config.Bind<float>("WRB - Enemy gold reward scaling", "Square Root Multiplier", 6f, "WRB's default value is unchanged");
StageAndLoopMultiplier = config.Bind<float>("WRB - Enemy gold reward scaling", "Stage and Loop Multiplier", 275f, "WRB's default value is unchanged");
EnableWRBMultiplayerCostScaling = config.Bind<bool>("WRB - Multiplayer cost scaling", "Enable", true, "Enable using the formula from Well-Rounded Balance (WRB) for scaling the cost of buyable things in multiplayer?\n\nFormula for cost scaling: Base Multiplier + (Per-Player Multiplier / Square Root(Player Count))");
BaseMultiplayerCostMultiplier = config.Bind<float>("WRB - Multiplayer cost scaling", "Base Multiplier", 1f, "WRB's default value is unchanged");
PerPlayerCostMultiplier = config.Bind<float>("WRB - Multiplayer cost scaling", "Per-Player cost multiplier", 0.25f, "WRB's default value is unchanged");
EnableSS2Support = config.Bind<bool>("Starstorm 2 - Late-game elites support", "Enable", true, "Enable special support for nerfing the gold reward from some late-game elites from Starstorm 2? The gold reward nerf for these elites are ON TOP OF the existing gold nerf from WRB if it's enabled.\n\nFormula for gold reward: Highest value between 1 and (Base Multiplier + IF APPLICABLE (Ethereal Multiplier * Ethereals Used Count)) / (1 + (Highest value between 0 and ((Stage Clear Count + 1) - Starting Stage of Nerf) * Per-Stage Multiplier))");
SS2Empyrean_EnableChange = config.Bind<bool>("Starstorm 2 - Empyrean Gold Reward", "Enable Empyrean Gold Reward Change", true, "");
SS2Empyrean_NerfBaseMultiplier = config.Bind<float>("Starstorm 2 - Empyrean Gold Reward", "Empyrean - Base Multiplier", 15f, "");
SS2Empyrean_StageOfNerfStart = config.Bind<int>("Starstorm 2 - Empyrean Gold Reward", "Empyrean - Starting stage of nerf", 11, "");
SS2Empyrean_NerfPerStageMultiplier = config.Bind<float>("Starstorm 2 - Empyrean Gold Reward", "Empyrean - Per-Stage multiplier", 0.5f, "");
SS2Ethereal_EnableChange = config.Bind<bool>("Starstorm 2 - Ethereal Gold Reward", "Enable Ethereal Gold Reward Change", false, "ONLY ENABLE IF YOU'RE PLAYING WITH THE STARSTORM 2 BETA");
SS2Ethereal_NerfBaseMultiplier = config.Bind<float>("Starstorm 2 - Ethereal Gold Reward", "Ethereal - Base Multiplier", 2f, "");
SS2Ethereal_EtherealsUsedMultiplier = config.Bind<float>("Starstorm 2 - Ethereal Gold Reward", "Ethereal - Ethereals-used Multiplier", 2f, "");
SS2Ethereal_StageOfNerfStart = config.Bind<int>("Starstorm 2 - Ethereal Gold Reward", "Ethereal - Starting stage of nerf", 8, "");
SS2Ethereal_NerfPerStageMultiplier = config.Bind<float>("Starstorm 2 - Ethereal Gold Reward", "Ethereal - Per-Stage multiplier", 0.2f, "");
SS2Ultra_EnableChange = config.Bind<bool>("Starstorm 2 - Ultra Gold Reward", "Enable Ultra Gold Reward Change", false, "ONLY ENABLE IF YOU'RE PLAYING WITH THE STARSTORM 2 BETA");
SS2Ultra_NerfBaseMultiplier = config.Bind<float>("Starstorm 2 - Ultra Gold Reward", "Ultra - Base Multiplier", 20f, "");
SS2Ultra_EtherealsUsedMultiplier = config.Bind<float>("Starstorm 2 - Ultra Gold Reward", "Ultra - Ethereals-used Multiplier", 20f, "");
SS2Ultra_StageOfNerfStart = config.Bind<int>("Starstorm 2 - Ultra Gold Reward", "Ultra - Starting stage of nerf", 12, "");
SS2Ultra_NerfPerStageMultiplier = config.Bind<float>("Starstorm 2 - Ultra Gold Reward", "Ultra - Per-Stage multiplier", 0.6f, "");
}
}
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object 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);
}
}
internal static class Main
{
internal static class Hooks
{
internal static void DeathRewards_OnKilledServer(orig_OnKilledServer orig, DeathRewards self, DamageReport damageReport)
{
self.goldReward = GetWRBGoldReward(self.goldReward);
orig.Invoke(self, damageReport);
}
internal static void Run_GetDifficultyScaledCost_int_float(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
ILCursor val = new ILCursor(il);
if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 1.25f)
}))
{
int index = val.Index;
val.Index = index + 1;
val.EmitDelegate<Func<float, float>>((Func<float, float>)delegate(float orig)
{
int participatingPlayerCount = Run.instance.participatingPlayerCount;
float num = ConfigOptions.BaseMultiplayerCostMultiplier.Value + ConfigOptions.PerPlayerCostMultiplier.Value / Mathf.Sqrt((float)participatingPlayerCount);
return (participatingPlayerCount > 1) ? num : orig;
});
}
else
{
Log.Error("COULD NOT IL HOOK " + ((MemberReference)il.Method).Name);
Log.Warning($"cursor is {val}");
Log.Warning($"il is {il}");
}
}
}
internal static int CurrentStageNumber => Run.instance.stageClearCount + 1;
internal static uint GetWRBGoldReward(uint goldReward)
{
return Convert.ToUInt32(Mathf.Min((float)goldReward * ConfigOptions.BaseGoldScalingMultiplier.Value, ConfigOptions.BaseGoldScalingMultiplier.Value * ((float)goldReward / (ConfigOptions.StageDivisor.Value + (float)Run.instance.stageClearCount * ConfigOptions.StageClearCountMultiplier.Value) + Mathf.Sqrt(ConfigOptions.SquareRootMultiplier.Value * (ConfigOptions.StageAndLoopMultiplier.Value + ((float)Run.instance.stageClearCount * ConfigOptions.StageMultiplier.Value + (float)Run.instance.loopClearCount * ConfigOptions.LoopMultiplier.Value))))));
}
}
internal static class ModSupport
{
internal static class RiskOfOptionsMod
{
private static bool? _modexists;
public static bool ModIsRunning
{
get
{
if (!_modexists.HasValue)
{
_modexists = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
}
return _modexists.Value;
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
internal static void AddOptions()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Expected O, but got Unknown
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Expected O, but got Unknown
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Expected O, but got Unknown
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Expected O, but got Unknown
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Expected O, but got Unknown
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Expected O, but got Unknown
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Expected O, but got Unknown
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Expected O, but got Unknown
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Expected O, but got Unknown
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Expected O, but got Unknown
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Expected O, but got Unknown
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Expected O, but got Unknown
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Expected O, but got Unknown
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Expected O, but got Unknown
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Expected O, but got Unknown
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Expected O, but got Unknown
ModSettingsManager.SetModDescription("A standalone version of the Well-Rounded Balance mod's gold scaling, with some more values now configurable + some mod support.");
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ConfigOptions.EnableWRBGoldScaling, true));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.BaseGoldScalingMultiplier));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.LoopMultiplier));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.StageDivisor));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.StageClearCountMultiplier));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.StageMultiplier));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.SquareRootMultiplier));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.StageAndLoopMultiplier));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ConfigOptions.EnableWRBMultiplayerCostScaling, true));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.BaseMultiplayerCostMultiplier));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.PerPlayerCostMultiplier));
if (!Starstorm2.ModIsRunning)
{
return;
}
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ConfigOptions.EnableSS2Support, true));
if (ConfigOptions.EnableSS2Support.Value)
{
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ConfigOptions.SS2Empyrean_EnableChange, true));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.SS2Empyrean_NerfBaseMultiplier));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.SS2Empyrean_NerfPerStageMultiplier));
ModSettingsManager.AddOption((BaseOption)new IntFieldOption(ConfigOptions.SS2Empyrean_StageOfNerfStart));
if (Starstorm2.IsBetaVersion)
{
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ConfigOptions.SS2Ethereal_EnableChange, true));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.SS2Ethereal_NerfBaseMultiplier));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.SS2Ethereal_EtherealsUsedMultiplier));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.SS2Ethereal_NerfPerStageMultiplier));
ModSettingsManager.AddOption((BaseOption)new IntFieldOption(ConfigOptions.SS2Ethereal_StageOfNerfStart));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ConfigOptions.SS2Ultra_EnableChange, true));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.SS2Ultra_NerfBaseMultiplier));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.SS2Ultra_EtherealsUsedMultiplier));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.SS2Ultra_NerfPerStageMultiplier));
ModSettingsManager.AddOption((BaseOption)new IntFieldOption(ConfigOptions.SS2Ultra_StageOfNerfStart));
}
}
}
}
internal static class Starstorm2
{
private enum EtherealEliteType
{
Ethereal,
Ultra
}
[HarmonyPatch]
internal class EmpyreanGoldReward
{
[HarmonyPatch(typeof(CustomEliteDirector), "MakeEmpyrean")]
[HarmonyILManipulator]
internal static void Patch(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (!val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCallvirt<DeathRewards>(x, "set_goldReward")
}))
{
Log.Error("COULD NOT IL HOOK " + ((MemberReference)il.Method).Name);
Log.Warning($"cursor is {val}");
Log.Warning($"il is {il}");
}
else
{
val.Emit(OpCodes.Ldloc, 3);
val.EmitDelegate<Func<uint, DeathRewards, uint>>((Func<uint, DeathRewards, uint>)((uint oldGoldReward, DeathRewards deathRewards) => GetNewEmpyreanGoldReward(deathRewards.goldReward)));
}
}
}
[HarmonyPatch]
internal class EmpyreanGoldReward_Beta
{
[HarmonyPatch(typeof(Empyrean), "MakeElite")]
[HarmonyILManipulator]
internal static void Patch(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (!val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCallvirt<DeathRewards>(x, "set_goldReward")
}))
{
Log.Error("COULD NOT IL HOOK " + ((MemberReference)il.Method).Name);
Log.Warning($"cursor is {val}");
Log.Warning($"il is {il}");
}
else
{
val.Emit(OpCodes.Ldloc, 3);
val.EmitDelegate<Func<uint, DeathRewards, uint>>((Func<uint, DeathRewards, uint>)((uint oldGoldReward, DeathRewards deathRewards) => GetNewEmpyreanGoldReward(deathRewards.goldReward)));
}
}
}
[HarmonyPatch]
internal class EtherealGoldReward
{
[HarmonyPatch(typeof(Ethereal), "MakeElite")]
[HarmonyILManipulator]
internal static void Patch(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCallvirt<DeathRewards>(x, "set_goldReward")
}))
{
Log.Error("COULD NOT IL HOOK " + ((MemberReference)il.Method).Name);
Log.Warning($"cursor is {val}");
Log.Warning($"il is {il}");
}
else
{
val.Emit(OpCodes.Ldloc, 4);
val.EmitDelegate<Func<uint, DeathRewards, uint>>((Func<uint, DeathRewards, uint>)((uint oldGoldReward, DeathRewards deathRewards) => GetNewEtherealGoldReward(EtherealEliteType.Ethereal, deathRewards.goldReward)));
}
}
}
[HarmonyPatch]
internal class UltraGoldReward
{
[HarmonyPatch(typeof(Ultra), "MakeElite")]
[HarmonyILManipulator]
internal static void Patch(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCallvirt<DeathRewards>(x, "set_goldReward")
}))
{
Log.Error("COULD NOT IL HOOK " + ((MemberReference)il.Method).Name);
Log.Warning($"cursor is {val}");
Log.Warning($"il is {il}");
}
else
{
val.Emit(OpCodes.Ldloc, 4);
val.EmitDelegate<Func<uint, DeathRewards, uint>>((Func<uint, DeathRewards, uint>)((uint oldGoldReward, DeathRewards deathRewards) => GetNewEtherealGoldReward(EtherealEliteType.Ultra, deathRewards.goldReward)));
}
}
}
private static bool? _modexists;
private static bool? _isBetaVersion;
internal static bool ModIsRunning
{
get
{
bool valueOrDefault = _modexists.GetValueOrDefault();
if (!_modexists.HasValue)
{
valueOrDefault = Chainloader.PluginInfos.ContainsKey("com.TeamMoonstorm");
_modexists = valueOrDefault;
}
return _modexists.Value;
}
}
internal static bool IsBetaVersion
{
get
{
if (_isBetaVersion.HasValue)
{
return _isBetaVersion.Value;
}
if (Chainloader.PluginInfos.TryGetValue("com.TeamMoonstorm", out var value) && value.Metadata.Version.ToString() == "0.6.16")
{
bool valueOrDefault = _isBetaVersion.GetValueOrDefault();
if (!_isBetaVersion.HasValue)
{
valueOrDefault = true;
_isBetaVersion = valueOrDefault;
}
}
return _isBetaVersion.Value;
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
private static uint GetNewEtherealGoldReward(EtherealEliteType eliteType, uint goldReward)
{
EtherealBehavior instance = EtherealBehavior.instance;
float num = 0f;
float num2 = 0f;
int num3 = 0;
float num4 = 0f;
switch (eliteType)
{
case EtherealEliteType.Ethereal:
num = ConfigOptions.SS2Ethereal_NerfBaseMultiplier.Value;
num2 = ConfigOptions.SS2Ethereal_EtherealsUsedMultiplier.Value;
num3 = ConfigOptions.SS2Ethereal_StageOfNerfStart.Value;
num4 = ConfigOptions.SS2Ethereal_NerfPerStageMultiplier.Value;
break;
case EtherealEliteType.Ultra:
num = ConfigOptions.SS2Ultra_NerfBaseMultiplier.Value;
num2 = ConfigOptions.SS2Ultra_EtherealsUsedMultiplier.Value;
num3 = ConfigOptions.SS2Ultra_StageOfNerfStart.Value;
num4 = ConfigOptions.SS2Ultra_NerfPerStageMultiplier.Value;
break;
}
return goldReward *= Convert.ToUInt32(MathF.Max(1f, (num + num2 * (float)instance.etherealsCompleted) / (1f + MathF.Max(0f, (float)(Main.CurrentStageNumber - num3) * num4))));
}
private static uint GetNewEmpyreanGoldReward(uint goldReward)
{
float value = ConfigOptions.SS2Empyrean_NerfBaseMultiplier.Value;
int value2 = ConfigOptions.SS2Empyrean_StageOfNerfStart.Value;
float value3 = ConfigOptions.SS2Empyrean_NerfPerStageMultiplier.Value;
return goldReward *= Convert.ToUInt32(MathF.Max(1f, value / (1f + MathF.Max(0f, (float)(Main.CurrentStageNumber - value2) * value3))));
}
}
}
[BepInPlugin("LordVGames.AlternativeGoldScaling", "AlternativeGoldScaling", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private static class <>O
{
public static hook_OnKilledServer <0>__DeathRewards_OnKilledServer;
public static Manipulator <1>__Run_GetDifficultyScaledCost_int_float;
}
public const string PluginGUID = "LordVGames.AlternativeGoldScaling";
public const string PluginAuthor = "LordVGames";
public const string PluginName = "AlternativeGoldScaling";
public const string PluginVersion = "1.0.0";
public void Awake()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_006a: 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_0075: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Expected O, but got Unknown
Log.Init(((BaseUnityPlugin)this).Logger);
ConfigOptions.BindConfigOptions(((BaseUnityPlugin)this).Config);
if (ModSupport.RiskOfOptionsMod.ModIsRunning)
{
ModSupport.RiskOfOptionsMod.AddOptions();
}
if (ConfigOptions.EnableWRBGoldScaling.Value)
{
object obj = <>O.<0>__DeathRewards_OnKilledServer;
if (obj == null)
{
hook_OnKilledServer val = Main.Hooks.DeathRewards_OnKilledServer;
<>O.<0>__DeathRewards_OnKilledServer = val;
obj = (object)val;
}
DeathRewards.OnKilledServer += (hook_OnKilledServer)obj;
}
if (ConfigOptions.EnableWRBMultiplayerCostScaling.Value)
{
object obj2 = <>O.<1>__Run_GetDifficultyScaledCost_int_float;
if (obj2 == null)
{
Manipulator val2 = Main.Hooks.Run_GetDifficultyScaledCost_int_float;
<>O.<1>__Run_GetDifficultyScaledCost_int_float = val2;
obj2 = (object)val2;
}
Run.GetDifficultyScaledCost_int_float += (Manipulator)obj2;
}
if (!ConfigOptions.EnableSS2Support.Value || !ModSupport.Starstorm2.ModIsRunning)
{
return;
}
Harmony val3 = new Harmony("LordVGames.AlternativeGoldScaling");
if (ConfigOptions.SS2Empyrean_EnableChange.Value)
{
Log.Info("Patching SS2's empyrean gold reward...");
if (ModSupport.Starstorm2.IsBetaVersion)
{
Log.Warning("Version number detected is the same as the beta's version! If this still errors out, either this mod is broken or you may have to update your version of Starstorm 2!");
val3.CreateClassProcessor(typeof(ModSupport.Starstorm2.EmpyreanGoldReward_Beta)).Patch();
}
else
{
val3.CreateClassProcessor(typeof(ModSupport.Starstorm2.EmpyreanGoldReward)).Patch();
}
}
if (ConfigOptions.SS2Ethereal_EnableChange.Value)
{
Log.Info("Patching SS2 beta's ethereal gold reward...");
val3.CreateClassProcessor(typeof(ModSupport.Starstorm2.EtherealGoldReward)).Patch();
}
if (ConfigOptions.SS2Ultra_EnableChange.Value)
{
Log.Info("Patching SS2 beta's ultra gold reward...");
val3.CreateClassProcessor(typeof(ModSupport.Starstorm2.UltraGoldReward)).Patch();
}
}
}
}