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.Configuration;
using BepInEx.Logging;
using HG.Reflection;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using On.RoR2;
using R2API;
using R2API.Utils;
using RoR2;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EclipseRevamped")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ccd47f88950cfc9cbe340d8974c0d308954fc26a")]
[assembly: AssemblyProduct("EclipseRevamped")]
[assembly: AssemblyTitle("EclipseRevamped")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.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 EclipseRevamped
{
internal static class Log
{
internal static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
{
int num = callerPath.LastIndexOf("EclipseRevamped");
if (num >= 0)
{
callerPath = callerPath.Substring(num + "EclipseRevamped".Length + 1);
}
return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
}
internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Error_NoCallerPrefix(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Fatal_NoCallerPrefix(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Info_NoCallerPrefix(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Message_NoCallerPrefix(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Warning_NoCallerPrefix(object data)
{
_logSource.LogWarning(data);
}
}
[BepInPlugin("Nuxlar.EclipseRevamped", "EclipseRevamped", "1.1.3")]
public class Main : BaseUnityPlugin
{
public const string PluginGUID = "Nuxlar.EclipseRevamped";
public const string PluginAuthor = "Nuxlar";
public const string PluginName = "EclipseRevamped";
public const string PluginVersion = "1.1.3";
public static ConfigEntry<bool> shouldChangeE1;
public static ConfigEntry<bool> shouldChangeE2;
public static ConfigEntry<bool> shouldChangeE3;
public static ConfigEntry<bool> shouldChangeE4;
public static ConfigEntry<bool> shouldChangeE5;
public static ConfigEntry<bool> shouldChangeE6;
public static ConfigEntry<bool> shouldChangeE7;
internal static Main Instance { get; private set; }
public static string PluginDirectory { get; private set; }
private static ConfigFile ERConfig { get; set; }
public void Awake()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Expected O, but got Unknown
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Expected O, but got Unknown
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Expected O, but got Unknown
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Expected O, but got Unknown
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Expected O, but got Unknown
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Expected O, but got Unknown
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Expected O, but got Unknown
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Expected O, but got Unknown
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Expected O, but got Unknown
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Expected O, but got Unknown
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Expected O, but got Unknown
Instance = this;
Stopwatch stopwatch = Stopwatch.StartNew();
Log.Init(((BaseUnityPlugin)this).Logger);
ERConfig = new ConfigFile(Paths.ConfigPath + "\\com.Nuxlar.EclipseRevamped.cfg", true);
shouldChangeE1 = ERConfig.Bind<bool>("General", "Enable E1 Changes", true, "Rework this Eclipse level");
shouldChangeE2 = ERConfig.Bind<bool>("General", "Enable E2 Changes", true, "Rework this Eclipse level");
shouldChangeE3 = ERConfig.Bind<bool>("General", "Enable E3 Changes", true, "Rework this Eclipse level");
shouldChangeE4 = ERConfig.Bind<bool>("General", "Enable E4 Changes", true, "Tweak this Eclipse level");
shouldChangeE5 = ERConfig.Bind<bool>("General", "Enable E5 Changes", true, "Rework this Eclipse level");
shouldChangeE6 = ERConfig.Bind<bool>("General", "Enable E6 Changes", true, "Rework this Eclipse level");
shouldChangeE7 = ERConfig.Bind<bool>("General", "Enable E7 Changes", true, "Tweak this Eclipse level");
ChangeDescriptions();
if (shouldChangeE1.Value)
{
CharacterMaster.OnBodyStart += new Manipulator(RemoveVanillaE1);
TeleporterInteraction.Awake += new hook_Awake(AddNewE1);
}
if (shouldChangeE2.Value)
{
HoldoutZoneController.DoUpdate += new Manipulator(RemoveVanillaE2);
new Hook((MethodBase)Reflection.GetPropertyGetter(typeof(DirectorCard), "cost"), (Delegate)new Func<Func<DirectorCard, int>, DirectorCard, int>(AddNewE2));
}
if (shouldChangeE3.Value)
{
GlobalEventManager.OnCharacterHitGroundServer += new Manipulator(RemoveVanillaE3);
RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(AddNewE3);
}
if (shouldChangeE4.Value)
{
CharacterBody.RecalculateStats += new Manipulator(TweakE4);
}
if (shouldChangeE5.Value)
{
HealthComponent.Heal += new Manipulator(RemoveVanillaE5);
Run.Start += new hook_Start(AddNewE5);
}
if (shouldChangeE6.Value)
{
DeathRewards.OnKilledServer += new Manipulator(RemoveVanillaE6);
CombatDirector.Init += new hook_Init(AddNewE6);
}
if (shouldChangeE7.Value)
{
CharacterBody.RecalculateStats += new Manipulator(TweakE7);
}
stopwatch.Stop();
Log.Info_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalSeconds:F2} seconds");
}
private void AddNewE5(orig_Start orig, Run self)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Invalid comparison between Unknown and I4
orig.Invoke(self);
EliteDef[] eliteTypes;
if (Object.op_Implicit((Object)(object)Run.instance) && (int)Run.instance.selectedDifficulty >= 7)
{
EliteAPI.VanillaEliteTiers[1].costMultiplier = 4.5f;
EliteAPI.VanillaEliteTiers[4].costMultiplier = 4.5f;
EliteTierDef obj = EliteAPI.VanillaEliteTiers[5];
obj.costMultiplier = 25f;
eliteTypes = obj.eliteTypes;
foreach (EliteDef val in eliteTypes)
{
if ((Object)(object)val != (Object)null)
{
val.damageBoostCoefficient = 4f;
val.healthBoostCoefficient = 12f;
}
}
return;
}
EliteAPI.VanillaEliteTiers[1].costMultiplier = 6f;
EliteAPI.VanillaEliteTiers[4].costMultiplier = 6f;
EliteTierDef obj2 = EliteAPI.VanillaEliteTiers[5];
obj2.costMultiplier = 36f;
eliteTypes = obj2.eliteTypes;
foreach (EliteDef val2 in eliteTypes)
{
if ((Object)(object)val2 != (Object)null)
{
val2.damageBoostCoefficient = 6f;
val2.healthBoostCoefficient = 18f;
}
}
}
private void AddNewE6(orig_Init orig)
{
orig.Invoke();
EliteAPI.VanillaEliteTiers[5].isAvailable = delegate(EliteRules rules)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Invalid comparison between Unknown and I4
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Invalid comparison between Unknown and I4
if (Object.op_Implicit((Object)(object)Run.instance) && (int)Run.instance.selectedDifficulty >= 7)
{
if (Object.op_Implicit((Object)(object)Run.instance))
{
return Run.instance.stageClearCount >= 3;
}
return false;
}
return Object.op_Implicit((Object)(object)Run.instance) && Run.instance.loopClearCount > 0 && (int)rules == 0;
};
}
private void AddNewE3(CharacterBody sender, StatHookEventArgs args)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Invalid comparison between Unknown and I4
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Invalid comparison between Unknown and I4
if (Object.op_Implicit((Object)(object)Run.instance) && (int)Run.instance.selectedDifficulty >= 5 && Object.op_Implicit((Object)(object)sender) && Object.op_Implicit((Object)(object)sender.teamComponent) && (int)sender.teamComponent.teamIndex != 1)
{
args.attackSpeedMultAdd += 0.25f;
}
}
public int AddNewE2(Func<DirectorCard, int> orig, DirectorCard self)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Invalid comparison between Unknown and I4
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Invalid comparison between Unknown and I4
if (Object.op_Implicit((Object)(object)Run.instance) && (int)Run.instance.selectedDifficulty >= 4)
{
SpawnCard spawnCard = self.GetSpawnCard();
if (Object.op_Implicit((Object)(object)spawnCard) && (int)spawnCard.hullSize == 1)
{
return (int)Math.Round((float)spawnCard.directorCreditCost * 0.8f, 0, MidpointRounding.AwayFromZero);
}
return spawnCard.directorCreditCost;
}
return orig(self);
}
private void AddNewE1(orig_Awake orig, TeleporterInteraction self)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Invalid comparison between Unknown and I4
orig.Invoke(self);
if (Object.op_Implicit((Object)(object)Run.instance) && (int)Run.instance.selectedDifficulty >= 3)
{
self.shrineBonusStacks += 1;
((Component)((Component)self).gameObject.transform.GetChild(0).GetChild(7)).gameObject.SetActive(true);
}
}
private void TweakE7(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)2, new Func<Instruction, bool>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, typeof(Run), "get_selectedDifficulty"),
(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 9)
}))
{
if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.5f)
}))
{
val.Next.Operand = 0.75f;
}
}
else
{
Log.Error("EclipseRevamped: Failed to tweak vanilla E7", "C:\\Users\\romym\\Desktop\\RoR2Mods\\EclipseRevamped\\EclipseRevamped\\Main.cs", "TweakE7", 199);
}
}
private void TweakE4(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.MatchCallvirt(x, typeof(Run), "get_selectedDifficulty")
}))
{
val.GotoNext((MoveType)0, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.4f)
});
val.Next.Operand = 0.5f;
}
else
{
Log.Error("EclipseRevamped: Failed to tweak vanilla E4", "C:\\Users\\romym\\Desktop\\RoR2Mods\\EclipseRevamped\\EclipseRevamped\\Main.cs", "TweakE4", 213);
}
}
private void RemoveVanillaE1(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, 0.5f)
}))
{
val.Next.Operand = 1f;
}
else
{
Log.Error("EclipseRevamped: Failed to remove vanilla E1", "C:\\Users\\romym\\Desktop\\RoR2Mods\\EclipseRevamped\\EclipseRevamped\\Main.cs", "RemoveVanillaE1", 224);
}
}
private void RemoveVanillaE2(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, 0.5f)
}))
{
val.Next.Operand = 1f;
}
else
{
Log.Error("EclipseRevamped: Failed to remove vanilla E2", "C:\\Users\\romym\\Desktop\\RoR2Mods\\EclipseRevamped\\EclipseRevamped\\Main.cs", "RemoveVanillaE2", 235);
}
}
private void RemoveVanillaE3(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.MatchLdcI4(x, 5)
}))
{
int index = val.Index + 1;
val.Index = index;
val.EmitDelegate<Func<int, int>>((Func<int, int>)((int useless) => int.MaxValue));
}
else
{
Log.Error("EclipseRevamped: Failed to remove vanilla E3", "C:\\Users\\romym\\Desktop\\RoR2Mods\\EclipseRevamped\\EclipseRevamped\\Main.cs", "RemoveVanillaE3", 248);
}
}
private void RemoveVanillaE5(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>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 2f),
(Instruction x) => ILPatternMatchingExt.MatchDiv(x)
}))
{
val.Next.Operand = 1f;
}
else
{
Log.Error("EclipseRevamped: Failed to tweak vanilla E5", "C:\\Users\\romym\\Desktop\\RoR2Mods\\EclipseRevamped\\EclipseRevamped\\Main.cs", "RemoveVanillaE5", 260);
}
}
private void RemoveVanillaE6(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, 0.8f)
}))
{
val.Next.Operand = 1f;
}
else
{
Log.Error("EclipseRevamped: Failed to remove vanilla E6", "C:\\Users\\romym\\Desktop\\RoR2Mods\\EclipseRevamped\\EclipseRevamped\\Main.cs", "RemoveVanillaE6", 271);
}
}
private void ChangeDescriptions()
{
string text = "Starts at baseline Monsoon difficulty.\n";
string text2 = (shouldChangeE1.Value ? "\n<mspace=0.5em>(1)</mspace> Teleporter Bosses: <style=cIsHealth>+100%</style></style>" : "\n<mspace=0.5em>(1)</mspace> Ally Starting Health: <style=cIsHealth>-50%</style></style>");
string text3 = (shouldChangeE2.Value ? "\n<mspace=0.5em>(2)</mspace> Larger Enemies <style=cIsHealth>appear more often</style></style>" : "\n<mspace=0.5em>(2)</mspace> Teleporter Radius: <style=cIsHealth>-50%</style></style>");
string text4 = (shouldChangeE3.Value ? "\n<mspace=0.5em>(3)</mspace> Enemy Attack Speed: <style=cIsHealth>+25%</style></style>" : "\n<mspace=0.5em>(3)</mspace> Ally Fall Damage: <style=cIsHealth>+100% and lethal</style></style>");
string text5 = (shouldChangeE4.Value ? "\n<mspace=0.5em>(4)</mspace> Enemies: <style=cIsHealth>+50% Faster</style></style>" : "\n<mspace=0.5em>(4)</mspace> Enemies: <style=cIsHealth>+40% Faster</style></style>");
string text6 = (shouldChangeE5.Value ? "\n<mspace=0.5em>(5)</mspace> Enemy Elites: <style=cIsHealth>+25%</style></style>" : "\n<mspace=0.5em>(5)</mspace> Ally Healing: <style=cIsHealth>-50%</style></style>");
string text7 = (shouldChangeE6.Value ? "\n<mspace=0.5em>(6)</mspace> Tier 2 Elites <style=cIsHealth>appear earlier</style></style>" : "\n<mspace=0.5em>(6)</mspace> Enemy Gold Drops: <style=cIsHealth>-20%</style></style>");
string text8 = (shouldChangeE7.Value ? "\n<mspace=0.5em>(7)</mspace> Enemy Cooldowns: <style=cIsHealth>-25%</style></style>" : "\n<mspace=0.5em>(7)</mspace> Enemy Cooldowns: <style=cIsHealth>-50%</style></style>");
string text9 = "\n<mspace=0.5em>(8)</mspace> Allies recieve <style=cIsHealth>permanent damage</style></style>";
string text10 = "\"You only celebrate in the light... because I allow it.\" \n\n";
LanguageAPI.Add("ECLIPSE_1_DESCRIPTION", text + text2);
LanguageAPI.Add("ECLIPSE_2_DESCRIPTION", text + text2 + text3);
LanguageAPI.Add("ECLIPSE_3_DESCRIPTION", text + text2 + text3 + text4);
LanguageAPI.Add("ECLIPSE_4_DESCRIPTION", text + text2 + text3 + text4 + text5);
LanguageAPI.Add("ECLIPSE_5_DESCRIPTION", text + text2 + text3 + text4 + text5 + text6);
LanguageAPI.Add("ECLIPSE_6_DESCRIPTION", text + text2 + text3 + text4 + text5 + text6 + text7);
LanguageAPI.Add("ECLIPSE_7_DESCRIPTION", text + text2 + text3 + text4 + text5 + text6 + text7 + text8);
LanguageAPI.Add("ECLIPSE_8_DESCRIPTION", text10 + text + text2 + text3 + text4 + text5 + text6 + text7 + text8 + text9);
}
}
}