Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of MiscFixes v1.5.9
MiscFixes.dll
Decompiled 2 months 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.Huntress.Weapon; using EntityStates.LunarExploderMonster; using EntityStates.MinorConstruct; using EntityStates.Scrapper; using EntityStates.VoidCamp; using HG; using HG.GeneralSerializer; using HarmonyLib; using Microsoft.CodeAnalysis; using MiscFixes.ErrorPolice; using MiscFixes.Modules; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.ContentManagement; using RoR2.Items; using RoR2.Projectile; using RoR2.UI; using RoR2BepInExPack.GameAssetPaths.Version_1_39_0; using RoR2BepInExPack.GameAssetPathsBetter; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.EventSystems; using UnityEngine.Networking; using UnityEngine.Rendering; [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+7aba0972df0737c4ac59a3dd86d5649b47e1e3ea")] [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 { 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); } } [BepInPlugin("_score.MiscFixes", "MiscFixes", "1.5.9")] 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.9"; 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); FixAssets.Init(); harmonyPatcher = new Harmony("_score.MiscFixes"); TryHarmonyPatch<FixGameplay>(); TryHarmonyPatch<FixEventSystem>(); TryHarmonyPatch<FixNullRefs>(); TryHarmonyPatch<FixParticleScale>(); TryHarmonyPatch<FixTempOverlay>(); } private void TryHarmonyPatch<T>() { try { harmonyPatcher.CreateClassProcessor(typeof(T)).Patch(); } catch (Exception data) { Log.Error(data); } } } } 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; } public static void EmitNullConditional(this ILCursor c, ILLabel notNullBranch, ILLabel nullBranch) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) c.Emit(OpCodes.Dup); c.EmitOpImplicit(); c.Emit(OpCodes.Brtrue, (object)notNullBranch); c.Emit(OpCodes.Pop); c.Emit(OpCodes.Br, (object)nullBranch); } public static void EmitNullConditional(this ILCursor c, Instruction notNullBranch, Instruction nullBranch) { c.EmitNullConditional(c.Context.DefineLabel(notNullBranch), c.Context.DefineLabel(nullBranch)); } public static void EmitNullConditional(this ILCursor c, Instruction notNullBranch, ILLabel nullBranch) { c.EmitNullConditional(c.Context.DefineLabel(notNullBranch), nullBranch); } 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); } private static bool GetModMetaDataSafe(this Assembly assembly, out string guid, out string name) { guid = ""; name = ""; foreach (Type loadableType in assembly.GetLoadableTypes()) { BepInPlugin customAttribute = ((MemberInfo)loadableType).GetCustomAttribute<BepInPlugin>(); if (customAttribute != null) { guid = customAttribute.GUID; name = customAttribute.Name; return true; } } Log.Error("Unable to associate config assembly " + assembly.FullName); return false; } public static IEnumerable<Type> GetLoadableTypes(this Assembly assembly) { try { return assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { return ex.Types.Where((Type t) => t != null); } } [Obsolete] public static void WipeConfig(this ConfigFile cfg) { cfg.DeleteOrphanedEntries(); } public static void DeleteOrphanedEntries(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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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)2, 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_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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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 GameObject obj) where T : Component { return UnityObjectExtensions.EnsureComponent<T>(obj); } public static T GetOrAddComponent<T>(this Component obj) where T : Component { return UnityObjectExtensions.EnsureComponent<T>(obj); } public static void TryDestroyComponent<T>(this GameObject obj) where T : Component { T val = default(T); if (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 (obj.TryGetComponent<T>(ref val)) { Object.Destroy((Object)(object)val); } } public static void TryDestroyAllComponents<T>(this GameObject obj) where T : Component { T[] components = obj.GetComponents<T>(); for (int num = components.Length - 1; num >= 0; num--) { Object.Destroy((Object)(object)components[num]); } } public static void TryDestroyAllComponents<T>(this Component obj) where T : Component { 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.Info($"Set field {fieldInfo.Name} to value of {fieldInfo.GetValue(obj)}"); } catch (Exception data) { Log.Warning(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.Info($"Set property {propertyInfo.Name} to value of {propertyInfo.GetValue(obj)}"); } catch (Exception data2) { Log.Warning(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; } public static void PrintAllSerializedValues(this EntityStateConfiguration esc) { Log.Info("Printing: " + esc.targetType.assemblyQualifiedName); for (int i = 0; i < esc.serializedFieldsCollection.serializedFields.Length; i++) { ref SerializedField reference = ref esc.serializedFieldsCollection.serializedFields[i]; string fieldName = reference.fieldName; string arg = "Unknown"; string arg2 = "<Null>"; if (Object.op_Implicit(reference.fieldValue.objectValue)) { arg = "Object"; arg2 = reference.fieldValue.objectValue.name; } else if (reference.fieldValue.stringValue != null) { arg = "String"; arg2 = reference.fieldValue.stringValue; } Log.Info(string.Format("\tName: {0}\t|\t Field Type: {1}" + Environment.NewLine + "{2}", fieldName, arg, arg2)); } } } 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 (!Object.op_Implicit((Object)(object)modelObject) || !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); } } } } } namespace MiscFixes.ErrorPolice { [HarmonyPatch] internal class FixGameplay { [HarmonyPatch(typeof(HalcyoniteShrineInteractable), "Awake")] [HarmonyPostfix] public static void HalcyoniteShrineInteractable_Awake(HalcyoniteShrineInteractable __instance) { __instance.goldDrainValue = Math.Max(1, __instance.goldDrainValue); } [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) { int num = 0; foreach (TeamComponent teamMember in teamMembers) { if (Object.op_Implicit((Object)(object)((teamMember != null) ? teamMember.body : null)) && Object.op_Implicit((Object)(object)teamMember.body.master) && Object.op_Implicit((Object)(object)teamMember.body.healthComponent)) { num++; } } return num; } [HarmonyPatch(typeof(CharacterMaster), "OnInventoryChanged")] [HarmonyILManipulator] private static void CharacterMaster_OnInventoryChanged(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); Instruction afterSetLuckInstruction = null; float num = default(float); if (!val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterMaster>(x, "set_luck"), (Instruction x) => x.MatchAny(out afterSetLuckInstruction) })) { Log.PatchFail(il); return; } ILLabel val2 = val.DefineLabel(); val.Emit(OpCodes.Br, (object)val2); val.Goto(afterSetLuckInstruction, (MoveType)0, false); val.MarkLabel(val2); } [HarmonyPatch(typeof(MeridianEventTriggerInteraction), "Awake")] [HarmonyPrefix] public static void MeridianEventTriggerInteraction_Awake(MeridianEventTriggerInteraction __instance) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) EntityStateMachine val = EntityStateMachine.FindByCustomName(((Component)__instance).gameObject, ""); if (((val != null) ? ((SerializableEntityStateType)(ref val.initialStateType)).stateType : null) == typeof(TestState1)) { val.initialStateType = new SerializableEntityStateType(typeof(Uninitialized)); ((Behaviour)val).enabled = false; } else { Log.PatchFail("Meridian Test ESM"); } } } [HarmonyPatch] internal class FixEventSystem { [HarmonyPatch(typeof(SurvivorIconController), "GetLocalUser")] [HarmonyPrefix] public static bool SurvivorIconController_GetLocalUser(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(ref NetworkUser __result) { if (EventSystem.current is MPEventSystem) { return true; } LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); __result = ((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null); return false; } } [HarmonyPatch] internal class FixNullRefs { [HarmonyPatch(typeof(ProjectileManager), "InitializeProjectile")] [HarmonyILManipulator] public static void ProjectileManager_InitializeProjectile(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ILCursor val = new ILCursor(il); int characterBodyVarIndex = -1; if (!val.TryGotoNext(new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 1), (Instruction x) => ILPatternMatchingExt.MatchLdfld<FireProjectileInfo>(x, "target"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<GameObject>(x, "GetComponent"), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref characterBodyVarIndex) }) || !val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, characterBodyVarIndex) })) { Log.PatchFail(il); return; } val.EmitDelegate<Func<CharacterBody, CharacterBody>>((Func<CharacterBody, CharacterBody>)((CharacterBody cb) => (!Object.op_Implicit((Object)(object)cb) || !Object.op_Implicit((Object)(object)cb.mainHurtBox)) ? null : cb)); } [HarmonyPatch(typeof(ThrownObjectProjectileController), "CalculatePassengerFinalPosition")] [HarmonyPrefix] public static bool ThrownObjectProjectileController_CalculatePassengerFinalPosition(ThrownObjectProjectileController __instance) { return Object.op_Implicit((Object)(object)__instance.passenger); } [HarmonyPatch(typeof(CharacterModel), "HighlightEquipentDisplay")] [HarmonyILManipulator] public static void CharacterModel_HighlightEquipentDisplay(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int defLoc = 0; Instruction retInstr = null; ILLabel val2 = default(ILLabel); if (!val.TryGotoNext(new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchBeq(x, ref val2), (Instruction x) => x.MatchAny(out retInstr) })) { Log.PatchFail(il); return; } int num = default(int); if (!val.TryGotoNext(new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(EquipmentCatalog), "GetEquipmentDef"), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref defLoc) })) { Log.PatchFail(il); return; } val.Emit(OpCodes.Ldloc, defLoc); val.EmitOpImplicit(); val.Emit(OpCodes.Brfalse, retInstr); } [HarmonyPatch(typeof(AttackSpeedPerNearbyCollider), "ReconcileBuffCount")] [HarmonyILManipulator] public static void AttackSpeedPerNearbyCollider_ReconcileBuffCount(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); Instruction retInstr = null; MethodReference val3 = default(MethodReference); ILLabel val2 = default(ILLabel); if (!val.TryGotoNext(new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val3), (Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val2), (Instruction x) => x.MatchAny(out retInstr) })) { Log.PatchFail(il); return; } val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldfld, AccessTools.Field(typeof(AttackSpeedPerNearbyCollider), "body")); val.EmitOpImplicit(); val.Emit(OpCodes.Brfalse, retInstr); } [HarmonyPatch(typeof(BuffWard), "BuffTeam")] [HarmonyILManipulator] public static void BuffWard_BuffTeam(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0094: 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) ILCursor val = new ILCursor(il); ILLabel continueLabel = null; int targetLoc = 0; int num = default(int); MethodReference val2 = default(MethodReference); if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchBr(x, ref continueLabel), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, ref val2), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref targetLoc) })) { Log.PatchFail(il); return; } val.Emit(OpCodes.Ldloc, targetLoc); val.EmitOpImplicit(); val.Emit(OpCodes.Brfalse, (object)continueLabel); } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyFinalizer] public static Exception PseudoCharacterMotor_setVelocityAuthority(Exception __exception) { if (__exception is NotImplementedException data) { Log.Error(data); return null; } return __exception; } [HarmonyPatch(typeof(FlickerLight), "OnEnable")] [HarmonyPrefix] public static void Ugh(FlickerLight __instance) { if (!Object.op_Implicit((Object)(object)__instance.light)) { Log.Error(Util.BuildPrefabTransformPath(((Component)__instance).transform.root, ((Component)__instance).transform, false, true) + " does not have a light! Fix this in the prefab!"); ((Behaviour)__instance).enabled = false; } } [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(CharacterDeathBehavior), "OnDeath")] [HarmonyILManipulator] public static void CharacterDeathBehavior_OnDeath(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ILCursor val = new ILCursor(il); Instruction nullBranch = null; MethodReference val2 = default(MethodReference); if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchNewobj(x, ref val2), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<EntityStateMachine>(x, "SetNextState"), (Instruction x) => x.MatchAny(out nullBranch) })) { Log.PatchFail(il); } else { val.EmitNullConditional(val.Next, nullBranch); } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyILManipulator] public static void ModelSkinController_ApplySkinAsync(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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) ILCursor val = new ILCursor(il); int loc = 0; if (!val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref loc), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<ModelSkinController>(x, "UnloadCurrentlyLoadedSkinAssets") })) { Log.PatchFail(il); return; } ILLabel val2 = il.DefineLabel(val.Next); val.Emit(OpCodes.Ldloc, loc); val.EmitDelegate<Func<ModelSkinController, bool>>((Func<ModelSkinController, bool>)((ModelSkinController mdlSkins) => mdlSkins.skins.Length != 0)); val.Emit(OpCodes.Brtrue, (object)val2); val.Emit(OpCodes.Ldc_I4_0); val.Emit(OpCodes.Ret); } [HarmonyPatch(typeof(CharacterBody), "OnSkillActivated")] [HarmonyILManipulator] public static void CharacterBody_OnSkillActivated(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ILCursor val = new ILCursor(il); ILLabel nullBranch = null; if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(CharacterBody), "inventory")) }) && val.Clone().TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchBle(x, ref nullBranch) })) { val.EmitNullConditional(val.Next, nullBranch); } else { Log.PatchFail(il); } } [HarmonyPatch(typeof(JumpDamageStrikeBodyBehavior), "UpdateDisplayInstances")] [HarmonyILManipulator] public static void JumpDamageStrikeBodyBehavior_UpdateDisplayInstances(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ILCursor val = new ILCursor(il); Instruction nullBranch = null; if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 1), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<GameObject>(x, "SetActive"), (Instruction x) => x.MatchAny(out nullBranch) })) { Log.PatchFail(il); } else { val.EmitNullConditional(val.Next, nullBranch); } } [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 ILCursor val = new ILCursor(il); Instruction nullBranch = null; int num = default(int); while (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertySetter(typeof(Behaviour), "enabled")), (Instruction x) => x.MatchAny(out nullBranch) })) { val.EmitNullConditional(val.Next, nullBranch); val.Goto(nullBranch, (MoveType)2, false); } } [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] internal class FixParticleScale { [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(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] internal class FixTempOverlay { [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(); } } } internal static class FixAssets { internal static void Init() { ((ResourceAvailability)(ref BodyCatalog.availability)).CallWhenAvailable((Action)FixBodies); MoreHudChildLocEntries(); FixHenry(); FixGlassMithrixMaterials(); FixVermin(); FixElderLemurianFootstepEvents(); } private static void FixBodies() { for (int i = 0; i < BodyCatalog.bodyPrefabBodyComponents.Length; i++) { CharacterBody val = BodyCatalog.bodyPrefabBodyComponents[i]; if (val.vehicleIdleStateMachine == null) { Log.Error(BodyCatalog.bodyNames[i] + " | Null vehicleIdleStateMachine array!"); val.vehicleIdleStateMachine = Array.Empty<EntityStateMachine>(); } for (int num = val.vehicleIdleStateMachine.Length - 1; num >= 0; num--) { if ((Object)(object)val.vehicleIdleStateMachine[num] == (Object)null) { Log.Error(BodyCatalog.bodyNames[i] + " | Null vehicleIdleStateMachine at index " + num); ArrayUtils.ArrayRemoveAtAndResize<EntityStateMachine>(ref val.vehicleIdleStateMachine, num, 1); } } } } private static void FixHenry() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Commando.CommandoBody_prefab).WaitForCompletion(); Material defaultMaterial = Addressables.LoadAssetAsync<Material>((object)RoR2_Base_Commando.matCommandoDualies_mat).WaitForCompletion(); ModelLocator component = obj.GetComponent<ModelLocator>(); ChildLocator component2 = ((Component)component.modelTransform).GetComponent<ChildLocator>(); ((Component)component.modelTransform).GetComponent<CharacterModel>().baseRendererInfos = (RendererInfo[])(object)new RendererInfo[3] { new RendererInfo { renderer = (Renderer)(object)component2.FindChildComponent<MeshRenderer>("GunMeshL"), defaultMaterial = defaultMaterial, defaultShadowCastingMode = (ShadowCastingMode)1 }, new RendererInfo { renderer = (Renderer)(object)component2.FindChildComponent<MeshRenderer>("GunMeshR"), defaultMaterial = defaultMaterial, defaultShadowCastingMode = (ShadowCastingMode)1 }, new RendererInfo { renderer = (Renderer)(object)((Component)component.modelTransform.Find("CommandoMesh")).GetComponent<SkinnedMeshRenderer>(), defaultMaterial = defaultMaterial, defaultShadowCastingMode = (ShadowCastingMode)1 } }; } public static void MoreHudChildLocEntries() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: 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_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: 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_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0226: 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_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) HUD component = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_UI.HUDSimple_prefab).WaitForCompletion().GetComponent<HUD>(); ChildLocator component2 = ((Component)component).GetComponent<ChildLocator>(); Transform val = 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 = val }, new NameTransformPair { name = "UpperRightCluster", transform = val.Find("UpperRightCluster") }, new NameTransformPair { name = "BottomRightCluster", transform = val.Find("BottomRightCluster") }, new NameTransformPair { name = "UpperLeftCluster", transform = val.Find("UpperLeftCluster") }, new NameTransformPair { name = "BottomCenterCluster", transform = val.Find("BottomCenterCluster") }, new NameTransformPair { name = "LeftCluster", transform = val.Find("LeftCluster") }, new NameTransformPair { name = "RightCluster", transform = val.Find("RightCluster") }, new NameTransformPair { name = "NotificationArea", transform = component.mainContainer.transform.Find("NotificationArea") }, new NameTransformPair { name = "ScoreboardPanel", transform = val.Find("ScoreboardPanel") }, new NameTransformPair { name = "SkillDisplayRoot", transform = val.Find("BottomRightCluster/Scaler") }, new NameTransformPair { name = "BuffDisplayRoot", transform = val.Find("BottomLeftCluster/BarRoots/LevelDisplayCluster/BuffDisplayRoot") }, new NameTransformPair { name = "InventoryDisplayRoot", transform = val.Find("TopCenterCluster/ItemInventoryDisplayRoot") } })); component2.transformPairs = (from pair in list group pair by pair.name into @group select @group.First()).ToArray(); } private static void FixGlassMithrixMaterials() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //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_002a: 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) GameObject modelObject = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Junk_BrotherGlass.BrotherGlassBody_prefab).WaitForCompletion(); SkinDef originalSkinDef = Addressables.LoadAssetAsync<SkinDef>((object)RoR2_Base_Brother.skinBrotherBodyDefault_asset).WaitForCompletion(); SkinDefParams originalSkinDefParams = Addressables.LoadAssetAsync<SkinDefParams>((object)RoR2_Base_Brother.skinBrotherBodyDefault_params_asset).WaitForCompletion(); PersistentOverlay.Init(modelObject, originalSkinDef, originalSkinDefParams); } public static void FixSaleStarCollider() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC2_Items_LowerPricedChests.PickupSaleStar_prefab).WaitForCompletion(); object obj2; if (obj == null) { obj2 = null; } else { Transform obj3 = obj.transform.Find("SaleStar"); obj2 = ((obj3 != null) ? ((Component)obj3).GetComponent<MeshCollider>() : null); } MeshCollider val = (MeshCollider)obj2; if ((Object)(object)val == (Object)null || val.convex) { Log.PatchFail("collider of SaleStar"); } else { val.convex = true; } } public static void FixElderLemurianFootstepEvents() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) RuntimeAnimatorController anim = Addressables.LoadAssetAsync<RuntimeAnimatorController>((object)RoR2_Base_Lemurian.animLemurianBruiser_controller).WaitForCompletion(); if (!Object.op_Implicit((Object)(object)anim)) { Log.PatchFail("Elder lem footsteps"); return; } PatchClip(4, "LemurianBruiserArmature|RunRight", 1, "", "FootR"); PatchClip(12, "LemurianBruiserArmature|Death", 2, "MouthMuzzle", "MuzzleMouth"); void PatchClip(int clipIndex, string clipName, int eventIndex, string oldEventString, string newEventString) { if (anim.animationClips.Length > clipIndex && ((Object)anim.animationClips[clipIndex]).name == clipName) { AnimationClip val = anim.animationClips[clipIndex]; if (val.events.Length > eventIndex && val.events[eventIndex].stringParameter == oldEventString) { AnimationEvent[] events = val.events; events[eventIndex].stringParameter = newEventString; val.events = events; return; } } Log.PatchFail(((Object)anim).name + " - " + clipName); } } private static void FixVermin() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) GameObject val = Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC1_Vermin.VerminSpawn_prefab).WaitForCompletion(); EffectComponent val2 = default(EffectComponent); if (Object.op_Implicit((Object)(object)val) && val.TryGetComponent<EffectComponent>(ref val2) && !val2.positionAtReferencedTransform) { val2.positionAtReferencedTransform = true; } else { Log.PatchFail("Vermin spawn effect"); } } } } namespace MiscFixes.ErrorPolice.Harmony { [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); } } } [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(); } }