using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using EntityStates;
using EntityStates.VoidSurvivor.CorruptMode;
using HG.Reflection;
using IL.EntityStates.VoidSurvivor.CorruptMode;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.AddressableAssets;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("VoidFiendCorruptAPI")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+938b6da7564d472fa2f6a242c4b43edf9014a083")]
[assembly: AssemblyProduct("VoidFiendCorruptAPI")]
[assembly: AssemblyTitle("VoidFiendCorruptAPI")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
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 VoidFiendCorruptAPI
{
[Serializable]
[BepInPlugin("com.brynzananas.voidfiendcorruptapi", "Void Fiend Corrupt API", "1.0.0")]
public class VoidFiendCorruptAPI : BaseUnityPlugin
{
public const string ModGuid = "com.brynzananas.voidfiendcorruptapi";
public const string ModName = "Void Fiend Corrupt API";
public const string ModVer = "1.0.0";
private static SkillDef corruptedPrimarySkill;
private static SkillDef corruptedSecondarySkill;
private static SkillDef corruptedUtilitySkill;
private static SkillDef corruptedSpecialSkill;
private static Dictionary<SkillDef, SkillDef> uncorruptSkillToCorruptSkill = new Dictionary<SkillDef, SkillDef>();
private bool hooksSet;
public void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
corruptedPrimarySkill = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/DLC1/VoidSurvivor/FireCorruptBeam.asset").WaitForCompletion();
corruptedSecondarySkill = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/DLC1/VoidSurvivor/FireCorruptDisk.asset").WaitForCompletion();
corruptedUtilitySkill = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/DLC1/VoidSurvivor/VoidBlinkDown.asset").WaitForCompletion();
corruptedSpecialSkill = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/DLC1/VoidSurvivor/CrushHealth.asset").WaitForCompletion();
SetHooks();
}
public void Destroy()
{
UnsetHooks();
}
private void SetHooks()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
if (!hooksSet)
{
CorruptMode.OnEnter += new Manipulator(CorruptMode_OnEnter);
hooksSet = true;
}
}
private void UnsetHooks()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
if (hooksSet)
{
CorruptMode.OnEnter -= new Manipulator(CorruptMode_OnEnter);
hooksSet = false;
}
}
private void CorruptMode_OnEnter(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: 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.MatchLdfld<CorruptMode>(x, "primaryOverrideSkillDef")
}))
{
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Action<CorruptMode>>((Action<CorruptMode>)GetCorruptedPrimarySkill);
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 1 failed!"));
}
if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchLdfld<CorruptMode>(x, "secondaryOverrideSkillDef")
}))
{
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Action<CorruptMode>>((Action<CorruptMode>)GetCorruptedSecondarySkill);
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 2 failed!"));
}
if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchLdfld<CorruptMode>(x, "utilityOverrideSkillDef")
}))
{
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Action<CorruptMode>>((Action<CorruptMode>)GetCorruptedUtilitySkill);
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 3 failed!"));
}
if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchLdfld<CorruptMode>(x, "specialOverrideSkillDef")
}))
{
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Action<CorruptMode>>((Action<CorruptMode>)GetCorruptedSpecialSkill);
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 4 failed!"));
}
}
private void GetCorruptedPrimarySkill(CorruptMode corruptMode)
{
GenericSkill primary = ((EntityState)corruptMode).skillLocator.primary;
SkillDef val = ((primary != null) ? primary.baseSkill : null);
if (!((Object)(object)val == (Object)null) && uncorruptSkillToCorruptSkill.TryGetValue(val, out var value))
{
corruptMode.primaryOverrideSkillDef = value;
}
}
private void GetCorruptedSecondarySkill(CorruptMode corruptMode)
{
GenericSkill secondary = ((EntityState)corruptMode).skillLocator.secondary;
SkillDef val = ((secondary != null) ? secondary.baseSkill : null);
if (!((Object)(object)val == (Object)null) && uncorruptSkillToCorruptSkill.TryGetValue(val, out var value))
{
corruptMode.secondaryOverrideSkillDef = value;
}
}
private void GetCorruptedUtilitySkill(CorruptMode corruptMode)
{
GenericSkill utility = ((EntityState)corruptMode).skillLocator.utility;
SkillDef val = ((utility != null) ? utility.baseSkill : null);
if (!((Object)(object)val == (Object)null) && uncorruptSkillToCorruptSkill.TryGetValue(val, out var value))
{
corruptMode.utilityOverrideSkillDef = value;
}
}
private void GetCorruptedSpecialSkill(CorruptMode corruptMode)
{
GenericSkill special = ((EntityState)corruptMode).skillLocator.special;
SkillDef val = ((special != null) ? special.baseSkill : null);
if (!((Object)(object)val == (Object)null) && uncorruptSkillToCorruptSkill.TryGetValue(val, out var value))
{
corruptMode.specialOverrideSkillDef = value;
}
}
public static void AddCorruptedSkillDef(SkillDef originalSkillDef, SkillDef corruptedSkillDef)
{
if (!uncorruptSkillToCorruptSkill.ContainsKey(originalSkillDef))
{
uncorruptSkillToCorruptSkill.Add(originalSkillDef, corruptedSkillDef);
}
}
}
}