Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of EclipsedShoresBaseMod v2.1.0
ESBM.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ESBM.TweakHelpers; using ESBM.Utils; using ESBM.Utils.Assets; using EntityStates; using EntityStates.BeetleMonster; using EntityStates.Captain.Weapon; using EntityStates.MeridianEvent; using EntityStates.Missions.BrotherEncounter; using KinematicCharacterController; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using On.EntityStates.BeetleMonster; using On.EntityStates.Captain.Weapon; using On.EntityStates.MeridianEvent; using On.EntityStates.Missions.BrotherEncounter; using On.RoR2; using R2API; using RoR2; using RoR2.Audio; using RoR2.CharacterAI; using RoR2.EntitlementManagement; using RoR2.ExpansionManagement; using RoR2.Navigation; using RoR2.Projectile; using RoR2.Skills; using RoR2.UI; using RoR2BepInExPack.Utilities; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.AddressableAssets; using UnityEngine.Audio; using UnityEngine.Networking; using UnityEngine.SceneManagement; [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("ESBM")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+6d6d844bbae1f1ed1aeb6c6755f8ac36b8186a69")] [assembly: AssemblyProduct("ESBM")] [assembly: AssemblyTitle("ESBM")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 ESBM { public class Beetles { [CompilerGenerated] private static class <>O { public static hook_OnEnter <0>__HandleBeetleJump; public static hook_FixedUpdate <1>__HandleBeetleHitbox; public static hook_Start <2>__OnStageStart; } [CompilerGenerated] private sealed class <OnStageStart>d__4 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public orig_Start orig; public Stage self; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <OnStageStart>d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = orig.Invoke(self); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static bool currentRunNotInferno = true; public static bool Enabled => ESBM.Bind("Enemy Tweaks", "Jumping Beetles", "Should Beetles perform leaps to close distance. Leaps are more effective and precise at longer ranges, and leaps are much shorter up close.", val: true); public static void Initialize() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown if (Enabled) { object obj = <>O.<0>__HandleBeetleJump; if (obj == null) { hook_OnEnter val = HandleBeetleJump; <>O.<0>__HandleBeetleJump = val; obj = (object)val; } HeadbuttState.OnEnter += (hook_OnEnter)obj; object obj2 = <>O.<1>__HandleBeetleHitbox; if (obj2 == null) { hook_FixedUpdate val2 = HandleBeetleHitbox; <>O.<1>__HandleBeetleHitbox = val2; obj2 = (object)val2; } HeadbuttState.FixedUpdate += (hook_FixedUpdate)obj2; GameObject beetleMaster = GameObject.BeetleMaster; SkillDef.BeetleBodyHeadbutt.baseRechargeInterval = 2f; SkillDef.BeetleBodyHeadbutt.beginSkillCooldownOnSkillEnd = true; AISkillDriver[] array = (from x in beetleMaster.GetComponents<AISkillDriver>() where (int)x.skillSlot == 0 select x).ToArray(); AISkillDriver[] array2 = array; foreach (AISkillDriver val3 in array2) { val3.maxDistance = 50f; val3.aimType = (AimType)2; } Transform transform = ((Component)GameObject.BeetleBody.GetComponentInChildren<HitBox>()).transform; transform.localScale *= 1.4f; object obj3 = <>O.<2>__OnStageStart; if (obj3 == null) { hook_Start val4 = OnStageStart; <>O.<2>__OnStageStart = val4; obj3 = (object)val4; } Stage.Start += (hook_Start)obj3; } } [IteratorStateMachine(typeof(<OnStageStart>d__4))] private static IEnumerator OnStageStart(orig_Start orig, Stage self) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <OnStageStart>d__4(0) { orig = orig, self = self }; } private static void HandleBeetleHitbox(orig_FixedUpdate orig, HeadbuttState self) { orig.Invoke(self); if (self.attack != null && ((EntityState)self).isAuthority) { self.attack.Fire((List<HurtBox>)null); } } private static void HandleBeetleJump(orig_OnEnter orig, HeadbuttState self) { //IL_0129: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); self.duration *= 0.75f; if (!((BaseState)self).isGrounded) { return; } float num = 60f; float num2 = 15f; CharacterMaster master = ((EntityState)self).characterBody.master; BaseAI component = ((Component)master).GetComponent<BaseAI>(); if (Object.op_Implicit((Object)(object)component.currentEnemy.gameObject)) { num = Mathf.Clamp(Vector3.Distance(((EntityState)self).transform.position, component.currentEnemy.gameObject.transform.position), 15f, 45f); Vector3 position = component.currentEnemy.gameObject.transform.position; if (position.y > ((EntityState)self).transform.position.y) { num2 = position.y - ((EntityState)self).transform.position.y; } if (num < 30f) { num *= 1.75f; } } ((BaseCharacterController)((EntityState)self).characterMotor).Motor.ForceUnground(0.1f); ((EntityState)self).characterMotor.velocity = ((EntityState)self).characterDirection.forward * num + Vector3.up * Util.Remap(num, 0f, 60f, 1f, num2 * 2f); } } public class Mithrix { [CompilerGenerated] private static class <>O { public static hook_TakeDamageProcess <0>__OnHitEnemy; } public static bool NoCripple; public static void Initialize() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown NoCripple = ESBM.Bind("Enemy Tweaks", "No Phase 4 Cripple", "Prevent Mithrix from applying Crippled during phase 4?", val: true); if (NoCripple) { object obj = <>O.<0>__OnHitEnemy; if (obj == null) { hook_TakeDamageProcess val = OnHitEnemy; <>O.<0>__OnHitEnemy = val; obj = (object)val; } HealthComponent.TakeDamageProcess += (hook_TakeDamageProcess)obj; } } private static void OnHitEnemy(orig_TakeDamageProcess orig, HealthComponent self, DamageInfo damageInfo) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (NoCripple && ((Enum)damageInfo.damageType.damageType).HasFlag((Enum)(object)(DamageType)4194304) && Object.op_Implicit((Object)(object)PhaseCounter.instance) && PhaseCounter._instance.phase > 2) { ref DamageType damageType = ref damageInfo.damageType.damageType; damageType = (DamageType)((uint)damageType & 0xFFBFFFFFu); } orig.Invoke(self, damageInfo); } } [BepInPlugin("_0.Smxrez.ESBM", "ESBM", "1.0.2")] public class ESBM : BaseUnityPlugin { public const string PluginGUID = "_0.Smxrez.ESBM"; public const string PluginAuthor = "Smxrez"; public const string PluginName = "ESBM"; public const string PluginVersion = "1.0.2"; public static ManualLogSource ModLogger; private static ConfigFile conf; public static BindingFlags FLAGS = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; public void Awake() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown ModLogger = ((BaseUnityPlugin)this).Logger; conf = new ConfigFile(Path.Combine(Paths.ConfigPath, "Smxrez.ESBM.cfg"), true); MiscTweaks.Initialize(); ItemWeightImprovement.Initialize(); BodyCustomizer.Initializer(); Beetles.Initialize(); Mithrix.Initialize(); PlayerRespawns.Initialize(); NoDiabloDamage.Initialize(); } public void Start() { StunResistance.Initialize(); } public static T Bind<T>(string sec, string key, string desc, T val) { return conf.Bind<T>(sec, key, val, desc).Value; } public static void ApplyIfExists(string assembly, Action<Assembly> handler) { Assembly assembly2 = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly x) => x.GetName().Name == assembly); if (assembly2 != null) { handler(assembly2); } } } public class BodyCustomizer { [CompilerGenerated] private static class <>O { public static hook_Init <0>__OnCatalogInit; } [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct <>c__DisplayClass3_0 { public string bodyName; } [CompilerGenerated] private sealed class <OnCatalogInit>d__3 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public orig_Init orig; private IEnumerator<GameObject> <>s__1; private GameObject <body>5__2; private <>c__DisplayClass3_0 <>8__3; private CharacterBody <c>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <OnCatalogInit>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>s__1 = null; <body>5__2 = null; <>8__3 = default(<>c__DisplayClass3_0); <c>5__4 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = orig.Invoke(); <>1__state = 1; return true; case 1: <>1__state = -1; <>s__1 = BodyCatalog.allBodyPrefabs.GetEnumerator(); try { while (<>s__1.MoveNext()) { <body>5__2 = <>s__1.Current; <>8__3.bodyName = ((Object)<body>5__2).name.Replace("'", ""); if (BodyConfig.Bind<bool>("Config Generation", <>8__3.bodyName, false, "Generate configs for this body.").Value) { <c>5__4 = <body>5__2.GetComponent<CharacterBody>(); <c>5__4.baseDamage = <OnCatalogInit>g__Bind|3_0("Base Damage", "The base damage of the survivor.", <c>5__4.baseDamage, ref <c>5__4.levelDamage, ref <>8__3); <c>5__4.baseAttackSpeed = <OnCatalogInit>g__Bind|3_0("Base Attack Speed", "The base attack speed of the survivor.", <c>5__4.baseAttackSpeed, ref <c>5__4.levelAttackSpeed, ref <>8__3); <c>5__4.baseMaxHealth = <OnCatalogInit>g__Bind|3_0("Base Max Health", "The base maximum health of the survivor.", <c>5__4.baseMaxHealth, ref <c>5__4.levelMaxHealth, ref <>8__3); <c>5__4.baseArmor = <OnCatalogInit>g__Bind|3_0("Base Armor", "The base armor of the survivor.", <c>5__4.baseArmor, ref <c>5__4.levelArmor, ref <>8__3); <c>5__4.baseMoveSpeed = <OnCatalogInit>g__Bind|3_0("Base Movement Speed", "The base movement speed of the survivor.", <c>5__4.baseMoveSpeed, ref <c>5__4.levelMoveSpeed, ref <>8__3); <c>5__4.baseRegen = <OnCatalogInit>g__Bind|3_0("Base Regen", "The base regen of the survivor.", <c>5__4.baseRegen, ref <c>5__4.levelRegen, ref <>8__3); <c>5__4 = null; } <>8__3 = default(<>c__DisplayClass3_0); <body>5__2 = null; } } finally { if (<>s__1 != null) { <>s__1.Dispose(); } } <>s__1 = null; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static ConfigFile BodyConfig; public static ConfigFile BodyEnableConfig; public static void Initializer() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown object obj = <>O.<0>__OnCatalogInit; if (obj == null) { hook_Init val = OnCatalogInit; <>O.<0>__OnCatalogInit = val; obj = (object)val; } BodyCatalog.Init += (hook_Init)obj; BodyConfig = new ConfigFile(Path.Combine(Paths.ConfigPath, "ESBM-BodyConfig.cfg"), true); } [IteratorStateMachine(typeof(<OnCatalogInit>d__3))] private static IEnumerator OnCatalogInit(orig_Init orig) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <OnCatalogInit>d__3(0) { orig = orig }; } } public class ItemWeightImprovement { [CompilerGenerated] private static class <>O { public static hook_OnInteractionBegin <0>__HandleChestLootReroll; } public static bool Enabled => ESBM.Bind("Item Weight Tweaks", "Enabled", "Enable item weight scaling? This scales weights so that you are more likely to receive duplicates the more diverse your inventory is.", val: false); public static float Ratio => ESBM.Bind("Item Weight Tweaks", "Inventory Ratio", "The percentage ratio of stacked to unstacked items, as a percentage of stacked compared to total inventory. Item weights of duplicates are increased the further the ratio is from this config.", 2.5f); public static void Initialize() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (Enabled) { _ = Ratio; object obj = <>O.<0>__HandleChestLootReroll; if (obj == null) { hook_OnInteractionBegin val = HandleChestLootReroll; <>O.<0>__HandleChestLootReroll = val; obj = (object)val; } PurchaseInteraction.OnInteractionBegin += (hook_OnInteractionBegin)obj; } } private static void HandleChestLootReroll(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)((Component)self).GetComponent<ChestBehavior>())) { Scene activeScene = SceneManager.GetActiveScene(); if (!((Scene)(ref activeScene)).name.StartsWith("it")) { ChestBehavior component = ((Component)self).GetComponent<ChestBehavior>(); if (component.dropTable is BasicPickupDropTable && Object.op_Implicit((Object)(object)((Component)activator).GetComponent<CharacterBody>())) { PickupDropTable dropTable = component.dropTable; BasicPickupDropTable val = (BasicPickupDropTable)(object)((dropTable is BasicPickupDropTable) ? dropTable : null); if (!(val.equipmentWeight > 0f) && !(val.lunarItemWeight > 0f) && !(val.lunarEquipmentWeight > 0f) && !(val.lunarCombinedWeight > 0f)) { ? val2 = component; PickupDropTable dropTable2 = component.dropTable; ((ChestBehavior)val2).currentPickup = RollModifiedDrop((BasicPickupDropTable)(object)((dropTable2 is BasicPickupDropTable) ? dropTable2 : null), ((Component)activator).GetComponent<CharacterBody>()); } } } } orig.Invoke(self, activator); } public static UniquePickup RollModifiedDrop(BasicPickupDropTable table, CharacterBody user) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) DiversePickupTable diversePickupTable = new DiversePickupTable(table, Run.instance.stageRng); return new UniquePickup(diversePickupTable.GenerateDropForPlayer(user.inventory)); } } public class DiversePickupTable { public WeightedSelection<List<PickupIndex>> TierSelection = new WeightedSelection<List<PickupIndex>>(8); public Xoroshiro128Plus rng; public void PopulateFromDropTable(BasicPickupDropTable table) { TierSelection.Clear(); TierSelection.AddChoice(new List<PickupIndex>(), table.tier1Weight); AddToSelection(Run.instance.availableTier1DropList, ref TierSelection.choices[TierSelection.Count - 1].value, table); TierSelection.AddChoice(new List<PickupIndex>(), table.tier2Weight); AddToSelection(Run.instance.availableTier2DropList, ref TierSelection.choices[TierSelection.Count - 1].value, table); TierSelection.AddChoice(new List<PickupIndex>(), table.tier3Weight); AddToSelection(Run.instance.availableTier3DropList, ref TierSelection.choices[TierSelection.Count - 1].value, table); TierSelection.AddChoice(new List<PickupIndex>(), table.voidTier1Weight); AddToSelection(Run.instance.availableVoidTier1DropList, ref TierSelection.choices[TierSelection.Count - 1].value, table); TierSelection.AddChoice(new List<PickupIndex>(), table.voidTier2Weight); AddToSelection(Run.instance.availableVoidTier2DropList, ref TierSelection.choices[TierSelection.Count - 1].value, table); TierSelection.AddChoice(new List<PickupIndex>(), table.voidTier3Weight); AddToSelection(Run.instance.availableVoidTier3DropList, ref TierSelection.choices[TierSelection.Count - 1].value, table); } public DiversePickupTable(BasicPickupDropTable table, Xoroshiro128Plus rng) { PopulateFromDropTable(table); this.rng = rng; } public PickupIndex GenerateDropForPlayer(Inventory inventory) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) List<PickupIndex> list = TierSelection.Evaluate(rng.nextNormalizedFloat); WeightedSelection<PickupIndex> val = new WeightedSelection<PickupIndex>(8); float sameTypeWeightMultiplier = GetSameTypeWeightMultiplier(GetTierForSelection(list), inventory); ESBM.ModLogger.LogError((object)("Stackable Weight For Player: " + sameTypeWeightMultiplier)); foreach (PickupIndex item in list) { ItemDef itemDef = ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(item).itemIndex); float num = 1f; if (inventory.GetItemCount(itemDef) > 0) { num *= ((inventory.GetItemCount(itemDef) > 1) ? sameTypeWeightMultiplier : (sameTypeWeightMultiplier * 0.5f)); } val.AddChoice(item, num); } return val.Evaluate(rng.nextNormalizedFloat); } public static float GetSameTypeWeightMultiplier(ItemTierDef tier, Inventory inventory) { //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_0026: Unknown result type (might be due to invalid IL or missing references) float result = 1f; int num = 0; int num2 = 0; foreach (ItemIndex item in inventory.itemAcquisitionOrder) { int itemCount = inventory.GetItemCount(item); num += itemCount; if (itemCount > 1) { num2 += itemCount; } } float num3 = (float)num2 / (float)num; if (num3 < ItemWeightImprovement.Ratio) { result = 1f + (ItemWeightImprovement.Ratio - num3); } return result; } public ItemTierDef GetTierForSelection(List<PickupIndex> selection) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(selection[0]).itemIndex)._itemTierDef; } public void AddToSelection(List<PickupIndex> indices, ref List<PickupIndex> selection, BasicPickupDropTable table) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) foreach (PickupIndex index in indices) { if (!IsFilterRequired() || PassesFilter(index)) { selection.Add(index); } } bool IsFilterRequired() { if (table.requiredItemTags.Length == 0) { return table.bannedItemTags.Length == 0; } return true; } bool PassesFilter(PickupIndex index) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) PickupDef pickupDef = PickupCatalog.GetPickupDef(index); if ((int)pickupDef.itemIndex != -1) { ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); ItemTag[] bannedItemTags = table.bannedItemTags; foreach (ItemTag value in bannedItemTags) { if (Array.IndexOf(itemDef.tags, value) != -1) { return false; } } ItemTag[] requiredItemTags = table.requiredItemTags; foreach (ItemTag value2 in requiredItemTags) { if (Array.IndexOf(itemDef.tags, value2) == -1) { return false; } } return true; } return false; } } } public static class MiscTweaks { public class EmpyreanBracesInfo { public bool lastState = true; public bool state = true; public bool justPressed => !lastState && state; public void SetState(bool nextState) { lastState = state; state = nextState; } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Action<Assembly> <>9__2_0; public static Func<Instruction, bool> <>9__2_8; public static Action<Assembly> <>9__2_1; public static Action<Assembly> <>9__2_2; public static Action<Assembly> <>9__2_3; public static Func<Instruction, bool> <>9__2_11; public static Func<bool, EntityState, bool> <>9__2_12; public static Manipulator <>9__2_10; public static Action<Assembly> <>9__2_4; public static Func<Instruction, bool> <>9__2_15; public static Func<Instruction, bool> <>9__2_16; public static Func<Instruction, bool> <>9__2_17; public static Func<Instruction, bool> <>9__2_18; public static Func<Instruction, bool> <>9__2_19; public static Func<Instruction, bool> <>9__2_20; public static Func<Instruction, bool> <>9__2_21; public static Func<Instruction, bool> <>9__2_22; public static Func<Instruction, bool> <>9__2_23; public static Func<Instruction, bool> <>9__2_24; public static Func<Instruction, bool> <>9__2_25; public static Manipulator <>9__2_13; public static Func<Instruction, bool> <>9__2_26; public static Manipulator <>9__2_14; public static Action<Assembly> <>9__2_5; public static Action<Assembly> <>9__2_6; internal void <Initialize>b__2_0(Assembly x) { if (ESBM.Bind("Mod Changes :: Razorhive", "Disable Hit Refresh", "Removes Razorhives ability to refresh on hit.", val: false)) { new FieldPatch(x, "RazorwireMod.Items.HiveOrb", "damageType", new ValueData { iVals = new int[0] }, "OnArrival", "r2api_moddedDamageTypes"); new FieldPatch(x, "RazorwireMod.Items.Razorhive", "ItemFullDescription", new ValueData { sVal = "", filter = new Filter { StringFilter = "Each sting <style=cIsUtility>refreshes</style> the duration. " }, operation = "Replace" }); } } internal void <Initialize>b__2_1(Assembly x) { //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown <>c__DisplayClass2_0 CS$<>8__locals0 = new <>c__DisplayClass2_0(); if (ESBM.Bind("Mod Changes :: Hex3Mod", "Captains Favor Corruption", "Makes Captains Favor corrupt Sale Star.", val: false)) { new MethodPatch(x, "Hex3Mod.Items.CaptainsFavor", "AddHooks", new ValueData { sVal = "LowerPricedChests", filter = new Filter { StringFilter = "FourHundredTickets" } }, Operation.Replace); new MethodPatch(x, "Hex3Mod.Items.CaptainsFavor", "AddTokens", new ValueData { sVal = "The first chests you open each stage will be replaced by a Void Potential. <style=cIsVoid>Corrupts all Sale Stars.</style>", filter = new Filter { StringFilter = "The first chests you open each stage will be replaced by a Void Potential. <style=cIsVoid>Corrupts all 400 Tickets.</style>" } }, Operation.Replace); new MethodPatch(x, "Hex3Mod.Items.CaptainsFavor", "UpdateItemStatus", new ValueData { sVal = "The first <style=cStack>(+1 per stack)</style> chest you open each stage will be replaced by a <style=cIsVoid>Void Potential</style>, inheriting the chest's item tiers. <style=cIsVoid>Corrupts all Sale Stars.</style>", filter = new Filter { StringFilter = "The first <style=cStack>(+1 per stack)</style> chest you open each stage will be replaced by a <style=cIsVoid>Void Potential</style>, inheriting the chest's item tiers. <style=cIsVoid>Corrupts all 400 Tickets.</style>" } }, Operation.Replace); } CS$<>8__locals0.nerf = ESBM.Bind("Mod Changes :: Hex3Mod", "The Unforgivable Stack Nerf", "Nerfs the reduction per stack on The Unforgivable. Default is 0.5", 0.5f); ILHook val = new ILHook((MethodBase)x.GetType("Hex3Mod.Items.TheUnforgivable/UnforgivableBehavior").GetMethod("FixedUpdate", ESBM.FLAGS), (Manipulator)delegate(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val2 = new ILCursor(il); val2.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchDiv(x) }); val2.Remove(); val2.EmitDelegate<Func<float, float, float>>((Func<float, float, float>)((float interval, float stack) => (stack >= 2f) ? (interval * Mathf.Pow(1f - CS$<>8__locals0.nerf, stack)) : interval)); }); new MethodPatch(x, "Hex3Mod.Items.TheUnforgivable", "UpdateItemStatus", new ValueData { sVal = "Activate your <style=cIsDamage>on-kill effects</style> at your location every <style=cIsDamage>{0}</style> <style=cStack>" + $"(-{CS$<>8__locals0.nerf * 100f}% per stack)</style> seconds.", filter = new Filter { StringFilter = "Activate your <style=cIsDamage>on-kill effects</style> at your location every <style=cIsDamage>{0}</style> <style=cStack>(-50% per stack)</style> seconds." } }, Operation.Replace); } internal bool <Initialize>b__2_8(Instruction x) { return ILPatternMatchingExt.MatchDiv(x); } internal void <Initialize>b__2_2(Assembly x) { if (ESBM.Bind("Mod Changes :: Umbral Mithrix", "No Glass Clones", "Removes the glass clones from the Umbral Mithrix fight.", val: false)) { new MethodPatch(x, "UmbralMithrix.CloneController", "FixedUpdate", new ValueData(), Operation.Return); } } internal void <Initialize>b__2_3(Assembly x) { if (ESBM.Bind("Mod Changes :: MysticsItems", "Black Monolith Retier", "Makes Black Monolith a red item.", val: false)) { new FieldPatch(x, "MysticsItems.Items.ExtraShrineUse", "itemDef", new ValueData { spVal = SpriteHandler.ProcessSprite("texRedMonolith.png") }, "OnLoad", "pickupIconSprite", InjectionTiming.End); new MethodPatch(x, "MysticsItems.Items.ExtraShrineUse", "SetItemTierWhenAvailable", new ValueData { eVal = "Tier3" }, Operation.Input, "OnLoad", 1); } int num = ESBM.Bind("Mod Changes :: MysticsItems", "Black Monolith Usages", "Increases the use count of Black Monolith. Default is 1.", 1); new MethodPatch(x, "MysticsItems.Items.ExtraShrineUse", "UpdateShrine", new ValueData { iVal = 2, operation = "Multiply" }, Operation.Input, null, 2); LanguageAPI.AddOverlay("ITEM_MYSTICSITEMS_EXTRASHRINEUSE_DESC", $"All Shrines can be used <style=cIsUtility>{num} <style=cStack>(+{num} per stack)</style></style> more times."); LanguageAPI.AddOverlay("ITEM_MYSTICSITEMS_EXTRASHRINEUSE_PICKUP", "All Shrines can be used " + HumanFriendlyInteger.IntegerToWritten(num) + " more time" + ((num > 1) ? "s" : "") + "."); } internal void <Initialize>b__2_4(Assembly x) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown if (!ESBM.Bind("Mod Changes :: Forgotten Relics", "Empyrean Braces Toggle", "Makes Empyrean Braces toggle to float instead of hold to float.", val: false)) { return; } MethodInfo? method = x.GetType("ForgottenRelicsEntityStates.VoidStompers.VoidStompersCharge").GetMethod("FixedUpdateAuthority", ESBM.FLAGS); object obj = <>9__2_10; if (obj == null) { Manipulator val = delegate(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) ILCursor val3 = new ILCursor(il); ILLabel val4 = default(ILLabel); val3.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val4) }); val3.Emit(OpCodes.Ldarg_0); val3.EmitDelegate<Func<bool, EntityState, bool>>((Func<bool, EntityState, bool>)delegate(bool input, EntityState self) { EmpyreanBracesInfo orCreateValue = EmpyreanBracesToggleMap.GetOrCreateValue(self); orCreateValue.SetState(input); return !orCreateValue.justPressed; }); }; <>9__2_10 = val; obj = (object)val; } ILHook val2 = new ILHook((MethodBase)method, (Manipulator)obj); } internal void <Initialize>b__2_10(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel val2 = default(ILLabel); val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val2) }); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<bool, EntityState, bool>>((Func<bool, EntityState, bool>)delegate(bool input, EntityState self) { EmpyreanBracesInfo orCreateValue = EmpyreanBracesToggleMap.GetOrCreateValue(self); orCreateValue.SetState(input); return !orCreateValue.justPressed; }); } internal bool <Initialize>b__2_11(Instruction x) { ILLabel val = default(ILLabel); return ILPatternMatchingExt.MatchBrtrue(x, ref val); } internal bool <Initialize>b__2_12(bool input, EntityState self) { EmpyreanBracesInfo orCreateValue = EmpyreanBracesToggleMap.GetOrCreateValue(self); orCreateValue.SetState(input); return !orCreateValue.justPressed; } internal void <Initialize>b__2_5(Assembly x) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown if (!ESBM.Bind("Mod Changes :: Dancer", "No Movement Lock", "Removes the movement lock during Dancer's M1.", val: false)) { return; } MethodInfo? method = x.GetType("Dancer.SkillStates.M1.BaseM1").GetMethod("FixedUpdate", ESBM.FLAGS); object obj = <>9__2_13; if (obj == null) { Manipulator val = delegate(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) ILCursor val6 = new ILCursor(il); val6.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "Slash.playbackRate") }); MethodReference val11 = default(MethodReference); MethodReference val10 = default(MethodReference); FieldReference val9 = default(FieldReference); val6.TryGotoPrev((MoveType)0, new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchNop(x), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val11), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val10), (Instruction x) => ILPatternMatchingExt.MatchStfld(x, ref val9) }); for (int i = 0; i < 5; i++) { val6.Next.Operand = null; val6.Next.OpCode = OpCodes.Nop; int index = val6.Index; val6.Index = index + 1; } ILLabel val8 = default(ILLabel); FieldReference val7 = default(FieldReference); val6.TryGotoNext((MoveType)0, new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val8), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, ref val7), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCeq(x) }); val6.Index += 3; val6.Emit(OpCodes.Pop); val6.Emit(OpCodes.Ldc_I4, 1); }; <>9__2_13 = val; obj = (object)val; } ILHook val2 = new ILHook((MethodBase)method, (Manipulator)obj); MethodInfo? method2 = x.GetType("Dancer.SkillStates.M1.BaseM1").GetMethod("StartAttack", ESBM.FLAGS); object obj2 = <>9__2_14; if (obj2 == null) { Manipulator val3 = delegate(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val5 = new ILCursor(il); val5.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.2f) }); val5.Next.Operand = 1f; }; <>9__2_14 = val3; obj2 = (object)val3; } ILHook val4 = new ILHook((MethodBase)method2, (Manipulator)obj2); } internal void <Initialize>b__2_13(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "Slash.playbackRate") }); MethodReference val6 = default(MethodReference); MethodReference val5 = default(MethodReference); FieldReference val4 = default(FieldReference); val.TryGotoPrev((MoveType)0, new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchNop(x), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val6), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val5), (Instruction x) => ILPatternMatchingExt.MatchStfld(x, ref val4) }); for (int i = 0; i < 5; i++) { val.Next.Operand = null; val.Next.OpCode = OpCodes.Nop; int index = val.Index; val.Index = index + 1; } ILLabel val3 = default(ILLabel); FieldReference val2 = default(FieldReference); val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val3), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, ref val2), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCeq(x) }); val.Index += 3; val.Emit(OpCodes.Pop); val.Emit(OpCodes.Ldc_I4, 1); } internal bool <Initialize>b__2_15(Instruction x) { return ILPatternMatchingExt.MatchLdstr(x, "Slash.playbackRate"); } internal bool <Initialize>b__2_16(Instruction x) { return ILPatternMatchingExt.MatchNop(x); } internal bool <Initialize>b__2_17(Instruction x) { return ILPatternMatchingExt.MatchLdarg(x, 0); } internal bool <Initialize>b__2_18(Instruction x) { MethodReference val = default(MethodReference); return ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val); } internal bool <Initialize>b__2_19(Instruction x) { MethodReference val = default(MethodReference); return ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val); } internal bool <Initialize>b__2_20(Instruction x) { FieldReference val = default(FieldReference); return ILPatternMatchingExt.MatchStfld(x, ref val); } internal bool <Initialize>b__2_21(Instruction x) { ILLabel val = default(ILLabel); return ILPatternMatchingExt.MatchBrtrue(x, ref val); } internal bool <Initialize>b__2_22(Instruction x) { return ILPatternMatchingExt.MatchLdarg(x, 0); } internal bool <Initialize>b__2_23(Instruction x) { FieldReference val = default(FieldReference); return ILPatternMatchingExt.MatchLdfld(x, ref val); } internal bool <Initialize>b__2_24(Instruction x) { return ILPatternMatchingExt.MatchLdcI4(x, 0); } internal bool <Initialize>b__2_25(Instruction x) { return ILPatternMatchingExt.MatchCeq(x); } internal void <Initialize>b__2_14(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(il); val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.2f) }); val.Next.Operand = 1f; } internal bool <Initialize>b__2_26(Instruction x) { return ILPatternMatchingExt.MatchLdcR4(x, 0.2f); } internal void <Initialize>b__2_6(Assembly x) { if (ESBM.Bind("Mod Changes :: Starstorm 2", "Enable Select Beta Content", "Enables the following without requiring the beta config: Blast Knuckles, Sticky Overloader, Knight, Archerbug", val: false)) { new MethodPatch(x, "SS2.Items.BlastKnuckles", "IsAvailable", new ValueData { bVal = true }, Operation.Return); new MethodPatch(x, "SS2.Items.StickyOverloader", "IsAvailable", new ValueData { bVal = true }, Operation.Return); new MethodPatch(x, "SS2.Monsters.AcidBug", "IsAvailable", new ValueData { bVal = true }, Operation.Return); new MethodPatch(x, "SS2.Interactables.Pedestal", "IsAvailable", new ValueData { bVal = true }, Operation.Return); new MethodPatch(x, "SS2.Survivors.Knight", "IsAvailable", new ValueData { bVal = true }, Operation.Return); } } } [CompilerGenerated] private sealed class <>c__DisplayClass2_0 { public float nerf; public Func<float, float, float> <>9__9; internal void <Initialize>b__7(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(il); val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchDiv(x) }); val.Remove(); val.EmitDelegate<Func<float, float, float>>((Func<float, float, float>)((float interval, float stack) => (stack >= 2f) ? (interval * Mathf.Pow(1f - nerf, stack)) : interval)); } internal float <Initialize>b__9(float interval, float stack) { return (stack >= 2f) ? (interval * Mathf.Pow(1f - nerf, stack)) : interval; } } public static FixedConditionalWeakTable<EntityState, EmpyreanBracesInfo> EmpyreanBracesToggleMap = new FixedConditionalWeakTable<EntityState, EmpyreanBracesInfo>(); public static void Initialize() { ESBM.ApplyIfExists("RazorhiveMod", delegate(Assembly x) { if (ESBM.Bind("Mod Changes :: Razorhive", "Disable Hit Refresh", "Removes Razorhives ability to refresh on hit.", val: false)) { new FieldPatch(x, "RazorwireMod.Items.HiveOrb", "damageType", new ValueData { iVals = new int[0] }, "OnArrival", "r2api_moddedDamageTypes"); new FieldPatch(x, "RazorwireMod.Items.Razorhive", "ItemFullDescription", new ValueData { sVal = "", filter = new Filter { StringFilter = "Each sting <style=cIsUtility>refreshes</style> the duration. " }, operation = "Replace" }); } }); ESBM.ApplyIfExists("Hex3Mod", delegate(Assembly x) { //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown if (ESBM.Bind("Mod Changes :: Hex3Mod", "Captains Favor Corruption", "Makes Captains Favor corrupt Sale Star.", val: false)) { new MethodPatch(x, "Hex3Mod.Items.CaptainsFavor", "AddHooks", new ValueData { sVal = "LowerPricedChests", filter = new Filter { StringFilter = "FourHundredTickets" } }, Operation.Replace); new MethodPatch(x, "Hex3Mod.Items.CaptainsFavor", "AddTokens", new ValueData { sVal = "The first chests you open each stage will be replaced by a Void Potential. <style=cIsVoid>Corrupts all Sale Stars.</style>", filter = new Filter { StringFilter = "The first chests you open each stage will be replaced by a Void Potential. <style=cIsVoid>Corrupts all 400 Tickets.</style>" } }, Operation.Replace); new MethodPatch(x, "Hex3Mod.Items.CaptainsFavor", "UpdateItemStatus", new ValueData { sVal = "The first <style=cStack>(+1 per stack)</style> chest you open each stage will be replaced by a <style=cIsVoid>Void Potential</style>, inheriting the chest's item tiers. <style=cIsVoid>Corrupts all Sale Stars.</style>", filter = new Filter { StringFilter = "The first <style=cStack>(+1 per stack)</style> chest you open each stage will be replaced by a <style=cIsVoid>Void Potential</style>, inheriting the chest's item tiers. <style=cIsVoid>Corrupts all 400 Tickets.</style>" } }, Operation.Replace); } float nerf = ESBM.Bind("Mod Changes :: Hex3Mod", "The Unforgivable Stack Nerf", "Nerfs the reduction per stack on The Unforgivable. Default is 0.5", 0.5f); ILHook val16 = new ILHook((MethodBase)x.GetType("Hex3Mod.Items.TheUnforgivable/UnforgivableBehavior").GetMethod("FixedUpdate", ESBM.FLAGS), (Manipulator)delegate(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val17 = new ILCursor(il); val17.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchDiv(x) }); val17.Remove(); val17.EmitDelegate<Func<float, float, float>>((Func<float, float, float>)((float interval, float stack) => (stack >= 2f) ? (interval * Mathf.Pow(1f - nerf, stack)) : interval)); }); new MethodPatch(x, "Hex3Mod.Items.TheUnforgivable", "UpdateItemStatus", new ValueData { sVal = "Activate your <style=cIsDamage>on-kill effects</style> at your location every <style=cIsDamage>{0}</style> <style=cStack>" + $"(-{nerf * 100f}% per stack)</style> seconds.", filter = new Filter { StringFilter = "Activate your <style=cIsDamage>on-kill effects</style> at your location every <style=cIsDamage>{0}</style> <style=cStack>(-50% per stack)</style> seconds." } }, Operation.Replace); }); ESBM.ApplyIfExists("UmbralMithrix", delegate(Assembly x) { if (ESBM.Bind("Mod Changes :: Umbral Mithrix", "No Glass Clones", "Removes the glass clones from the Umbral Mithrix fight.", val: false)) { new MethodPatch(x, "UmbralMithrix.CloneController", "FixedUpdate", new ValueData(), Operation.Return); } }); ESBM.ApplyIfExists("MysticsItemsPlugin", delegate(Assembly x) { if (ESBM.Bind("Mod Changes :: MysticsItems", "Black Monolith Retier", "Makes Black Monolith a red item.", val: false)) { new FieldPatch(x, "MysticsItems.Items.ExtraShrineUse", "itemDef", new ValueData { spVal = SpriteHandler.ProcessSprite("texRedMonolith.png") }, "OnLoad", "pickupIconSprite", InjectionTiming.End); new MethodPatch(x, "MysticsItems.Items.ExtraShrineUse", "SetItemTierWhenAvailable", new ValueData { eVal = "Tier3" }, Operation.Input, "OnLoad", 1); } int num = ESBM.Bind("Mod Changes :: MysticsItems", "Black Monolith Usages", "Increases the use count of Black Monolith. Default is 1.", 1); new MethodPatch(x, "MysticsItems.Items.ExtraShrineUse", "UpdateShrine", new ValueData { iVal = 2, operation = "Multiply" }, Operation.Input, null, 2); LanguageAPI.AddOverlay("ITEM_MYSTICSITEMS_EXTRASHRINEUSE_DESC", $"All Shrines can be used <style=cIsUtility>{num} <style=cStack>(+{num} per stack)</style></style> more times."); LanguageAPI.AddOverlay("ITEM_MYSTICSITEMS_EXTRASHRINEUSE_PICKUP", "All Shrines can be used " + HumanFriendlyInteger.IntegerToWritten(num) + " more time" + ((num > 1) ? "s" : "") + "."); }); ESBM.ApplyIfExists("FHCSharp", delegate(Assembly x) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown if (ESBM.Bind("Mod Changes :: Forgotten Relics", "Empyrean Braces Toggle", "Makes Empyrean Braces toggle to float instead of hold to float.", val: false)) { MethodInfo? method3 = x.GetType("ForgottenRelicsEntityStates.VoidStompers.VoidStompersCharge").GetMethod("FixedUpdateAuthority", ESBM.FLAGS); object obj3 = <>c.<>9__2_10; if (obj3 == null) { Manipulator val12 = delegate(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) ILCursor val14 = new ILCursor(il); ILLabel val15 = default(ILLabel); val14.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val15) }); val14.Emit(OpCodes.Ldarg_0); val14.EmitDelegate<Func<bool, EntityState, bool>>((Func<bool, EntityState, bool>)delegate(bool input, EntityState self) { EmpyreanBracesInfo orCreateValue = EmpyreanBracesToggleMap.GetOrCreateValue(self); orCreateValue.SetState(input); return !orCreateValue.justPressed; }); }; <>c.<>9__2_10 = val12; obj3 = (object)val12; } ILHook val13 = new ILHook((MethodBase)method3, (Manipulator)obj3); } }); ESBM.ApplyIfExists("Dancer", delegate(Assembly x) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown if (ESBM.Bind("Mod Changes :: Dancer", "No Movement Lock", "Removes the movement lock during Dancer's M1.", val: false)) { MethodInfo? method = x.GetType("Dancer.SkillStates.M1.BaseM1").GetMethod("FixedUpdate", ESBM.FLAGS); object obj = <>c.<>9__2_13; if (obj == null) { Manipulator val = delegate(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) ILCursor val6 = new ILCursor(il); val6.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "Slash.playbackRate") }); MethodReference val11 = default(MethodReference); MethodReference val10 = default(MethodReference); FieldReference val9 = default(FieldReference); val6.TryGotoPrev((MoveType)0, new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchNop(x), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val11), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val10), (Instruction x) => ILPatternMatchingExt.MatchStfld(x, ref val9) }); for (int i = 0; i < 5; i++) { val6.Next.Operand = null; val6.Next.OpCode = OpCodes.Nop; int index = val6.Index; val6.Index = index + 1; } ILLabel val8 = default(ILLabel); FieldReference val7 = default(FieldReference); val6.TryGotoNext((MoveType)0, new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val8), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, ref val7), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCeq(x) }); val6.Index += 3; val6.Emit(OpCodes.Pop); val6.Emit(OpCodes.Ldc_I4, 1); }; <>c.<>9__2_13 = val; obj = (object)val; } ILHook val2 = new ILHook((MethodBase)method, (Manipulator)obj); MethodInfo? method2 = x.GetType("Dancer.SkillStates.M1.BaseM1").GetMethod("StartAttack", ESBM.FLAGS); object obj2 = <>c.<>9__2_14; if (obj2 == null) { Manipulator val3 = delegate(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val5 = new ILCursor(il); val5.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.2f) }); val5.Next.Operand = 1f; }; <>c.<>9__2_14 = val3; obj2 = (object)val3; } ILHook val4 = new ILHook((MethodBase)method2, (Manipulator)obj2); } }); ESBM.ApplyIfExists("Starstorm2", delegate(Assembly x) { if (ESBM.Bind("Mod Changes :: Starstorm 2", "Enable Select Beta Content", "Enables the following without requiring the beta config: Blast Knuckles, Sticky Overloader, Knight, Archerbug", val: false)) { new MethodPatch(x, "SS2.Items.BlastKnuckles", "IsAvailable", new ValueData { bVal = true }, Operation.Return); new MethodPatch(x, "SS2.Items.StickyOverloader", "IsAvailable", new ValueData { bVal = true }, Operation.Return); new MethodPatch(x, "SS2.Monsters.AcidBug", "IsAvailable", new ValueData { bVal = true }, Operation.Return); new MethodPatch(x, "SS2.Interactables.Pedestal", "IsAvailable", new ValueData { bVal = true }, Operation.Return); new MethodPatch(x, "SS2.Survivors.Knight", "IsAvailable", new ValueData { bVal = true }, Operation.Return); } }); } } public static class NoDiabloDamage { [CompilerGenerated] private static class <>O { public static hook_ModifyProjectile <0>__ModifyProjectile; public static hook_TakeDamage <1>__TakeDamage; } public static ModdedDamageType DiabloType = DamageAPI.ReserveDamageType(); public static void Initialize() { //IL_002b: 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) //IL_0036: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown if (ESBM.Bind("Vanilla Changes :: Diablo Strike", "Ally Protection", "Prevents Diablo damage against allies (knockback still applies)", val: false)) { object obj = <>O.<0>__ModifyProjectile; if (obj == null) { hook_ModifyProjectile val = ModifyProjectile; <>O.<0>__ModifyProjectile = val; obj = (object)val; } CallAirstrikeAlt.ModifyProjectile += (hook_ModifyProjectile)obj; object obj2 = <>O.<1>__TakeDamage; if (obj2 == null) { hook_TakeDamage val2 = TakeDamage; <>O.<1>__TakeDamage = val2; obj2 = (object)val2; } HealthComponent.TakeDamage += (hook_TakeDamage)obj2; } } private static void TakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) if (DamageAPI.HasModdedDamageType(ref damageInfo.damageType, DiabloType) && (int)self.body.teamComponent.teamIndex == 1 && (Object)(object)damageInfo.attacker != (Object)(object)((Component)self).gameObject) { damageInfo.damage = 1f; damageInfo.damageType |= DamageTypeCombo.op_Implicit((DamageType)2048); damageInfo.force *= 0.35f; } orig.Invoke(self, damageInfo); } private static void ModifyProjectile(orig_ModifyProjectile orig, CallAirstrikeAlt self, ref FireProjectileInfo fireProjectileInfo) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, ref fireProjectileInfo); DamageTypeCombo value = default(DamageTypeCombo); ((DamageTypeCombo)(ref value))..ctor(DamageTypeCombo.op_Implicit((DamageType)32), (DamageTypeExtended)0, (DamageSource)4); DamageAPI.AddModdedDamageType(ref value, DiabloType); fireProjectileInfo.damageTypeOverride = value; } } public class PlayerRespawns { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Action<TeleporterInteraction> <>9__6_0; public static hook_OnEnter <>9__6_1; public static hook_OnEnter <>9__6_2; public static hook_OnEnter <>9__6_3; public static Func<PlayerCharacterMasterController, bool> <>9__7_0; internal void <Initialize>b__6_0(TeleporterInteraction x) { AttemptRespawnDeadPlayers(); } internal void <Initialize>b__6_1(orig_OnEnter x, MissionCompleted y) { x.Invoke(y); AttemptRespawnDeadPlayers(); } internal void <Initialize>b__6_2(orig_OnEnter x, Phase1 y) { x.Invoke(y); AttemptRespawnDeadPlayers(); } internal void <Initialize>b__6_3(orig_OnEnter x, Phase1 y) { x.Invoke(y); AttemptRespawnDeadPlayers(); } internal bool <AttemptRespawnDeadPlayers>b__7_0(PlayerCharacterMasterController x) { return Object.op_Implicit((Object)(object)x.body); } } public static bool BeforeMithrixEnabled => ESBM.Bind("Player Respawns", "Before Final Bosses", "Should all dead players respawn at the start of a final boss?", val: false); public static bool AfterVieldsEnabled => ESBM.Bind("Player Respawns", "After Void Cells", "Should all dead players respawn upon completion of the Void Fields?", val: false); public static bool AfterTeleporterEnabled => ESBM.Bind("Player Respawns", "After Teleporter", "Should all dead players respawn after the teleporter event is over?", val: false); public static void Initialize() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown if (AfterTeleporterEnabled) { TeleporterInteraction.onTeleporterChargedGlobal += delegate { AttemptRespawnDeadPlayers(); }; } if (AfterVieldsEnabled) { object obj = <>c.<>9__6_1; if (obj == null) { hook_OnEnter val = delegate(orig_OnEnter x, MissionCompleted y) { x.Invoke(y); AttemptRespawnDeadPlayers(); }; <>c.<>9__6_1 = val; obj = (object)val; } MissionCompleted.OnEnter += (hook_OnEnter)obj; } if (!BeforeMithrixEnabled) { return; } object obj2 = <>c.<>9__6_2; if (obj2 == null) { hook_OnEnter val2 = delegate(orig_OnEnter x, Phase1 y) { x.Invoke(y); AttemptRespawnDeadPlayers(); }; <>c.<>9__6_2 = val2; obj2 = (object)val2; } Phase1.OnEnter += (hook_OnEnter)obj2; object obj3 = <>c.<>9__6_3; if (obj3 == null) { hook_OnEnter val3 = delegate(orig_OnEnter x, Phase1 y) { x.Invoke(y); AttemptRespawnDeadPlayers(); }; <>c.<>9__6_3 = val3; obj3 = (object)val3; } Phase1.OnEnter += (hook_OnEnter)obj3; } public static void AttemptRespawnDeadPlayers() { //IL_00d9: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { return; } PlayerCharacterMasterController[] array = PlayerCharacterMasterController.instances.Where((PlayerCharacterMasterController x) => Object.op_Implicit((Object)(object)x.body)).ToArray(); foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { if (Object.op_Implicit((Object)(object)instance.master) && (!Object.op_Implicit((Object)(object)instance.body) || !instance.body.healthComponent.alive) && (!Object.op_Implicit((Object)(object)instance.master.bodyInstanceObject) || !instance.master.bodyInstanceObject.GetComponent<CharacterBody>().healthComponent.alive)) { instance.master.deathFootPosition = array[Random.Range(0, array.Length)].body.footPosition; instance.master.RespawnExtraLifeShrine(); } } } } public static class StunResistance { [CompilerGenerated] private static class <>O { public static hook_SetStun <0>__ResistStun; public static hook_SetFrozen <1>__ResistFreeze; public static hook_SetShock <2>__ResistShock; } public static BuffDef bdStunRes; public static float ResistPerStack; public static float LargeEnemyMultiplier; public static void Initialize() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown if (ESBM.Bind("Enemy CC Resistance", "Enabled", "Whether enemies should build up a tolerance to CC effects.", val: false)) { bdStunRes = ScriptableObject.CreateInstance<BuffDef>(); bdStunRes.isHidden = true; bdStunRes.canStack = true; bdStunRes.isDebuff = false; ContentAddition.AddBuffDef(bdStunRes); object obj = <>O.<0>__ResistStun; if (obj == null) { hook_SetStun val = ResistStun; <>O.<0>__ResistStun = val; obj = (object)val; } SetStateOnHurt.SetStun += (hook_SetStun)obj; object obj2 = <>O.<1>__ResistFreeze; if (obj2 == null) { hook_SetFrozen val2 = ResistFreeze; <>O.<1>__ResistFreeze = val2; obj2 = (object)val2; } SetStateOnHurt.SetFrozen += (hook_SetFrozen)obj2; object obj3 = <>O.<2>__ResistShock; if (obj3 == null) { hook_SetShock val3 = ResistShock; <>O.<2>__ResistShock = val3; obj3 = (object)val3; } SetStateOnHurt.SetShock += (hook_SetShock)obj3; ResistPerStack = ESBM.Bind("Enemy CC Resistance", "Resist Percentage", "How much to resist CC effects by for each CC re-application.", 0.2f); LargeEnemyMultiplier = ESBM.Bind("Enemy CC Resistance", "Large Enemy Multiplier", "The effectiveness multiplier against elites and bosses.", 1.5f); } } private static void ResistStun(orig_SetStun orig, SetStateOnHurt self, float duration) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) CharacterBody component = ((Component)self).GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component)) { int buffCount = component.GetBuffCount(bdStunRes); duration = ((!component.isElite && !component.isChampion) ? (duration * ((buffCount > 1) ? Mathf.Pow(1f - ResistPerStack, (float)(buffCount - 1)) : 1f)) : (duration * ((buffCount > 1) ? Mathf.Pow(1f - ResistPerStack * LargeEnemyMultiplier, (float)(buffCount - 1)) : 1f))); component.AddTimedBuff(bdStunRes, 8f); foreach (TimedBuff timedBuff in component.timedBuffs) { if (timedBuff.buffIndex == bdStunRes.buffIndex) { timedBuff.timer = 8f; } } } orig.Invoke(self, duration); } private static void ResistFreeze(orig_SetFrozen orig, SetStateOnHurt self, float duration) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) CharacterBody component = ((Component)self).GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component)) { int buffCount = component.GetBuffCount(bdStunRes); duration = ((!component.isElite && !component.isChampion) ? (duration * ((buffCount > 1) ? Mathf.Pow(1f - ResistPerStack, (float)(buffCount - 1)) : 1f)) : (duration * ((buffCount > 1) ? Mathf.Pow(1f - ResistPerStack * LargeEnemyMultiplier, (float)(buffCount - 1)) : 1f))); component.AddTimedBuff(bdStunRes, 8f); foreach (TimedBuff timedBuff in component.timedBuffs) { if (timedBuff.buffIndex == bdStunRes.buffIndex) { timedBuff.timer = timedBuff.totalDuration; } } } orig.Invoke(self, duration); } private static void ResistShock(orig_SetShock orig, SetStateOnHurt self, float duration) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) CharacterBody component = ((Component)self).GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component)) { int buffCount = component.GetBuffCount(bdStunRes); duration = ((!component.isElite && !component.isChampion) ? (duration * ((buffCount > 1) ? Mathf.Pow(1f - ResistPerStack, (float)(buffCount - 1)) : 1f)) : (duration * ((buffCount > 1) ? Mathf.Pow(1f - ResistPerStack * LargeEnemyMultiplier, (float)(buffCount - 1)) : 1f))); component.AddTimedBuff(bdStunRes, 8f); foreach (TimedBuff timedBuff in component.timedBuffs) { if (timedBuff.buffIndex == bdStunRes.buffIndex) { timedBuff.timer = timedBuff.totalDuration; } } } orig.Invoke(self, duration); } } } namespace ESBM.TweakHelpers { public enum InjectionTiming { Before, End } public class FieldPatch { public string typeName; public string fieldName; public ValueData mod; public string injection; public InjectionTiming timing; private FieldInfo info; private PropertyInfo pInfo; private Sprite sprite; public string path; private FieldInfo[] infos; private bool post = false; public FieldPatch(Assembly assembly, string type, string field, ValueData mod, string method = null, string childPath = null, InjectionTiming timing = InjectionTiming.Before, Sprite sprite = null) { typeName = type; fieldName = field; this.mod = mod; injection = method; this.timing = timing; this.sprite = sprite; path = childPath; Apply(assembly); } public void Apply(Assembly assembly) { //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) Type type = assembly.GetType(typeName); if (mod == null || (Object)(object)mod.spVal != (Object)null) { } info = type.GetField(fieldName, ESBM.FLAGS); if (info == null) { TryApplyProperty(type); return; } infos = ResolveFields(info); if (infos == null) { return; } if (timing == InjectionTiming.End) { post = true; } if (string.IsNullOrEmpty(injection) && infos[infos.Length - 1].IsStatic) { FieldInfo fieldInfo = infos[infos.Length - 1]; if (!(fieldInfo == null)) { mod.Apply(fieldInfo); } } else { new ILHook((MethodBase)type.GetMethod(injection, ESBM.FLAGS), new Manipulator(Hook)); } } public FieldInfo[] ResolveFields(FieldInfo info) { if (string.IsNullOrEmpty(path)) { return new FieldInfo[1] { info }; } string[] array = path.Split("/"); FieldInfo[] array2 = new FieldInfo[array.Length + 1]; array2[0] = info; for (int i = 0; i < array.Length; i++) { info = info.FieldType.GetField(array[i], ESBM.FLAGS); array2[i + 1] = info; } return array2; } public void TryApplyProperty(Type type) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) pInfo = type.GetProperty(fieldName, ESBM.FLAGS); new ILHook((MethodBase)pInfo.GetMethod, new Manipulator(PropertyHook)); } public void Hook(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (post) { while (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchRet(x) })) { int index = val.Index; val.Index = index - 1; EmitIL(val); val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchRet(x) }); } } else { EmitIL(val); } } public void EmitIL(ILCursor c) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) if (infos[infos.Length - 1].IsStatic) { mod.EmitValue(infos[infos.Length - 1], c); c.Emit(OpCodes.Stsfld, infos[infos.Length - 1]); return; } c.Emit(OpCodes.Ldarg_0); for (int i = 0; i < infos.Length; i++) { FieldInfo fieldInfo = infos[i]; if (i == infos.Length - 1) { mod.EmitValue(fieldInfo, c); c.Emit(OpCodes.Stfld, fieldInfo); } else if (fieldInfo.FieldType.IsValueType) { c.Emit(OpCodes.Ldflda, fieldInfo); } else { c.Emit(OpCodes.Ldfld, fieldInfo); } } } public void PropertyHook(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (mod.operation == null) { mod.EmitValue(pInfo, val); val.Emit(OpCodes.Ret); return; } while (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchRet(x) })) { int index = val.Index; val.Index = index - 1; mod.EmitValue(pInfo, val, op: true); val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchRet(x) }); } } } public enum Operation { Replace, Suppress, Return, Input } public class MethodPatch { public string typeName; public string methodName; public ValueData mod; public Operation operation; public int index; public string injection; private MethodInfo info; private MethodInfo target; private ParameterInfo param; private int paramCount; public MethodPatch(Assembly assembly, string type, string method, ValueData mod, Operation operation, string replace = null, int param = 0) { typeName = type; methodName = method; this.mod = mod; injection = replace; this.operation = operation; index = param; Apply(assembly); } public void Apply(Assembly assembly) { //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Expected O, but got Unknown //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Expected O, but got Unknown //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Expected O, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Expected O, but got Unknown //IL_022c: Unknown result type (might be due to invalid IL or missing references) Type type = assembly.GetType(typeName); try { info = type.GetMethod(methodName, ESBM.FLAGS); } catch { info = type.GetMethods(ESBM.FLAGS).FirstOrDefault((MethodInfo x) => x.GetParameters().Count() >= index); } paramCount = info.GetParameters().Length; if (injection != null) { target = type.GetMethod(injection, ESBM.FLAGS); if (operation == Operation.Suppress) { new ILHook((MethodBase)target, new Manipulator(SuppressI)); } else if (operation == Operation.Return) { new ILHook((MethodBase)target, new Manipulator(ReturnI)); } else if (operation == Operation.Input) { ParameterInfo[] parameters = info.GetParameters(); if (index - 1 < parameters.Length) { param = parameters[index - 1]; new ILHook((MethodBase)target, new Manipulator(InputI)); } } } else if (operation == Operation.Suppress) { new ILHook((MethodBase)info, new Manipulator(Suppress)); } else if (operation == Operation.Return) { new ILHook((MethodBase)info, new Manipulator(Return)); } else if (operation == Operation.Replace) { new ILHook((MethodBase)info, new Manipulator(Replace)); } else if (operation == Operation.Input) { ParameterInfo[] parameters2 = info.GetParameters(); if (index - 1 < parameters2.Length) { param = parameters2[index - 1]; new ILHook((MethodBase)info, new Manipulator(Input)); } } } public void Replace(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (mod.sVal != null) { while (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdstr(x, mod.filter.StringFilter) })) { val.Prev.Operand = mod.sVal; } } else if (mod.filter.FloatFilter != null) { while (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, float.Parse(mod.filter.FloatFilter)) })) { val.Prev.Operand = mod.fVal; } } else if (mod.filter.IntFilter != null) { while (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, (float)int.Parse(mod.filter.IntFilter)) })) { val.Prev.Operand = mod.iVal; } } } public void Suppress(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (info.ReturnType != typeof(void)) { val.EmitDelegate<Func<object>>((Func<object>)(() => GetDefaultValue(info.ReturnType))); } val.Emit(OpCodes.Ret); } public void Return(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); mod.EmitValue(info, val); val.Emit(OpCodes.Ret); } public void Input(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (mod.operation != null) { val.Emit(OpCodes.Ldarg, info.IsStatic ? (index - 1) : index); } mod.EmitValue(param.ParameterType, val, mod.operation != null); val.Emit(OpCodes.Starg, info.IsStatic ? (index - 1) : index); } public void SuppressI(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); while (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)info) })) { int num = val.Index; val.Index = num - 1; val.Remove(); for (int i = 0; i < paramCount; i++) { val.Emit(OpCodes.Pop); } if (!info.IsStatic) { val.Emit(OpCodes.Pop); } if (info.ReturnType != typeof(void)) { val.EmitDelegate<Func<object>>((Func<object>)(() => GetDefaultValue(info.ReturnType))); } } } public void ReturnI(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); while (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)info) })) { int num = val.Index; val.Index = num - 1; val.Remove(); for (int i = 0; i < paramCount; i++) { val.Emit(OpCodes.Pop); } if (!info.IsStatic) { val.Emit(OpCodes.Pop); } if (info.ReturnType != typeof(void)) { mod.EmitValue(info, val); } val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)info) }); } } public void InputI(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); while (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)info) })) { int num = val.Index; val.Index = num - 1; int num2 = val.Index; Instruction val2 = FindParameter(il, val.Next); val.Index = il.IndexOf(val2); if (mod.operation == null) { val.Emit(OpCodes.Pop); } mod.EmitValue(param, val, mod.operation != null); val.Index = num2; val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)info) }); } } private object GetDefaultValue(Type t) { if (t.IsValueType) { return Activator.CreateInstance(t); } return null; } private Instruction FindParameter(ILContext il, Instruction call) { List<Instruction> list = ((IEnumerable<Instruction>)il.Body.Instructions).ToList(); Stack<Instruction> stack = new Stack<Instruction>(); foreach (Instruction item in list) { int num = StackChange(item); if (num > 0) { for (int i = 0; i < num; i++) { stack.Push(item); } } if (num < 0) { for (int j = 0; j < Math.Abs(num); j++) { if (stack.Count > 0) { stack.Pop(); } } } if (item == call) { int num2 = paramCount + ((!info.IsStatic) ? 1 : 0); return stack.ElementAt(stack.Count - (num2 - (index - 1))); } } return null; } private int StackChange(Instruction i) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_009a: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Invalid comparison between Unknown and I4 //IL_0046: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) int num = 0; OpCode opCode = i.OpCode; StackBehaviour stackBehaviourPop = ((OpCode)(ref opCode)).StackBehaviourPop; StackBehaviour val = stackBehaviourPop; if ((int)val != 1) { if ((int)val != 2) { if ((int)val == 27 && (i.OpCode == OpCodes.Call || i.OpCode == OpCodes.Callvirt)) { object operand = i.Operand; IMethodSignature val2 = (IMethodSignature)((operand is IMethodSignature) ? operand : null); int num2 = val2.Parameters.Count; if (val2.HasThis) { num2++; } num += num2; } } else { num += 2; } } else { num++; } opCode = i.OpCode; StackBehaviour stackBehaviourPush = ((OpCode)(ref opCode)).StackBehaviourPush; StackBehaviour val3 = stackBehaviourPush; if ((int)val3 != 20) { if ((int)val3 != 21) { if ((int)val3 == 28 && (i.OpCode == OpCodes.Call || i.OpCode == OpCodes.Callvirt)) { object operand2 = i.Operand; IMethodSignature val4 = (IMethodSignature)((operand2 is IMethodSignature) ? operand2 : null); if (((MemberReference)val4.ReturnType).FullName != typeof(void).FullName) { num--; } } } else { num -= 2; } } else { num--; } return num; } } public static class SpriteHandler { public static Sprite ProcessSprite(string resource) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) Stream manifestResourceStream = typeof(SpriteHandler).Assembly.GetManifestResourceStream("ESBM.Resources." + resource); byte[] array = new byte[manifestResourceStream.Length]; manifestResourceStream.Read(array); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ImageConversion.LoadImage(val, array); ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; val.Apply(false, false); int width = ((Texture)val).width; int height = ((Texture)val).height; int num = Math.Max(width, height); int num2 = (num - width) / 2; int num3 = (num - height) / 2; Texture2D val2 = val; if (width != height) { val2 = new Texture2D(num, num, val.format, false); Color val3 = default(Color); ((Color)(ref val3))..ctor(0f, 0f, 0f, 0f); for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { val2.SetPixel(j, i, val3); } } for (int k = 0; k < height; k++) { for (int l = 0; l < width; l++) { val2.SetPixel(l + num2, k + num3, val.GetPixel(l, k)); } } val2.Apply(false, false); } return Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); } } public class ValueData { public string sVal; public int iVal; public float fVal; public bool bVal; public string eVal; public Sprite spVal; public string[] sVals; public int[] iVals; public float[] fVals; public bool[] bVals; public string operation; public Filter filter; public void Apply(FieldInfo info, object instance = null) { object obj = null; if (info.FieldType == typeof(string)) { obj = sVal; } else if (info.FieldType == typeof(int)) { obj = iVal; } else if (info.FieldType == typeof(byte)) { obj = (byte)iVal; } else if (info.FieldType == typeof(float)) { obj = fVal; } else if (info.FieldType == typeof(bool)) { obj = sVal; } else if (info.FieldType.IsEnum) { obj = Enum.Parse(info.FieldType, eVal); } else if (info.FieldType == typeof(string[])) { obj = sVals; } else if (info.FieldType == typeof(int[])) { obj = iVals; } else if (info.FieldType == typeof(byte[])) { obj = CastArray<byte>(iVals); } else if (info.FieldType == typeof(float[])) { obj = fVals; } else if (info.FieldType == typeof(bool[])) { obj = bVals; } else { if (!(info.FieldType == typeof(Sprite))) { return; } obj = spVal; } info.SetValue(instance, v(obj)); object v(object f) { object value = info.GetValue(instance); if (value != null) { return ResolveOperation(value, f); } return f; } } public void Apply(PropertyInfo info, object instance) { object obj = null; if (info.PropertyType == typeof(string)) { obj = sVal; } else if (info.PropertyType == typeof(int)) { obj = iVal; } else if (info.PropertyType == typeof(byte)) { obj = (byte)iVal; } else if (info.PropertyType == typeof(float)) { obj = fVal; } else if (info.PropertyType == typeof(bool)) { obj = sVal; } else if (info.PropertyType.IsEnum) { obj = Enum.Parse(info.PropertyType, eVal); } else if (info.PropertyType == typeof(string[])) { obj = sVals; } else if (info.PropertyType == typeof(int[])) { obj = iVals; } else if (info.PropertyType == typeof(byte[])) { obj = CastArray<byte>(iVals); } else if (info.PropertyType == typeof(float[])) { obj = fVals; } else if (info.PropertyType == typeof(bool[])) { obj = bVals; } else { if (!(info.PropertyType == typeof(Sprite))) { return; } obj = spVal; } info.SetValue(instance, v(obj)); object v(object f) { object value = info.GetValue(instance); if (value != null) { return ResolveOperation(value, f); } return f; } } public void EmitValue(PropertyInfo info, ILCursor c, bool op = false) { EmitValue(info.PropertyType, c, op); } public void EmitValue(FieldInfo info, ILCursor c, bool op = false) { EmitValue(info.FieldType, c, op); } public void EmitValue(MethodInfo info, ILCursor c, bool op = false) { EmitValue(info.ReturnType, c, op); } public void EmitValue(ParameterInfo info, ILCursor c, bool op = false) { EmitValue(info.ParameterType, c, op); } public void EmitValue(Type type, ILCursor c, bool ope = false) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_028a: Unknown result type (might be due to invalid IL or missing references) if (type == typeof(string)) { Emit(OpCodes.Ldstr, sVal); } else if (type == typeof(int) || type == typeof(byte)) { Emit(OpCodes.Ldc_I4, iVal); } else if (type == typeof(float)) { Emit(OpCodes.Ldc_R4, fVal); } else if (type == typeof(bool)) { Emit(OpCodes.Ldc_I4, bVal ? 1 : 0); } else if (type == typeof(int[])) { EmitArray(c, iVals); } else if (type == typeof(byte[])) { EmitArray(c, CastArray<byte>(iVals)); } else if (type == typeof(string[])) { EmitArray(c, sVals); } else if (type == typeof(float[])) { EmitArray(c, fVals); } else if (type == typeof(bool[])) { EmitArray(c, bVals); } else if (type == typeof(Sprite)) { c.EmitDelegate<Func<Sprite>>((Func<Sprite>)(() => spVal)); } else if (type.IsEnum) { Type underlyingType = Enum.GetUnderlyingType(type); c.Emit(GetOpCode(underlyingType), Convert.ChangeType(Enum.Parse(type, eVal), underlyingType)); } void Emit(OpCode op, object val) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (ope) { ToObject(c, type); } c.Emit(op, val); if (ope) { ToObject(c, type); c.EmitDelegate<Func<object, object, object>>((Func<object, object, object>)((object l, object r) => ResolveOperation(l, r))); FromObject(c, type); } } } public void FromObject(ILCursor c, Type t) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (t.IsValueType) { c.Emit(OpCodes.Unbox_Any, t); } else { c.Emit(OpCodes.Castclass, t); } } public void ToObject(ILCursor c, Type t) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (t.IsValueType) { c.Emit(OpCodes.Box, t); } else { c.Emit(OpCodes.Castclass, typeof(object)); } } public OpCode GetOpCode(Type type) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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) if (type == typeof(byte)) { return OpCodes.Ldc_I4; } if (type == typeof(int)) { return OpCodes.Ldc_I4; } if (type == typeof(short)) { return OpCodes.Ldc_I4; } if (type == typeof(long)) { return OpCodes.Ldc_I8; } if (type == typeof(ulong)) { return OpCodes.Ldc_I8; } if (type == typeof(float)) { return OpCodes.Ldc_R4; } if (type == typeof(double)) { return OpCodes.Ldc_R8; } return OpCodes.Ldc_I4; } public T[] CastArray<T>(Array array) { T[] array2 = new T[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = (T)array.GetValue(i); } return array2; } public void EmitArray<T>(ILCursor c, T[] array) { c.EmitDelegate<Func<T[]>>((Func<T[]>)(() => array)); } public object ResolveOperation(object left, object right) { if (operation == null) { return right; } bool flag = left is float || right is float; switch (operation.ToLower()) { case "add": if (left is string text && right is string text2) { return text + text2; } if (flag) { return Convert.ToSingle(left) + Convert.ToSingle(right); } return Convert.ToInt32(left) + Convert.ToInt32(right); case "sub": case "subtract": if (flag) { return Convert.ToSingle(left) - Convert.ToSingle(right); } return Convert.ToInt32(left) - Convert.ToInt32(right); case "mul": case "mult": case "multiply": if (flag) { return Convert.ToSingle(left) * Convert.ToSingle(right); } return Convert.ToInt32(left) * Convert.ToInt32(right); case "div": case "divide": if (flag) { return Convert.ToSingle(left) / Convert.ToSingle(right); } return Convert.ToInt32(left) / Convert.ToI