Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of RendererInfoPatcher v1.0.1
RendererInfoPatcher.dll
Decompiled 9 hours agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using IL.RoR2; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using On.RoR2; using RoR2; using UnityEngine; using UnityEngine.AddressableAssets; [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("RendererInfoPatcher")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+0990452fd8be3d69a580a159fd4a085602157f1a")] [assembly: AssemblyProduct("RendererInfoPatcher")] [assembly: AssemblyTitle("RendererInfoPatcher")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace RendererInfoPatcher { internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(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); } } [BepInPlugin("Dnarok.RendererInfoPatcher", "RendererInfoPatcher", "1.0.1")] public class Plugin : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<Instruction, bool> <>9__4_5; public static Func<Instruction, bool> <>9__4_6; public static Func<Instruction, bool> <>9__4_7; public static Func<Instruction, bool> <>9__4_8; public static Func<Instruction, bool> <>9__4_9; public static Manipulator <>9__4_0; public static Func<Instruction, bool> <>9__4_10; public static Func<Instruction, bool> <>9__4_11; public static Manipulator <>9__4_1; public static Func<Instruction, bool> <>9__4_12; public static Func<Instruction, bool> <>9__4_13; public static Manipulator <>9__4_2; public static hook_Equals <>9__4_3; internal void <Awake>b__4_0(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) <>c__DisplayClass4_0 CS$<>8__locals0 = new <>c__DisplayClass4_0(); ILCursor val = new ILCursor(il); CS$<>8__locals0.location = 0; int num = default(int); if (!val.TryGotoNext(new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref CS$<>8__locals0.location), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(RendererInfo), "renderer"), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(RendererInfo), "defaultMaterial"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(Renderer), "set_material") })) { Log.Error("Couldn't patch ItemDisplay.RefreshRenderers."); } ILLabel val2 = val.DefineLabel(); val.Emit(OpCodes.Br, (object)val2); val.GotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(Renderer), "set_material") }); val.MarkLabel(val2); val.Emit(OpCodes.Ldloc, CS$<>8__locals0.location); val.EmitDelegate<Action<RendererInfo>>((Action<RendererInfo>)RefreshRenderersCorrection); } internal bool <Awake>b__4_5(Instruction x) { return ILPatternMatchingExt.MatchLdfld(x, typeof(RendererInfo), "renderer"); } internal bool <Awake>b__4_6(Instruction x) { int num = default(int); return ILPatternMatchingExt.MatchLdloc(x, ref num); } internal bool <Awake>b__4_7(Instruction x) { return ILPatternMatchingExt.MatchLdfld(x, typeof(RendererInfo), "defaultMaterial"); } internal bool <Awake>b__4_8(Instruction x) { return ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(Renderer), "set_material"); } internal bool <Awake>b__4_9(Instruction x) { return ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(Renderer), "set_material"); } internal void <Awake>b__4_1(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>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(RendererInfo), "defaultMaterial"), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0) })) { Log.Error("Couldn't patch CharacterModel.UpdateMaterials."); } val.Remove(); val.EmitDelegate<<>F{00000001}<RendererInfo, Material>>((<>F{00000001}<RendererInfo, Material>)UpdateMaterialsCorrection); } internal bool <Awake>b__4_10(Instruction x) { return ILPatternMatchingExt.MatchLdfld(x, typeof(RendererInfo), "defaultMaterial"); } internal bool <Awake>b__4_11(Instruction x) { return ILPatternMatchingExt.MatchLdarg(x, 0); } internal void <Awake>b__4_2(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>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(RendererInfo), "defaultMaterial"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(Object), "Instantiate") })) { Log.Error("Couldn't patch RandomizeSplatBias.Setup."); } val.Remove(); val.EmitDelegate<Func<RendererInfo, Material>>((Func<RendererInfo, Material>)SetupCorrection); } internal bool <Awake>b__4_12(Instruction x) { return ILPatternMatchingExt.MatchLdfld(x, typeof(RendererInfo), "defaultMaterial"); } internal bool <Awake>b__4_13(Instruction x) { return ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(Object), "Instantiate"); } internal bool <Awake>b__4_3(orig_Equals orig, ref RendererInfo self, RendererInfo other) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (object.Equals(self.defaultMaterialAddress, other.defaultMaterialAddress)) { return orig.Invoke(ref self, other); } return false; } } [CompilerGenerated] private sealed class <>c__DisplayClass4_0 { public int location; internal bool <Awake>b__4(Instruction x) { return ILPatternMatchingExt.MatchLdloc(x, ref location); } } public const string PluginGUID = "Dnarok.RendererInfoPatcher"; public const string PluginAuthor = "Dnarok"; public const string PluginName = "RendererInfoPatcher"; public const string PluginVersion = "1.0.1"; public void Awake() { //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_002a: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0067: 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_0072: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown Log.Init(((BaseUnityPlugin)this).Logger); object obj = <>c.<>9__4_0; if (obj == null) { Manipulator val = delegate(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) ILCursor val7 = new ILCursor(il); int location = 0; int num = default(int); if (!val7.TryGotoNext(new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref location), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(RendererInfo), "renderer"), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(RendererInfo), "defaultMaterial"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(Renderer), "set_material") })) { Log.Error("Couldn't patch ItemDisplay.RefreshRenderers."); } ILLabel val8 = val7.DefineLabel(); val7.Emit(OpCodes.Br, (object)val8); val7.GotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(Renderer), "set_material") }); val7.MarkLabel(val8); val7.Emit(OpCodes.Ldloc, location); val7.EmitDelegate<Action<RendererInfo>>((Action<RendererInfo>)RefreshRenderersCorrection); }; <>c.<>9__4_0 = val; obj = (object)val; } ItemDisplay.RefreshRenderers += (Manipulator)obj; object obj2 = <>c.<>9__4_1; if (obj2 == null) { Manipulator val2 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val6 = new ILCursor(il); if (!val6.TryGotoNext(new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(RendererInfo), "defaultMaterial"), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0) })) { Log.Error("Couldn't patch CharacterModel.UpdateMaterials."); } val6.Remove(); val6.EmitDelegate<<>F{00000001}<RendererInfo, Material>>((<>F{00000001}<RendererInfo, Material>)UpdateMaterialsCorrection); }; <>c.<>9__4_1 = val2; obj2 = (object)val2; } CharacterModel.UpdateMaterials += (Manipulator)obj2; object obj3 = <>c.<>9__4_2; if (obj3 == null) { Manipulator val3 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val5 = new ILCursor(il); if (!val5.TryGotoNext(new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(RendererInfo), "defaultMaterial"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(Object), "Instantiate") })) { Log.Error("Couldn't patch RandomizeSplatBias.Setup."); } val5.Remove(); val5.EmitDelegate<Func<RendererInfo, Material>>((Func<RendererInfo, Material>)SetupCorrection); }; <>c.<>9__4_2 = val3; obj3 = (object)val3; } RandomizeSplatBias.Setup += (Manipulator)obj3; object obj4 = <>c.<>9__4_3; if (obj4 == null) { hook_Equals val4 = delegate(orig_Equals orig, ref RendererInfo self, RendererInfo other) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) return object.Equals(self.defaultMaterialAddress, other.defaultMaterialAddress) && orig.Invoke(ref self, other); }; <>c.<>9__4_3 = val4; obj4 = (object)val4; } RendererInfo.Equals += (hook_Equals)obj4; } public static void RefreshRenderersCorrection(RendererInfo info) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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) if (info.defaultMaterialAddress != null && ((AssetReference)info.defaultMaterialAddress).RuntimeKeyIsValid()) { info.renderer.material = Addressables.LoadAssetAsync<Material>((object)info.defaultMaterialAddress).WaitForCompletion(); } else { info.renderer.material = info.defaultMaterial; } } public static Material UpdateMaterialsCorrection(ref RendererInfo info) { //IL_001b: 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) if (info.defaultMaterialAddress != null && ((AssetReference)info.defaultMaterialAddress).RuntimeKeyIsValid()) { return Addressables.LoadAssetAsync<Material>((object)info.defaultMaterialAddress).WaitForCompletion(); } return info.defaultMaterial; } public static Material SetupCorrection(RendererInfo info) { //IL_0000: 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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (info.defaultMaterialAddress != null && ((AssetReference)info.defaultMaterialAddress).RuntimeKeyIsValid()) { return Addressables.LoadAssetAsync<Material>((object)info.defaultMaterialAddress).WaitForCompletion(); } return info.defaultMaterial; } } }