Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of MiscFixes v1.5.1
MiscFixes.dll
Decompiled 3 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using EntityStates.BrotherMonster; using EntityStates.ChildMonster; using EntityStates.FalseSon; using EntityStates.Halcyonite; using EntityStates.Huntress.Weapon; using EntityStates.LunarExploderMonster; using EntityStates.MinorConstruct; using EntityStates.Scrapper; using EntityStates.VoidCamp; using Facepunch.Steamworks; using HG; using HG.GeneralSerializer; using HarmonyLib; using Microsoft.CodeAnalysis; using MiscFixes.ErrorPolice; using MiscFixes.ErrorPolice.Harmony; using MiscFixes.Modules; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using Rewired; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.ContentManagement; using RoR2.Navigation; using RoR2.Orbs; using RoR2.Projectile; using RoR2.Stats; using RoR2.UI; using RoR2BepInExPack.GameAssetPathsBetter; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.EventSystems; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MiscFixes")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+08e6f505888d9807d184ee7da0722eda243fab6c")] [assembly: AssemblyProduct("MiscFixes")] [assembly: AssemblyTitle("MiscFixes")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MiscFixes { [BepInPlugin("_score.MiscFixes", "MiscFixes", "1.5.1")] public class MiscFixesPlugin : BaseUnityPlugin { public const string PluginGUID = "_score.MiscFixes"; public const string PluginAuthor = "score"; public const string PluginName = "MiscFixes"; public const string PluginVersion = "1.5.1"; private Harmony harmonyPatcher; internal static bool RooInstalled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); private void Awake() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown Log.Init(((BaseUnityPlugin)this).Logger); AssetFixes.Init(); harmonyPatcher = new Harmony("_score.MiscFixes"); harmonyPatcher.CreateClassProcessor(typeof(PermanentFixes)).Patch(); harmonyPatcher.CreateClassProcessor(typeof(ServerCommandsOnClient)).Patch(); harmonyPatcher.CreateClassProcessor(typeof(VanillaFixes)).Patch(); } } } namespace MiscFixes.Modules { public static class Extensions { [Flags] public enum ConfigFlags : byte { None = 0, RestartRequired = 1, ClientSided = 2, ServerSided = 4 } private static readonly StringBuilder _sb = new StringBuilder(); public static void EmitNetworkServerActive(this ILCursor cursor) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) cursor.Emit<NetworkServer>(OpCodes.Call, "get_active"); } public static void EmitOpImplicit(this ILCursor c) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) c.Emit<Object>(OpCodes.Call, "op_Implicit"); } public static bool MatchNetworkServerActive(this Instruction instr) { return ILPatternMatchingExt.MatchCallOrCallvirt<NetworkServer>(instr, "get_active"); } public static bool MatchOpImplicit(this Instruction instr) { return ILPatternMatchingExt.MatchCallOrCallvirt<Object>(instr, "op_Implicit"); } public static bool MatchAny(this Instruction instr, out Instruction instruction) { instruction = instr; return true; } private static string BuildDescription(string name, string description, string defaultValue, ConfigFlags flags) { if (string.IsNullOrEmpty(description)) { description = name; } _sb.Append(description + " (Default: " + defaultValue + ")"); if ((flags & ConfigFlags.RestartRequired) != 0) { _sb.Append(" (Restart Required)"); } if ((flags & ConfigFlags.ClientSided) != 0) { _sb.Append(" (Client-Sided)"); } if ((flags & ConfigFlags.ServerSided) != 0) { _sb.Append(" (Server-Sided)"); } return StringBuilderExtensions.Take(_sb).Replace("'", string.Empty); } public static void WipeConfig(this ConfigFile cfg) { if (typeof(ConfigFile).GetProperty("OrphanedEntries", (BindingFlags)(-1))?.GetValue(cfg) is Dictionary<ConfigDefinition, string> dictionary) { dictionary.Clear(); } cfg.Save(); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static ConfigEntry<T> BindOption<T>(this ConfigFile myConfig, string section, string name, string description, T defaultValue, ConfigFlags flags = ConfigFlags.None) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown description = BuildDescription(name, description, defaultValue?.ToString(), flags); ConfigEntry<T> val = myConfig.Bind<T>(section, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>())); try { if (MiscFixesPlugin.RooInstalled) { Assembly.GetCallingAssembly().GetModMetaDataSafe(out var guid, out var name2); val.TryRegisterOption<T>((flags & ConfigFlags.RestartRequired) != 0, guid, name2); } } catch (Exception data) { Log.Error(data); } return val; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static ConfigEntry<T> BindOption<T>(this ConfigFile myConfig, string section, string name, string description, T defaultValue, T[] acceptableValues, ConfigFlags flags = ConfigFlags.None) where T : IEquatable<T> { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown description = BuildDescription(name, description, defaultValue?.ToString(), flags); AcceptableValueBase val = null; if (acceptableValues != null && acceptableValues.Length != 0) { val = (AcceptableValueBase)(object)new AcceptableValueList<T>(Array.Empty<T>()); } ConfigEntry<T> val2 = myConfig.Bind<T>(section, name, defaultValue, new ConfigDescription(description, val, Array.Empty<object>())); try { if (MiscFixesPlugin.RooInstalled) { Assembly.GetCallingAssembly().GetModMetaDataSafe(out var guid, out var name2); val2.TryRegisterOption<T>((flags & ConfigFlags.RestartRequired) != 0, guid, name2); } } catch (Exception data) { Log.Error(data); } return val2; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static ConfigEntry<T> BindOptionSlider<T>(this ConfigFile myConfig, string section, string name, string description, T defaultValue, ConfigFlags flags = ConfigFlags.None) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown description = BuildDescription(name, description, defaultValue.ToString(), flags); ConfigEntry<T> val = myConfig.Bind<T>(section, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>())); try { if (MiscFixesPlugin.RooInstalled) { Assembly.GetCallingAssembly().GetModMetaDataSafe(out var guid, out var name2); val.TryRegisterOptionSlider<T>((flags & ConfigFlags.RestartRequired) != 0, guid, name2); } } catch (Exception data) { Log.Error(data); } return val; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static ConfigEntry<T> BindOptionSlider<T>(this ConfigFile myConfig, string section, string name, string description, T defaultValue, T min, T max, ConfigFlags flags = ConfigFlags.None) where T : IComparable { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown description = BuildDescription(name, description, defaultValue.ToString(), flags); ConfigEntry<T> val = myConfig.Bind<T>(section, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<T>(min, max), Array.Empty<object>())); try { if (MiscFixesPlugin.RooInstalled) { Assembly.GetCallingAssembly().GetModMetaDataSafe(out var guid, out var name2); val.TryRegisterOptionSlider<T>((flags & ConfigFlags.RestartRequired) != 0, guid, name2); } } catch (Exception data) { Log.Error(data); } return val; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static ConfigEntry<float> BindOptionSteppedSlider(this ConfigFile myConfig, string section, string name, string description, float defaultValue, float increment, float min = 0f, float max = 100f, ConfigFlags flags = ConfigFlags.None) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown description = BuildDescription(name, description, defaultValue.ToString(), flags); ConfigEntry<float> val = myConfig.Bind<float>(section, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), Array.Empty<object>())); try { if (MiscFixesPlugin.RooInstalled) { Assembly.GetCallingAssembly().GetModMetaDataSafe(out var guid, out var name2); val.TryRegisterOptionSteppedSlider(increment, min, max, (flags & ConfigFlags.RestartRequired) != 0, guid, name2); } } catch (Exception data) { Log.Error(data); } return val; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void TryRegisterOption<T>(this ConfigEntry<T> entry, bool restartRequired = false, string modGuid = null, string modName = null) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown if (modGuid == null && modName == null) { Assembly.GetCallingAssembly().GetModMetaDataSafe(out modGuid, out modName); } if (entry is ConfigEntry<string> val) { ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(val, new InputFieldConfig { lineType = (LineType)0, submitOn = (SubmitEnum)6, restartRequired = restartRequired }), modGuid, modName); return; } if (entry is ConfigEntry<bool> val2) { ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(val2, restartRequired), modGuid, modName); return; } if (entry is ConfigEntry<KeyboardShortcut> val3) { ModSettingsManager.AddOption((BaseOption)new KeyBindOption(val3, restartRequired), modGuid, modName); return; } if (typeof(T).IsEnum) { ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)entry, restartRequired), modGuid, modName); return; } Log.Error("Config entry " + ((ConfigEntryBase)entry).Definition.Key + " in section " + ((ConfigEntryBase)entry).Definition.Section + " with type " + typeof(T).Name + " could not be registered in Risk Of Options using TryRegisterOption."); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void TryRegisterOptionSlider<T>(this ConfigEntry<T> entry, bool restartRequired = false, string modGuid = null, string modName = null) { //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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown if (modGuid == null && modName == null) { Assembly.GetCallingAssembly().GetModMetaDataSafe(out modGuid, out modName); } if (entry is ConfigEntry<int> val) { IntSliderConfig val2 = new IntSliderConfig { formatString = "{0:0.00}", restartRequired = restartRequired }; if (((ConfigEntryBase)entry).Description.AcceptableValues is AcceptableValueRange<int> val3) { val2.min = val3.MinValue; val2.max = val3.MaxValue; } ModSettingsManager.AddOption((BaseOption)new IntSliderOption(val, val2), modGuid, modName); } else if (entry is ConfigEntry<float> val4) { SliderConfig val5 = new SliderConfig { FormatString = "{0:0.00}", restartRequired = restartRequired }; if (((ConfigEntryBase)entry).Description.AcceptableValues is AcceptableValueRange<float> val6) { val5.min = val6.MinValue; val5.max = val6.MaxValue; } ModSettingsManager.AddOption((BaseOption)new SliderOption(val4, val5), modGuid, modName); } else { Log.Error("Config entry " + ((ConfigEntryBase)entry).Definition.Key + " in section " + ((ConfigEntryBase)entry).Definition.Section + " with type " + typeof(T).Name + " could not be registered in Risk Of Options using TryRegisterOptionSlider."); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void TryRegisterOptionSteppedSlider(this ConfigEntry<float> entry, float increment, float min, float max, bool restartRequired = false, string modGuid = null, string modName = null) { //IL_001c: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown if (entry != null) { if (modGuid == null && modName == null) { Assembly.GetCallingAssembly().GetModMetaDataSafe(out modGuid, out modName); } ModSettingsManager.AddOption((BaseOption)new StepSliderOption(entry, new StepSliderConfig { increment = increment, min = min, max = max, FormatString = "{0:0.00}", restartRequired = restartRequired }), modGuid, modName); } else { Log.Error("Config entry " + ((ConfigEntryBase)entry).Definition.Key + " in section " + ((ConfigEntryBase)entry).Definition.Section + " with type " + typeof(float).Name + " could not be registered in Risk Of Options using TryRegisterOptionSteppedSlider."); } } public static T GetOrAddComponent<T>(this Component obj) where T : Component { T result = default(T); if (Object.op_Implicit((Object)(object)obj) && !obj.TryGetComponent<T>(ref result)) { return obj.gameObject.AddComponent<T>(); } return result; } public static T GetOrAddComponent<T>(this GameObject obj) where T : Component { T result = default(T); if (Object.op_Implicit((Object)(object)obj) && !obj.TryGetComponent<T>(ref result)) { return obj.AddComponent<T>(); } return result; } public static void TryDestroyComponent<T>(this GameObject obj) where T : Component { T val = default(T); if (Object.op_Implicit((Object)(object)obj) && obj.TryGetComponent<T>(ref val)) { Object.Destroy((Object)(object)val); } } public static void TryDestroyComponent<T>(this Component obj) where T : Component { T val = default(T); if (Object.op_Implicit((Object)(object)obj) && obj.TryGetComponent<T>(ref val)) { Object.Destroy((Object)(object)val); } } public static void TryDestroyAllComponents<T>(this GameObject obj) where T : Component { if (Object.op_Implicit((Object)(object)obj)) { T[] components = obj.GetComponents<T>(); for (int i = 0; i < components.Length; i++) { Object.Destroy((Object)(object)components[i]); } } } public static void TryDestroyAllComponents<T>(this Component obj) where T : Component { if (Object.op_Implicit((Object)(object)obj)) { T[] components = obj.GetComponents<T>(); for (int num = components.Length - 1; num >= 0; num--) { Object.Destroy((Object)(object)components[num]); } } } public static T CloneComponent<T>(this GameObject go, T src) where T : Component { return go.AddComponent<T>().CloneFrom<T>(src); } public static T CloneFrom<T>(this T obj, T other) where T : Object { Type type = ((object)obj).GetType(); if (type != ((object)other).GetType()) { throw new TypeAccessException($"Type mismatch of {((object)obj)?.GetType()} and {((object)other)?.GetType()}"); } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo[] fields = type.GetFields(bindingAttr); foreach (FieldInfo fieldInfo in fields) { if (!(fieldInfo.DeclaringType == typeof(Object)) && !(fieldInfo.DeclaringType == typeof(Component))) { try { fieldInfo.SetValue(obj, fieldInfo.GetValue(other)); Log.Debug($"Set field {fieldInfo.Name} to value of {fieldInfo.GetValue(obj)}"); } catch (Exception data) { Log.Debug(data); } } } PropertyInfo[] properties = type.GetProperties(bindingAttr); foreach (PropertyInfo propertyInfo in properties) { if (!(propertyInfo.DeclaringType == typeof(Object)) && !(propertyInfo.DeclaringType == typeof(Component)) && propertyInfo.CanWrite && !(propertyInfo.DeclaringType == typeof(Object))) { try { propertyInfo.SetValue(obj, propertyInfo.GetValue(other)); Log.Debug($"Set property {propertyInfo.Name} to value of {propertyInfo.GetValue(obj)}"); } catch (Exception data2) { Log.Debug(data2); } } } return obj; } public static GameObject ResolveObjectInNewRoot(this GameObject obj, Transform originalRoot, Transform newRoot) { if (!Object.op_Implicit((Object)(object)obj)) { return null; } string text = Util.BuildPrefabTransformPath(originalRoot, obj.transform, false, false); if (string.IsNullOrEmpty(text)) { return null; } Transform val = newRoot.Find(text); if (!Object.op_Implicit((Object)(object)val)) { return null; } return ((Component)val).gameObject; } public static T ResolveComponentInNewRoot<T>(this T component, Transform originalRoot, Transform newRoot) where T : Component { if (!Object.op_Implicit((Object)(object)component)) { return default(T); } GameObject val = ((Component)component).gameObject.ResolveObjectInNewRoot(originalRoot, newRoot); if (!Object.op_Implicit((Object)(object)val)) { return default(T); } Component component2 = val.GetComponent(((object)component).GetType()); return (T)(object)((component2 is T) ? component2 : null); } public static bool TryModifyFieldValue<T>(this EntityStateConfiguration entityStateConfiguration, string fieldName, T value) { ref SerializedField orCreateField = ref ((SerializedFieldCollection)(ref entityStateConfiguration.serializedFieldsCollection)).GetOrCreateField(fieldName); if (Object.op_Implicit(orCreateField.fieldValue.objectValue) && typeof(Object).IsAssignableFrom(typeof(T))) { ref Object objectValue = ref orCreateField.fieldValue.objectValue; object obj = value; objectValue = (Object)((obj is Object) ? obj : null); return true; } if (orCreateField.fieldValue.stringValue != null && StringSerializer.CanSerializeType(typeof(T))) { orCreateField.fieldValue.stringValue = StringSerializer.Serialize(typeof(T), (object)value); return true; } Log.Error("Failed to modify field " + fieldName); return false; } public static bool TryGetFieldValue<T>(this EntityStateConfiguration entityStateConfiguration, string fieldName, out T value) where T : Object { ref SerializedField orCreateField = ref ((SerializedFieldCollection)(ref entityStateConfiguration.serializedFieldsCollection)).GetOrCreateField(fieldName); if (Object.op_Implicit(orCreateField.fieldValue.objectValue) && typeof(Object).IsAssignableFrom(typeof(T))) { Object objectValue = orCreateField.fieldValue.objectValue; value = (T)(object)((objectValue is T) ? objectValue : null); return true; } if (!string.IsNullOrEmpty(orCreateField.fieldValue.stringValue)) { Log.Error("Failed to return " + fieldName + " as an Object, try getting the string value instead."); } else { Log.Error("Field is null " + fieldName); } value = default(T); return false; } public static bool TryGetFieldValueString<T>(this EntityStateConfiguration entityStateConfiguration, string fieldName, out T value) where T : IEquatable<T> { ref SerializedField orCreateField = ref ((SerializedFieldCollection)(ref entityStateConfiguration.serializedFieldsCollection)).GetOrCreateField(fieldName); if (orCreateField.fieldValue.stringValue != null && StringSerializer.CanSerializeType(typeof(T))) { value = (T)StringSerializer.Deserialize(typeof(T), orCreateField.fieldValue.stringValue); return true; } if (Object.op_Implicit(orCreateField.fieldValue.objectValue)) { Log.Error("Failed to return " + fieldName + " as a string, try getting the Object value instead."); } else { Log.Error("Field is null " + fieldName); } value = default(T); return false; } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } internal static void PatchFail(string method) { _logSource.LogWarning((object)("Failed to patch " + method)); } internal static void PatchFail(ILContext il) { PatchFail(((MemberReference)il.Method).Name); } } public class PersistentOverlay : MonoBehaviour { private CharacterModel _characterModel; private TemporaryOverlayInstance _temporaryOverlay; private AssetOrDirectReference<Material> _overlayReference; public static void Init(GameObject modelObject, SkinDef originalSkinDef, SkinDefParams originalSkinDefParams) { ModelLocator val = default(ModelLocator); if (!modelObject.TryGetComponent<ModelLocator>(ref val)) { Log.Error("modelLocator is null"); return; } Transform modelTransform = val.modelTransform; if (!Object.op_Implicit((Object)(object)modelTransform)) { Log.Error("modelTransform is null"); return; } if (!Object.op_Implicit((Object)(object)originalSkinDef?.rootObject)) { Log.Error("originalSkinDef?.rootObject is null"); return; } if (!Object.op_Implicit((Object)(object)originalSkinDefParams)) { Log.Error("originalSkinDefParams is null"); return; } Transform transform = originalSkinDef.rootObject.transform; SkinDef val2 = Object.Instantiate<SkinDef>(originalSkinDef); ((Object)val2).name = "skinBrotherGlassBodyDefault"; val2.rootObject = ((Component)modelTransform).gameObject; SkinDefParams val3 = Object.Instantiate<SkinDefParams>(originalSkinDefParams); ((Object)val3).name = ((Object)val2).name + "_params"; val2.skinDefParams = val3; val2.skinDefParamsAddress = new AssetReferenceT<SkinDefParams>(string.Empty); val2.optimizedSkinDefParams = val3; val2.optimizedSkinDefParamsAddress = new AssetReferenceT<SkinDefParams>(string.Empty); for (int num = val3.rendererInfos.Length - 1; num >= 0; num--) { ref RendererInfo reference = ref val3.rendererInfos[num]; reference.renderer = reference.renderer.ResolveComponentInNewRoot<Renderer>(transform, modelTransform); if (!Object.op_Implicit((Object)(object)reference.renderer)) { ArrayUtils.ArrayRemoveAtAndResize<RendererInfo>(ref val3.rendererInfos, num, 1); } else { string name = ((Object)reference.renderer).name; if (name == "BrotherHammerConcrete" || name == "BrotherBodyMesh") { reference.defaultMaterial = null; reference.defaultMaterialAddress = new AssetReferenceT<Material>(RoR2_Base_Brother.maBrotherGlassOverlay_mat); } } } for (int num2 = val3.gameObjectActivations.Length - 1; num2 >= 0; num2--) { ref GameObjectActivation reference2 = ref val3.gameObjectActivations[num2]; reference2.gameObject = reference2.gameObject.ResolveObjectInNewRoot(transform, modelTransform); if (!Object.op_Implicit((Object)(object)reference2.gameObject)) { ArrayUtils.ArrayRemoveAtAndResize<GameObjectActivation>(ref val3.gameObjectActivations, num2, 1); } } for (int num3 = val3.meshReplacements.Length - 1; num3 >= 0; num3--) { ref MeshReplacement reference3 = ref val3.meshReplacements[num3]; reference3.renderer = reference3.renderer.ResolveComponentInNewRoot<Renderer>(transform, modelTransform); if (!Object.op_Implicit((Object)(object)reference3.renderer)) { ArrayUtils.ArrayRemoveAtAndResize<MeshReplacement>(ref val3.meshReplacements, num3, 1); } } for (int num4 = val3.lightReplacements.Length - 1; num4 >= 0; num4--) { ref LightInfo reference4 = ref val3.lightReplacements[num4]; reference4.light = reference4.light.ResolveComponentInNewRoot<Light>(transform, modelTransform); if (!Object.op_Implicit((Object)(object)reference4.light)) { ArrayUtils.ArrayRemoveAtAndResize<LightInfo>(ref val3.lightReplacements, num4, 1); } } ModelSkinController val4 = UnityObjectExtensions.EnsureComponent<ModelSkinController>(((Component)modelTransform).gameObject); int num5 = Array.IndexOf(val4.skins, originalSkinDef); if (ArrayUtils.IsInBounds<SkinDef>(val4.skins, num5)) { val4.skins[num5] = val2; } else { ArrayUtils.ArrayAppend<SkinDef>(ref val4.skins, ref val2); } ((Component)modelTransform).gameObject.AddComponent<PersistentOverlay>(); } private void Awake() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) _characterModel = ((Component)this).GetComponent<CharacterModel>(); _overlayReference = new AssetOrDirectReference<Material> { unloadType = (AsyncReferenceHandleUnloadType)2, address = new AssetReferenceT<Material>(RoR2_Base_Brother.matBrotherGlassDistortion_mat) }; } private void OnEnable() { if (_overlayReference.IsLoaded()) { SetOverlayMaterial(_overlayReference.Result); } _overlayReference.onValidReferenceDiscovered += SetOverlayMaterial; } private void OnDisable() { if (_overlayReference != null) { _overlayReference.onValidReferenceDiscovered -= SetOverlayMaterial; } SetOverlayMaterial(null); } private void OnDestroy() { _overlayReference?.Reset(); _overlayReference = null; } public void SetOverlayMaterial(Material newMaterial) { bool flag = (Object)(object)newMaterial != (Object)null; bool flag2 = _temporaryOverlay != null; if (flag != flag2 || (Object)(object)_temporaryOverlay?.originalMaterial != (Object)(object)newMaterial) { TemporaryOverlayInstance temporaryOverlay = _temporaryOverlay; if (temporaryOverlay != null) { temporaryOverlay.CleanupEffect(); } _temporaryOverlay = null; if (flag) { _temporaryOverlay = TemporaryOverlayManager.AddOverlay(((Component)this).gameObject); _temporaryOverlay.duration = float.PositiveInfinity; _temporaryOverlay.originalMaterial = newMaterial; _temporaryOverlay.AddToCharacterModel(_characterModel); } } } } internal static class Utils { internal static AsyncOperationHandle<T> PreloadAsset<T>(AssetReferenceT<T> reference) where T : Object { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return AssetAsyncReferenceManager<T>.LoadAsset(reference, (AsyncReferenceHandleUnloadType)0); } internal static void UnloadAsset<T>(AssetReferenceT<T> reference) where T : Object { AssetAsyncReferenceManager<T>.UnloadAsset(reference); } internal static void GetModMetaDataSafe(this Assembly assembly, out string guid, out string name) { guid = ""; name = ""; Type[] types = assembly.GetTypes(); for (int i = 0; i < types.Length; i++) { BepInPlugin customAttribute = ((MemberInfo)types[i]).GetCustomAttribute<BepInPlugin>(); if (customAttribute != null) { guid = customAttribute.GUID; name = customAttribute.Name; } } } } } namespace MiscFixes.ErrorPolice { internal static class AssetFixes { internal static void Init() { FixElderLemurianFootstepEvents(); FixSaleStarCollider(); MoreHudChildLocEntries(); FixHenry(); FixVermin(); FixGlassMithrixMaterials(); } private static void FixVermin() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_001c: 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) AssetReferenceGameObject ref1 = new AssetReferenceGameObject(RoR2_DLC1_Vermin.VerminSpawn_prefab); AsyncOperationHandle<GameObject> val = Utils.PreloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)ref1); val.Completed += delegate(AsyncOperationHandle<GameObject> obj) { EffectComponent component = obj.Result.GetComponent<EffectComponent>(); if (Object.op_Implicit((Object)(object)component) && !component.positionAtReferencedTransform) { component.positionAtReferencedTransform = true; } else { Log.PatchFail("Vermin spawn effect"); } Utils.UnloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)ref1); }; } private static void FixHenry() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) AssetReferenceGameObject bodyRef = new AssetReferenceGameObject(RoR2_Base_Commando.CommandoBody_prefab); AssetReferenceT<Material> matRef = new AssetReferenceT<Material>(RoR2_Base_Commando.matCommandoDualies_mat); AsyncOperationHandle<GameObject> val = Utils.PreloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)bodyRef); val.Completed += delegate(AsyncOperationHandle<GameObject> bodyHandle) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_001f: Unknown result type (might be due to invalid IL or missing references) AsyncOperationHandle<Material> val2 = Utils.PreloadAsset<Material>(matRef); val2.Completed += delegate(AsyncOperationHandle<Material> matHandle) { //IL_003a: 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_0062: 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_006c: 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) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) ModelLocator component = bodyHandle.Result.GetComponent<ModelLocator>(); ChildLocator component2 = ((Component)component.modelTransform).GetComponent<ChildLocator>(); Material result = matHandle.Result; ((Component)component.modelTransform).GetComponent<CharacterModel>().baseRendererInfos = (RendererInfo[])(object)new RendererInfo[3] { new RendererInfo { renderer = (Renderer)(object)component2.FindChildComponent<MeshRenderer>("GunMeshL"), defaultMaterial = result, defaultShadowCastingMode = (ShadowCastingMode)1 }, new RendererInfo { renderer = (Renderer)(object)component2.FindChildComponent<MeshRenderer>("GunMeshR"), defaultMaterial = result, defaultShadowCastingMode = (ShadowCastingMode)1 }, new RendererInfo { renderer = (Renderer)(object)((Component)component.modelTransform.Find("CommandoMesh")).GetComponent<SkinnedMeshRenderer>(), defaultMaterial = result, defaultShadowCastingMode = (ShadowCastingMode)1 } }; Log.Debug("Commando baseRendererInfos done"); Utils.UnloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)bodyRef); Utils.UnloadAsset<Material>(matRef); }; }; } public static void FixElderLemurianFootstepEvents() { //IL_001c: 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) AssetReferenceT<RuntimeAnimatorController> animRef = new AssetReferenceT<RuntimeAnimatorController>(RoR2_Base_Lemurian.animLemurianBruiser_controller); AsyncOperationHandle<RuntimeAnimatorController> val = Utils.PreloadAsset<RuntimeAnimatorController>(animRef); val.Completed += delegate(AsyncOperationHandle<RuntimeAnimatorController> animHandle) { RuntimeAnimatorController anim = animHandle.Result; PatchClip(4, "LemurianBruiserArmature|RunRight", 1, "", "FootR"); PatchClip(12, "LemurianBruiserArmature|Death", 2, "MouthMuzzle", "MuzzleMouth"); Log.Debug("Elder lemurian footsteps done"); Utils.UnloadAsset<RuntimeAnimatorController>(animRef); void PatchClip(int clipIndex, string clipName, int eventIndex, string oldEventString, string newEventString) { if (anim.animationClips.Length > clipIndex && ((Object)anim.animationClips[clipIndex]).name == clipName) { AnimationClip val2 = anim.animationClips[clipIndex]; if (val2.events.Length > eventIndex && val2.events[eventIndex].stringParameter == oldEventString) { AnimationEvent[] events = val2.events; events[eventIndex].stringParameter = newEventString; val2.events = events; return; } } Log.PatchFail(((Object)anim).name + " - " + clipName); } }; } public static void FixSaleStarCollider() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_001c: 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) AssetReferenceGameObject objRef = new AssetReferenceGameObject(RoR2_DLC2_Items_LowerPricedChests.PickupSaleStar_prefab); AsyncOperationHandle<GameObject> val = Utils.PreloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)objRef); val.Completed += delegate(AsyncOperationHandle<GameObject> objHandle) { Transform obj = objHandle.Result.transform.Find("SaleStar"); MeshCollider val2 = ((obj != null) ? ((Component)obj).GetComponent<MeshCollider>() : null); if ((Object)(object)val2 == (Object)null || val2.convex) { Log.PatchFail("collider of SaleStar"); } else { val2.convex = true; Log.Debug("SaleStar Collider done"); } Utils.UnloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)objRef); }; } public static void MoreHudChildLocEntries() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_001c: 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) AssetReferenceGameObject objRef = new AssetReferenceGameObject(RoR2_Base_UI.HUDSimple_prefab); AsyncOperationHandle<GameObject> val = Utils.PreloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)objRef); val.Completed += delegate(AsyncOperationHandle<GameObject> objHandle) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) HUD component = objHandle.Result.GetComponent<HUD>(); ChildLocator component2 = ((Component)component).GetComponent<ChildLocator>(); Transform val2 = component.mainUIPanel.transform.Find("SpringCanvas"); List<NameTransformPair> list = component2.transformPairs.ToList(); list.AddRange(new <>z__ReadOnlyArray<NameTransformPair>((NameTransformPair[])(object)new NameTransformPair[12] { new NameTransformPair { name = "SpringCanvas", transform = val2 }, new NameTransformPair { name = "UpperRightCluster", transform = val2.Find("UpperRightCluster") }, new NameTransformPair { name = "BottomRightCluster", transform = val2.Find("BottomRightCluster") }, new NameTransformPair { name = "UpperLeftCluster", transform = val2.Find("UpperLeftCluster") }, new NameTransformPair { name = "BottomCenterCluster", transform = val2.Find("BottomCenterCluster") }, new NameTransformPair { name = "LeftCluster", transform = val2.Find("LeftCluster") }, new NameTransformPair { name = "RightCluster", transform = val2.Find("RightCluster") }, new NameTransformPair { name = "NotificationArea", transform = component.mainContainer.transform.Find("NotificationArea") }, new NameTransformPair { name = "ScoreboardPanel", transform = val2.Find("ScoreboardPanel") }, new NameTransformPair { name = "SkillDisplayRoot", transform = val2.Find("BottomRightCluster/Scaler") }, new NameTransformPair { name = "BuffDisplayRoot", transform = val2.Find("BottomLeftCluster/BarRoots/LevelDisplayCluster/BuffDisplayRoot") }, new NameTransformPair { name = "InventoryDisplayRoot", transform = val2.Find("TopCenterCluster/ItemInventoryDisplayRoot") } })); component2.transformPairs = (from pair in list group pair by pair.name into @group select @group.First()).ToArray(); Log.Debug("HUD Childlocator updated"); Utils.UnloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)objRef); }; } private static void FixGlassMithrixMaterials() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) AssetReferenceGameObject brotherGlassBodyRef = new AssetReferenceGameObject(RoR2_Junk_BrotherGlass.BrotherGlassBody_prefab); AssetReferenceT<SkinDef> originalSkinRef = new AssetReferenceT<SkinDef>(RoR2_Base_Brother.skinBrotherBodyDefault_asset); AssetReferenceT<SkinDefParams> originalSkinParamsRef = new AssetReferenceT<SkinDefParams>(RoR2_Base_Brother.skinBrotherBodyDefault_params_asset); AsyncOperationHandle<GameObject> val = Utils.PreloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)brotherGlassBodyRef); val.Completed += delegate(AsyncOperationHandle<GameObject> bodyHandle) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_001f: Unknown result type (might be due to invalid IL or missing references) AsyncOperationHandle<SkinDef> val2 = Utils.PreloadAsset<SkinDef>(originalSkinRef); val2.Completed += delegate(AsyncOperationHandle<SkinDef> skinHandle) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) AsyncOperationHandle<SkinDefParams> val3 = Utils.PreloadAsset<SkinDefParams>(originalSkinParamsRef); val3.Completed += delegate(AsyncOperationHandle<SkinDefParams> skinParamsHandle) { PersistentOverlay.Init(bodyHandle.Result, skinHandle.Result, skinParamsHandle.Result); Utils.UnloadAsset<SkinDefParams>(originalSkinParamsRef); Utils.UnloadAsset<SkinDef>(originalSkinRef); Utils.UnloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)brotherGlassBodyRef); }; }; }; } } } namespace MiscFixes.ErrorPolice.Harmony { [HarmonyPatch] public class PermanentFixes { [HarmonyPatch(typeof(NormalizeParticleScale), "OnEnable")] [HarmonyPrefix] public static bool NormalizeParticleScale_OnEnable(NormalizeParticleScale __instance) { return !Object.op_Implicit((Object)(object)__instance.particleSystem); } [HarmonyPatch(typeof(BurnEffectController), "AddFireParticles")] [HarmonyPostfix] public static void BurnEffectController_AddFireParticles(NormalizeParticleScale __instance, ref BurnEffectControllerHelper __result, Renderer modelRenderer) { //IL_0017: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_007e: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)__result) && Object.op_Implicit((Object)(object)modelRenderer)) { Vector3 localScale = ((Component)modelRenderer).transform.localScale; float num = Vector3Utils.ComponentMax(ref localScale); if (num > 1f && Object.op_Implicit((Object)(object)__result.normalizeParticleScale) && Object.op_Implicit((Object)(object)__result.burnParticleSystem)) { MainModule main = __result.burnParticleSystem.main; MinMaxCurve startSize = ((MainModule)(ref main)).startSize; ((MinMaxCurve)(ref startSize)).constantMin = ((MinMaxCurve)(ref startSize)).constantMin / num; ((MinMaxCurve)(ref startSize)).constantMax = ((MinMaxCurve)(ref startSize)).constantMax / num; ((MainModule)(ref main)).startSize = startSize; } } } [HarmonyPatch(typeof(SurvivorIconController), "GetLocalUser")] [HarmonyPrefix] public static bool SurvivorIconController_GetLocalUser(SurvivorIconController __instance, ref LocalUser __result) { if (EventSystem.current is MPEventSystem) { return true; } __result = LocalUserManager.GetFirstLocalUser(); return false; } [HarmonyPatch(typeof(RuleChoiceController), "FindNetworkUser")] [HarmonyPrefix] public static bool RuleChoiceController_FindNetworkUser(RuleChoiceController __instance, ref NetworkUser __result) { if (EventSystem.current is MPEventSystem) { return true; } LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); __result = ((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null); return false; } [HarmonyPatch(typeof(TemporaryOverlayInstance), "SetupMaterial")] [HarmonyPrefix] public static void TemporaryOverlayInstance_SetupMaterial(TemporaryOverlayInstance __instance) { if (!Object.op_Implicit((Object)(object)__instance.originalMaterial) && Object.op_Implicit((Object)(object)__instance.componentReference) && __instance.ValidateOverlay()) { __instance.componentReference.CopyDataFromPrefabToInstance(); } } [HarmonyPatch(typeof(HalcyoniteShrineInteractable), "Awake")] [HarmonyPostfix] public static void HalcyoniteShrineInteractable_Awake(HalcyoniteShrineInteractable __instance) { __instance.goldDrainValue = Math.Max(1, __instance.goldDrainValue); } [HarmonyPatch(typeof(BaseSteamworks), "RunUpdateCallbacks")] [HarmonyFinalizer] public static Exception FixFacepunch() { return null; } [HarmonyPatch(typeof(FlickerLight), "OnEnable")] [HarmonyPrefix] public static void Ugh(FlickerLight __instance) { if (!Object.op_Implicit((Object)(object)__instance.light)) { ((Behaviour)__instance).enabled = false; } } public static void FixThisFuckingBullshitGearbox(ILContext il) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) ILCursor[] array = null; if (new ILCursor(il).TryFindNext(ref array, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchCall(x, (MethodBase)AccessTools.PropertyGetter(typeof(EventSystem), "current")), (Instruction x) => ILPatternMatchingExt.MatchCall(x, (MethodBase)AccessTools.PropertySetter(typeof(EventSystem), "current")) })) { array[0].Remove(); array[1].Remove(); } else { Log.PatchFail(il); } } [HarmonyPatch(typeof(Idle), "FixedUpdate")] [HarmonyPatch(typeof(VoidCampObjectiveTracker), "GenerateString")] [HarmonyILManipulator] public static void FixVoidSeed(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(ReadOnlyCollection<TeamComponent>), "Count")) })) { val.Remove(); val.EmitDelegate<Func<ReadOnlyCollection<TeamComponent>, int>>((Func<ReadOnlyCollection<TeamComponent>, int>)GetValidTeamCount); } else { Log.PatchFail(il); } } private static int GetValidTeamCount(ReadOnlyCollection<TeamComponent> teamMembers) { return teamMembers.Count((TeamComponent t) => Object.op_Implicit((Object)(object)((t != null) ? t.body : null)) && Object.op_Implicit((Object)(object)t.body.master) && Object.op_Implicit((Object)(object)t.body.healthComponent)); } } [HarmonyPatch] public class ServerCommandsOnClient { [HarmonyPatch(typeof(EnterSkyLeap), "OnEnter")] [HarmonyILManipulator] public static void FixEnterSkyLeapOnEnter(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); Instruction nextInstr = null; if (!val.TryGotoNext(new Func<Instruction, bool>[6] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(EntityState), "characterBody")), (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Buffs), "ArmorBoost"), (Instruction x) => ILPatternMatchingExt.MatchLdsfld<EnterSkyLeap>(x, "baseDuration"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "AddTimedBuff"), (Instruction x) => x.MatchAny(out nextInstr) })) { Log.PatchFail(il); return; } val.EmitNetworkServerActive(); val.Emit(OpCodes.Brfalse_S, nextInstr); } [HarmonyPatch(typeof(ExitSkyLeap), "OnEnter")] [HarmonyILManipulator] public static void FixExitSkyLeapOnEnter(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); Instruction nextInstr = null; if (!val.TryGotoNext(new Func<Instruction, bool>[6] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(EntityState), "characterBody")), (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Buffs), "ArmorBoost"), (Instruction x) => ILPatternMatchingExt.MatchLdsfld<ExitSkyLeap>(x, "baseDuration"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "AddTimedBuff"), (Instruction x) => x.MatchAny(out nextInstr) })) { Log.PatchFail(il); return; } val.EmitNetworkServerActive(); val.Emit(OpCodes.Brfalse_S, nextInstr); } [HarmonyPatch(typeof(HoldSkyLeap), "OnEnter")] [HarmonyILManipulator] public static void FixHoldSkyLeapOnEnter(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); Instruction nextInstr = null; if (!val.TryGotoNext(new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(EntityState), "characterBody")), (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Buffs), "HiddenInvincibility"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "AddBuff"), (Instruction x) => x.MatchAny(out nextInstr) })) { Log.PatchFail(((MemberReference)il.Method).Name + " #1"); return; } val.EmitNetworkServerActive(); Instruction prev = val.Prev; val.Emit(OpCodes.Brfalse_S, nextInstr); if (!val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<HoldSkyLeap>(x, "hurtboxGroup"), (Instruction x) => x.MatchOpImplicit() })) { Log.PatchFail(((MemberReference)il.Method).Name + " #2"); return; } val.Remove(); val.Emit(OpCodes.Brfalse_S, prev); } [HarmonyPatch(typeof(HoldSkyLeap), "OnExit")] [HarmonyILManipulator] public static void FixHoldSkyLeapOnExit(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); Instruction nextInstr = null; if (!val.TryGotoNext(new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(EntityState), "characterBody")), (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Buffs), "HiddenInvincibility"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "RemoveBuff"), (Instruction x) => x.MatchAny(out nextInstr) })) { Log.PatchFail(((MemberReference)il.Method).Name + " #1"); return; } val.EmitNetworkServerActive(); Instruction prev = val.Prev; val.Emit(OpCodes.Brfalse_S, nextInstr); if (!val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<HoldSkyLeap>(x, "hurtboxGroup"), (Instruction x) => x.MatchOpImplicit() })) { Log.PatchFail(((MemberReference)il.Method).Name + " #2"); return; } val.Remove(); val.Emit(OpCodes.Brfalse_S, prev); } [HarmonyPatch(typeof(SpellChannelState), "OnEnter")] [HarmonyILManipulator] public static void FixSpellChannelStateOnEnter(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); Instruction nextInstr = null; if (!val.TryGotoNext(new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(EntityState), "characterBody")), (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Buffs), "Immune"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "AddBuff"), (Instruction x) => x.MatchAny(out nextInstr) })) { Log.PatchFail(((MemberReference)il.Method).Name + " #1"); return; } val.EmitNetworkServerActive(); Instruction prev = val.Prev; val.Emit(OpCodes.Brfalse_S, nextInstr); if (!val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<SpellChannelState>(x, "spellChannelChildTransform"), (Instruction x) => x.MatchOpImplicit() })) { Log.PatchFail(((MemberReference)il.Method).Name + " #2"); return; } val.Remove(); val.Emit(OpCodes.Brfalse_S, prev); } [HarmonyPatch(typeof(SpellChannelState), "OnExit")] [HarmonyILManipulator] public static void SpellChannelState_OnExit(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); Instruction nextInstr = null; if (!val.TryGotoNext(new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(EntityState), "characterBody")), (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Buffs), "Immune"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "RemoveBuff"), (Instruction x) => x.MatchAny(out nextInstr) })) { Log.PatchFail(il); return; } val.EmitNetworkServerActive(); val.Emit(OpCodes.Brfalse_S, nextInstr); } [HarmonyPatch(typeof(FireArrowSnipe), "FireBullet")] [HarmonyILManipulator] public static void FixFireArrowSnipeFireBullet(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0173: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); Instruction nextInstr = null; float num = default(float); if (!val.TryGotoNext(new Func<Instruction, bool>[10] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(EntityState), "healthComponent")), (Instruction x) => ILPatternMatchingExt.MatchLdarga(x, 1), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(Ray), "direction")), (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Vector3>(x, "op_Multiply"), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 1), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<HealthComponent>(x, "TakeDamageForce"), (Instruction x) => x.MatchAny(out nextInstr) })) { Log.PatchFail(il); return; } val.EmitNetworkServerActive(); val.Emit(OpCodes.Brfalse_S, nextInstr); } [HarmonyPatch(typeof(Hidden), "OnEnter")] [HarmonyILManipulator] public static void FixHiddenOnEnter(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel nextLabel = null; if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<Hidden>(x, "buffDef"), (Instruction x) => x.MatchOpImplicit(), (Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref nextLabel) })) { Log.PatchFail(il); return; } val.EmitNetworkServerActive(); val.Emit(OpCodes.Brfalse_S, (object)nextLabel); } [HarmonyPatch(typeof(Hidden), "OnExit")] [HarmonyILManipulator] public static void FixHiddenOnExit(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel nextLabel = null; if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<Hidden>(x, "buffDef"), (Instruction x) => x.MatchOpImplicit(), (Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref nextLabel) })) { Log.PatchFail(il); return; } val.EmitNetworkServerActive(); val.Emit(OpCodes.Brfalse_S, (object)nextLabel); } [HarmonyPatch(typeof(ScrapperBaseState), "OnEnter")] [HarmonyILManipulator] public static void FixScrapperBaseStateOnEnter(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); Instruction nextInstr = null; if (!val.TryGotoNext(new Func<Instruction, bool>[6] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<ScrapperBaseState>(x, "pickupPickerController"), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(ScrapperBaseState), "enableInteraction")), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<PickupPickerController>(x, "SetAvailable"), (Instruction x) => x.MatchAny(out nextInstr) })) { Log.PatchFail(il); return; } val.EmitNetworkServerActive(); val.Emit(OpCodes.Brfalse_S, nextInstr); } [HarmonyPatch(typeof(BuffPassengerWhileSeated), "OnDisable")] [HarmonyILManipulator] public static void FixBuffPassengerWhileSeatedOnDisable(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel nextLabel = null; if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<BuffPassengerWhileSeated>(x, "vehicleSeat"), (Instruction x) => x.MatchOpImplicit(), (Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref nextLabel) })) { Log.PatchFail(il); return; } val.EmitNetworkServerActive(); val.Emit(OpCodes.Brfalse_S, (object)nextLabel); } [HarmonyPatch(typeof(BuffPassengerWhileSeated), "OnEnable")] [HarmonyILManipulator] public static void FixBuffPassengerWhileSeatedOnEnable(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel nextLabel = null; if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<BuffPassengerWhileSeated>(x, "vehicleSeat"), (Instruction x) => x.MatchOpImplicit(), (Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref nextLabel) })) { Log.PatchFail(il); return; } val.EmitNetworkServerActive(); val.Emit(OpCodes.Brfalse_S, (object)nextLabel); } [HarmonyPatch(typeof(DelusionChestController), "ResetChestForDelusion")] [HarmonyILManipulator] public static void FixDelusionChestControllerResetChestForDelusion(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); Instruction nextInstr = null; int num = default(int); if (!val.TryGotoNext(new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<DelusionChestController>(x, "_pickupPickerController"), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<PickupPickerController>(x, "SetAvailable"), (Instruction x) => x.MatchAny(out nextInstr) })) { Log.PatchFail(il); return; } val.EmitNetworkServerActive(); val.Emit(OpCodes.Brfalse_S, nextInstr); } [HarmonyPatch(typeof(DelusionChestController), "Start")] [HarmonyILManipulator] public static void FixDelusionChestControllerStart(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); Instruction nextInstr = null; int num = default(int); if (!val.TryGotoNext(new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<DelusionChestController>(x, "_pickupPickerController"), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<PickupPickerController>(x, "SetAvailable"), (Instruction x) => x.MatchAny(out nextInstr) })) { Log.PatchFail(il); return; } val.EmitNetworkServerActive(); val.Emit(OpCodes.Brfalse_S, nextInstr); } [HarmonyPatch(typeof(DevotionInventoryController), "Awake")] [HarmonyILManipulator] public static void FixDevotionInventoryControllerAwake(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); Instruction nextInstr = null; int num = default(int); if (!val.TryGotoNext(new Func<Instruction, bool>[6] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<DevotionInventoryController>(x, "_devotionMinionInventory"), (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "LemurianHarness"), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "GiveItem"), (Instruction x) => x.MatchAny(out nextInstr) })) { Log.PatchFail(il); return; } val.EmitNetworkServerActive(); val.Emit(OpCodes.Brfalse_S, nextInstr); } [HarmonyPatch(typeof(MasterDropDroplet), "DropItems")] [HarmonyILManipulator] public static void FixMasterDropDropletDropItems(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); Instruction val2 = val.Instrs[val.Instrs.Count - 1]; val.EmitNetworkServerActive(); val.Emit(OpCodes.Brfalse_S, val2); } } [HarmonyPatch] public class VanillaFixes { [HarmonyPatch(typeof(TemporaryVisualEffect), "RebuildVisualComponents")] [HarmonyILManipulator] public static void TemporaryVisualEffect_RebuildVisualComponents(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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); Instruction instr = null; int num = default(int); while (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchLdelemRef(x), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(Behaviour), "enabled")), (Instruction x) => x.MatchAny(out instr) })) { ILLabel val2 = val.DefineLabel(); int index = val.Index; val.Index = index + 1; val.Emit(OpCodes.Dup); val.EmitOpImplicit(); val.Emit(OpCodes.Brfalse_S, instr); val.Emit(OpCodes.Pop); val.Emit(OpCodes.Br_S, (object)val2); val.MarkLabel(val2); } } [HarmonyPatch(typeof(AffixAurelioniteBehavior), "Update")] [HarmonyPrefix] public static bool AffixAurelioniteBehavior_Update(AffixAurelioniteBehavior __instance) { CharacterBody body = ((ItemBehavior)__instance).body; return Object.op_Implicit((Object)(object)((body != null) ? body.coreTransform : null)); } [HarmonyPatch(typeof(VineOrb), "OnArrival")] [HarmonyILManipulator] public static void VineOrb_OnArrival(ILContext il, ILLabel retLabel) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0008: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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) ILCursor val = new ILCursor(il); val.Emit(OpCodes.Ldarg_0); val.Emit<Orb>(OpCodes.Ldfld, "target"); val.EmitOpImplicit(); val.Emit(OpCodes.Brfalse_S, (object)retLabel); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<GlobalEventManager>(x, "ProcDeathMark") })) { ILLabel val2 = val.DefineLabel(); val.MarkLabel(val2); int dotLoc = 0; if (val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<DotController>(x, "GetDotDef"), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref dotLoc) })) { val.Emit(OpCodes.Ldloc, dotLoc); val.EmitOpImplicit(); val.Emit(OpCodes.Brfalse_S, (object)val2); } else { Log.PatchFail(((MemberReference)il.Method).Name + " #2"); } } else { Log.PatchFail(((MemberReference)il.Method).Name + " #1"); } } public static void ProjectileController_Start(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel label = null; int num = default(int); ILLabel val2 = default(ILLabel); if (val.TryGotoNext(new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertySetter(typeof(ProjectileController), "shouldPlaySounds")), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num), (Instruction x) => x.MatchOpImplicit(), (Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref label) }) && val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(ProjectileController), "isPrediction")), (Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref val2) })) { val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Call, (MethodBase)AccessTools.PropertyGetter(typeof(ProjectileController), "ghost")); val.EmitOpImplicit(); val.Emit(OpCodes.Brfalse, (object)label); } else { Log.PatchFail(il); } } [HarmonyPatch(typeof(StatManager), "ProcessGoldEvents")] [HarmonyILManipulator] public static void StatManager_ProcessGoldEvents(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); ILLabel val3 = default(ILLabel); if (val.TryGotoNext(new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<GoldEvent>(x, "characterMaster"), (Instruction x) => ILPatternMatchingExt.MatchDup(x), (Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val3) })) { val.GotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchDup(x) }); val.EmitOpImplicit(); } else { Log.PatchFail(((MemberReference)il.Method).Name + " 1"); } ILLabel val2 = default(ILLabel); if (val.TryGotoNext(new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Component>(x, "GetComponent"), (Instruction x) => ILPatternMatchingExt.MatchDup(x), (Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val2) })) { val.GotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchDup(x) }); val.EmitOpImplicit(); } else { Log.PatchFail(((MemberReference)il.Method).Name + " 2"); } } [HarmonyPatch(typeof(ElusiveAntlersPickup), "OnShardDestroyed")] [HarmonyILManipulator] private static void ElusiveAntlersPickup_OnShardDestroyed(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); ILLabel val2 = default(ILLabel); if (val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Component>(x, "GetComponent") }) && val.TryGotoPrev(new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<ElusiveAntlersPickup>(x, "ownerBody"), (Instruction x) => ILPatternMatchingExt.MatchDup(x), (Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val2) })) { val.Index += 2; val.EmitOpImplicit(); } else { Log.PatchFail(il); } } [HarmonyPatch(typeof(FogDamageController), "EvaluateTeam")] [HarmonyILManipulator] public static void FogDamageController_EvaluateTeam(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0093: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int locTC = 0; int locBody = 0; ILLabel label = null; ILCursor[] array = default(ILCursor[]); if (val.TryGotoNext(new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref locTC), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(TeamComponent), "body")), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref locBody) }) && val.TryFindPrev(ref array, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchBr(x, ref label) })) { val.Emit(OpCodes.Ldloc, locTC); val.EmitOpImplicit(); val.Emit(OpCodes.Brfalse, (object)label); val.GotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, locBody) }); val.Emit(OpCodes.Ldloc, locBody); val.EmitOpImplicit(); val.Emit(OpCodes.Brfalse, (object)label); } else { Log.PatchFail(il); } } [HarmonyPatch(typeof(DeathState), "FixedUpdate")] [HarmonyILManipulator] public static void DeathState_FixedUpdate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) ILCursor[] array = default(ILCursor[]); if (new ILCursor(il).TryFindNext(ref array, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<DeathState>(x, "FireExplosion"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<GameObject>(x, "SetActive") })) { ILCursor obj = array[0]; ILCursor val = array[1]; int index = obj.Index; obj.Index = index + 1; obj.MoveAfterLabels(); index = val.Index; val.Index = index + 1; obj.Emit(OpCodes.Br, (object)val.MarkLabel()); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Action<DeathState>>((Action<DeathState>)delegate(DeathState self) { if (Object.op_Implicit((Object)(object)((EntityState)self).modelLocator) && Object.op_Implicit((Object)(object)((EntityState)self).modelLocator.modelTransform)) { ((Component)((EntityState)self).modelLocator.modelTransform).gameObject.SetActive(false); } }); } else { Log.PatchFail(il); } } [HarmonyPatch(typeof(Idle), "OnEnter")] [HarmonyILManipulator] public static void RouletteChestController_Idle_OnEnter(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int num = default(int); if (val.TryGotoNext(new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(RouletteChestControllerBaseState), "rouletteChestController")), (Instruction x) => ILPatternMatchingExt.MatchLdfld<RouletteChestController>(x, "purchaseInteraction"), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertySetter(typeof(PurchaseInteraction), "Networkavailable")) })) { ILLabel val2 = val.DefineLabel(); val.Emit(OpCodes.Br, (object)val2); val.GotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertySetter(typeof(PurchaseInteraction), "Networkavailable")) }); val.MarkLabel(val2); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Action<RouletteChestControllerBaseState>>((Action<RouletteChestControllerBaseState>)delegate(RouletteChestControllerBaseState ctrl) { if (Object.op_Implicit((Object)(object)ctrl.rouletteChestController) && Object.op_Implicit((Object)(object)ctrl.rouletteChestController.purchaseInteraction)) { ctrl.rouletteChestController.purchaseInteraction.Networkavailable = true; } }); } else { Log.PatchFail(il); } } public static void Duplicating_DropDroplet(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (!val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(EffectManager), "SimpleMuzzleFlash") })) { Log.PatchFail(il); return; } val.Remove(); val.EmitDelegate<Action<GameObject, GameObject, string, bool>>((Action<GameObject, GameObject, string, bool>)delegate(GameObject effectPrefab, GameObject obj, string muzzleName, bool _) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) ModelLocator val2 = default(ModelLocator); if (Object.op_Implicit((Object)(object)obj) && obj.TryGetComponent<ModelLocator>(ref val2) && Object.op_Implicit((Object)(object)val2.modelTransform)) { ChildLocator component = ((Component)val2.modelTransform).GetComponent<ChildLocator>(); if (Object.op_Implicit((Object)(object)component)) { int num = component.FindChildIndex(muzzleName); Transform val3 = component.FindChild(num); if (Object.op_Implicit((Object)(object)val3)) { Object.Instantiate<GameObject>(effectPrefab, val3.position, Quaternion.identity, val3); } } } }); } [HarmonyPatch(typeof(DetachParticleOnDestroyAndEndEmission), "OnDisable")] [HarmonyILManipulator] public static void DetachParticleOnDestroyAndEndEmission_OnDisable(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel returnLabel = null; if (!val.TryGotoNext(new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<DetachParticleOnDestroyAndEndEmission>(x, "particleSystem"), (Instruction x) => x.MatchOpImplicit(), (Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref returnLabel) }) || !val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<ParticleSystem>(x, "Stop") })) { Log.PatchFail(il); return; } val.Emit(OpCodes.Ldarg_0); val.Emit<DetachParticleOnDestroyAndEndEmission>(OpCodes.Ldfld, "particleSystem"); val.Emit(OpCodes.Callvirt, (MethodBase)AccessTools.PropertyGetter(typeof(Component), "gameObject")); val.Emit(OpCodes.Callvirt, (MethodBase)AccessTools.PropertyGetter(typeof(GameObject), "activeInHierarchy")); val.Emit(OpCodes.Brfalse, (object)returnLabel); } [HarmonyPatch(typeof(CharacterModel), "Awake")] [HarmonyILManipulator] public static void CharacterModel_Awake(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<HurtBoxGroup>(x, "hurtBoxes") })) { Log.PatchFail(il); return; } val.EmitDelegate<Func<HurtBox[], HurtBox[]>>((Func<HurtBox[], HurtBox[]>)delegate(HurtBox[] hurtBoxes) { int num = hurtBoxes.Length - 1; while (0 <= num) { if (!Object.op_Implicit((Object)(object)hurtBoxes[num])) { ArrayUtils.ArrayRemoveAtAndResize<HurtBox>(ref hurtBoxes, num, 1); } num--; } return hurtBoxes; }); } [HarmonyPatch(typeof(CrosshairOverrideBehavior), "OnDestroy")] [HarmonyILManipulator] public static void CrosshairUtils_CrosshairOverrideBehavior_OnDestroy(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<CrosshairOverrideBehavior>(x, "requestList") })) { Log.PatchFail(il); return; } val.EmitDelegate<Func<List<OverrideRequest>, List<OverrideRequest>>>((Func<List<OverrideRequest>, List<OverrideRequest>>)((List<OverrideRequest> requestList) => requestList.ToList())); } [HarmonyPatch(typeof(RewiredIntegrationManager), "RefreshJoystickAssignment")] [HarmonyPrefix] public static bool RewiredIntegrationManager_RefreshJoystickAssignment() { if (ReInput.initialized) { return ReInput.controllers != null; } return false; } [HarmonyPatch(typeof(MeridianEventTriggerInteraction), "Awake")] [HarmonyPrefix] public static void MeridianEventTriggerInteraction_Awake(MeridianEventTriggerInteraction __instance) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) EntityStateMachine val = EntityStateMachine.FindByCustomName(((Component)__instance).gameObject, ""); if ((Object)(object)val != (Object)null && ((SerializableEntityStateType)(ref val.initialStateType)).stateType == typeof(TestState1)) { val.initialStateType = new SerializableEntityStateType(typeof(Uninitialized)); ((Behaviour)val).enabled = false; } else { Log.PatchFail("Meridian Test ESM"); } } [HarmonyPatch(typeof(Frolic), "TeleportAroundPlayer")] [HarmonyILManipulator] public static void Frolic_TeleportAroundPlayer(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int listVar = 0; int vectorVar = 0; int boolVar = 0; int num = default(int); if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[6] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<NodeGraph>(x, "FindNodesInRange"), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref listVar), (Instruction x) => ILPatternMatchingExt.MatchLdloca(x, ref vectorVar), (Instruction x) => ILPatternMatchingExt.MatchInitobj<Vector3>(x), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref boolVar) })) { Log.PatchFail(il); return; } val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Call, (MethodBase)AccessTools.PropertyGetter(typeof(EntityState), "characterBody")); val.Emit(OpCodes.Callvirt, (MethodBase)AccessTools.PropertyGetter(typeof(CharacterBody), "coreTransform")); val.Emit(OpCodes.Callvirt, (MethodBase)AccessTools.PropertyGetter(typeof(Transform), "position")); val.Emit(OpCodes.Stloc, vectorVar); val.Emit(OpCodes.Ldloc, listVar); val.Emit(OpCodes.Callvirt, (MethodBase)AccessTools.PropertyGetter(typeof(List<NodeIndex>), "Count")); val.Emit(OpCodes.Ldc_I4_1); val.Emit(OpCodes.Cgt); val.Emit(OpCodes.Ldc_I4_0); val.Emit(OpCodes.Ceq); val.Emit(OpCodes.Stloc, boolVar); } [HarmonyPatch(typeof(TeamManager), "LongstandingSolitudesInParty")] [HarmonyILManipulator] public static void TeamManager_LongstandingSolitudesInParty(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int pcmcVarIndex = 0; int bodyVarIndex = 0; if (!val.TryGotoNext(new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref pcmcVarIndex), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(PlayerCharacterMasterController), "master")), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterMaster>(x, "GetBody"), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref bodyVarIndex) })) { Log.PatchFail(((MemberReference)il.Method).Name + " #1"); return; } for (int i = 0; i < 2; i++) { if (!val.TryGotoNext(new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, bodyVarIndex), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(CharacterBody), "inventory")) })) { Log.PatchFail(((MemberReference)il.Method).Name + $" #{i + 2}"); break; } val.RemoveRange(2); val.Emit(OpCodes.Ldloc, pcmcVarIndex); val.Emit(OpCodes.Callvirt, (MethodBase)AccessTools.PropertyGetter(typeof(PlayerCharacterMasterController), "master")); val.Emit(OpCodes.Callvirt, (MethodBase)AccessTools.PropertyGetter(typeof(CharacterMaster), "inventory")); } } [HarmonyPatch(typeof(Util), "HealthComponentToTransform")] [HarmonyILManipulator] public static void Util_HealthComponentToTransform(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (!val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(CharacterBody), "coreTransform")) })) { Log.PatchFail(il); return; } val.Remove(); val.Emit(OpCodes.Callvirt, (MethodBase)AccessTools.PropertyGetter(typeof(CharacterBody), "mainHurtBox")); val.Emit(OpCodes.Callvirt, (MethodBase)AccessTools.PropertyGetter(typeof(Component), "transform")); } [HarmonyPatch(typeof(WhirlWindPersuitCycle), "UpdateDecelerate")] [HarmonyILManipulator] public static void WhirlWindPersuitCycle_UpdateDecelerate(ILContext il, ILLabel retLabel) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); Instruction next = val.Next; val.Emit(OpCodes.Ldarg_0); val.Emit<WhirlWindPersuitCycle>(OpCodes.Ldfld, "targetBody"); Extensions.EmitOpImplicit(val); val.Emit(OpCodes.Brtrue_S, next); val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldc_I4, 4); val.Emit<WhirlWindPersuitCycle>(OpCodes.Stfld, "state"); val.Emit(OpCodes.Br, (object)retLabel); } [HarmonyPatch(typeof(MeridiansWillFire), "InitializePullInfo")] [HarmonyILManipulator] public static void MeridiansWillFire_InitializePullInfo(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_008d: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel label = null; if (val.TryGotoNext(new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(CharacterBody), "rigidbody")), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(Rigidbody), "mass")), (Instruction x) => ILPatternMatchingExt.MatchBr(x, ref label) })) { int index = val.Index; val.Index = index + 1; Instruction next = val.Next; val.Emit(OpCodes.Dup); val.EmitOpImplicit(); val.Emit(OpCodes.Brtrue_S, next); val.Emit(OpCodes.Pop); val.Emit(OpCodes.Ldc_R4, 0f); val.Emit(OpCodes.Br, (object)label); } else { Log.PatchFail(il); } } } } [CompilerGenerated] internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { int ICollection.Count => _items.Length; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => _items.Length; T IReadOnlyList<T>.this[int index] => _items[index]; int ICollection<T>.Count => _items.Length; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyArray(T[] items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return ((IEnumerable<T>)_items).GetEnumerator(); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return ((ICollection<T>)_items).Contains(item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { ((ICollection<T>)_items).CopyTo(array, arrayIndex); } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { return ((IList<T>)_items).IndexOf(item); } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } }