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 InfestorFix v1.0.1
plugins/InfestorFix/InfestorFix.dll
Decompiled a year agousing System; using System.Diagnostics; 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.Logging; using InfestorFix.Utilities.Extensions; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; using MonoMod.Cil; using MonoMod.Utils; using On.RoR2; using R2API.Utils; using RoR2; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: NetworkCompatibility(/*Could not decode attribute arguments.*/)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("InfestorFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+620379ae6beb67bffb91c36951da96c1f28862b0")] [assembly: AssemblyProduct("InfestorFix")] [assembly: AssemblyTitle("InfestorFix")] [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 InfestorFix { public class DelayTrailRendererStart : MonoBehaviour { public float Delay; public TrailRenderer[] TrailRenderers = Array.Empty<TrailRenderer>(); private float _age; private void Awake() { setTrailsEnabled(enabled: false); } private void FixedUpdate() { _age += Time.fixedDeltaTime; if (_age >= Delay) { setTrailsEnabled(enabled: true); ((Behaviour)this).enabled = false; } } private void setTrailsEnabled(bool enabled) { TrailRenderer[] trailRenderers = TrailRenderers; foreach (TrailRenderer val in trailRenderers) { if (Object.op_Implicit((Object)(object)val)) { val.Clear(); ((Renderer)val).forceRenderingOff = !enabled; } } } } [BepInPlugin("Gorakh.InfestorFix", "InfestorFix", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class InfestorFixPlugin : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static hook_GetAppropriateLayerForTeam <0>__LayerIndex_GetAppropriateLayerForTeam; public static hook_ApplyForceImpulse <1>__CharacterMotor_ApplyForceImpulse; } public const string PluginGUID = "Gorakh.InfestorFix"; public const string PluginAuthor = "Gorakh"; public const string PluginName = "InfestorFix"; public const string PluginVersion = "1.0.1"; private static InfestorFixPlugin _instance; internal static InfestorFixPlugin Instance => _instance; private void Awake() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown Stopwatch stopwatch = Stopwatch.StartNew(); SingletonHelper.Assign<InfestorFixPlugin>(ref _instance, this); Log.Init(((BaseUnityPlugin)this).Logger); object obj = <>O.<0>__LayerIndex_GetAppropriateLayerForTeam; if (obj == null) { hook_GetAppropriateLayerForTeam val = LayerIndex_GetAppropriateLayerForTeam; <>O.<0>__LayerIndex_GetAppropriateLayerForTeam = val; obj = (object)val; } LayerIndex.GetAppropriateLayerForTeam += (hook_GetAppropriateLayerForTeam)obj; object obj2 = <>O.<1>__CharacterMotor_ApplyForceImpulse; if (obj2 == null) { hook_ApplyForceImpulse val2 = CharacterMotor_ApplyForceImpulse; <>O.<1>__CharacterMotor_ApplyForceImpulse = val2; obj2 = (object)val2; } CharacterMotor.ApplyForceImpulse += (hook_ApplyForceImpulse)obj2; Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/EliteVoid/VoidInfestorBody.prefab").CallOnSuccess(delegate(GameObject voidInfestorBody) { TrailRenderer[] componentsInChildren = voidInfestorBody.GetComponentsInChildren<TrailRenderer>(true); if (componentsInChildren.Length != 0) { DelayTrailRendererStart delayTrailRendererStart = voidInfestorBody.AddComponent<DelayTrailRendererStart>(); delayTrailRendererStart.Delay = 1f / 30f; delayTrailRendererStart.TrailRenderers = componentsInChildren; } }); stopwatch.Stop(); Log.Message_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalMilliseconds:F0}ms"); } private void OnDestroy() { //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) //IL_0026: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown SingletonHelper.Unassign<InfestorFixPlugin>(ref _instance, this); object obj = <>O.<0>__LayerIndex_GetAppropriateLayerForTeam; if (obj == null) { hook_GetAppropriateLayerForTeam val = LayerIndex_GetAppropriateLayerForTeam; <>O.<0>__LayerIndex_GetAppropriateLayerForTeam = val; obj = (object)val; } LayerIndex.GetAppropriateLayerForTeam -= (hook_GetAppropriateLayerForTeam)obj; object obj2 = <>O.<1>__CharacterMotor_ApplyForceImpulse; if (obj2 == null) { hook_ApplyForceImpulse val2 = CharacterMotor_ApplyForceImpulse; <>O.<1>__CharacterMotor_ApplyForceImpulse = val2; obj2 = (object)val2; } CharacterMotor.ApplyForceImpulse -= (hook_ApplyForceImpulse)obj2; } private static int LayerIndex_GetAppropriateLayerForTeam(orig_GetAppropriateLayerForTeam orig, TeamIndex teamIndex) { //IL_0001: 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_000a: Invalid comparison between Unknown and I4 int result = orig.Invoke(teamIndex); if ((int)teamIndex == 4) { result = LayerIndex.enemyBody.intVal; } return result; } private static void CharacterMotor_ApplyForceImpulse(orig_ApplyForceImpulse orig, CharacterMotor self, ref PhysForceInfo forceInfo) { if (!self.hasEffectiveAuthority && Util.HasEffectiveAuthority(((NetworkBehaviour)self).netIdentity)) { self.UpdateAuthority(); } orig.Invoke(self, ref forceInfo); } } internal static class Log { private static readonly StringBuilder _sharedStringBuilder; private static readonly int _cachedCallerPathPrefixLength; private static ManualLogSource _logSource; static Log() { _sharedStringBuilder = new StringBuilder(256); _cachedCallerPathPrefixLength = getCallerPathPrefixLength("X:\\Git\\RoR2\\InfestorFix\\InfestorFix\\Log.cs"); static int getCallerPathPrefixLength([CallerFilePath] string callerPath = null) { int num = callerPath.LastIndexOf("InfestorFix\\"); if (num >= 0) { return num + "InfestorFix\\".Length; } Debug.LogError((object)"[InfestorFix] Logger failed to determine caller path prefix length"); return 0; } } internal static void Init(ManualLogSource logSource) { _logSource = logSource; } private static StringBuilder AppendCallerPrefix(this StringBuilder stringBuilder, string callerPath, string callerMemberName, int callerLineNumber) { return stringBuilder.Append(callerPath, _cachedCallerPathPrefixLength, callerPath.Length - _cachedCallerPathPrefixLength).Append(':').Append(callerLineNumber) .Append(" (") .Append(callerMemberName) .Append("):"); } private static StringBuilder buildCallerLogString(string callerPath, string callerMemberName, int callerLineNumber, object data) { return _sharedStringBuilder.Clear().AppendCallerPrefix(callerPath, callerMemberName, callerLineNumber).Append(' ') .Append(data); } [Conditional("DEBUG")] internal static void Debug(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogDebug((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [Conditional("DEBUG")] internal static void Debug_NoCallerPrefix(object data) { _logSource.LogDebug(data); } internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogError((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Error_NoCallerPrefix(object data) { _logSource.LogError(data); } internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogFatal((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Fatal_NoCallerPrefix(object data) { _logSource.LogFatal(data); } internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogInfo((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Info_NoCallerPrefix(object data) { _logSource.LogInfo(data); } internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogMessage((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Message_NoCallerPrefix(object data) { _logSource.LogMessage(data); } internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogWarning((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Warning_NoCallerPrefix(object data) { _logSource.LogWarning(data); } internal static void LogType(LogLevel level, object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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) if ((level & 0x20) == 0) { _logSource.Log(level, (object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void LogType_NoCallerPrefix(LogLevel level, object data) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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) if ((level & 0x20) == 0) { _logSource.Log(level, data); } } } } namespace InfestorFix.Utilities.Extensions { public static class AssetLoadExtensions { public static void CallOnSuccess<T>(this AsyncOperationHandle<T> handle, Action<T> onSuccess) { handle.Completed += delegate(AsyncOperationHandle<T> handle) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)handle.Status == 2) { Log.Error("Failed to load asset '" + handle.LocationName + "'", "X:\\Git\\RoR2\\InfestorFix\\InfestorFix\\Utilities\\Extensions\\AssetLoadExtensions.cs", "CallOnSuccess", 19); } else { onSuccess(handle.Result); } }; } } public static class PatchExtensions { public static void EmitSkipMethodCall(this ILCursor c, MethodDefinition method = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) c.EmitSkipMethodCall(OpCodes.Br, method); } public static void EmitSkipMethodCall(this ILCursor c, OpCode branchOpCode, MethodDefinition method = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) c.EmitSkipMethodCall(branchOpCode, null, method); } public static void EmitSkipMethodCall(this ILCursor c, OpCode branchOpCode, Action<ILCursor> emitSkippedReturnValue, MethodDefinition method = null) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) if (c == null) { throw new ArgumentNullException("c"); } if ((int)((OpCode)(ref branchOpCode)).FlowControl != 0 && (int)((OpCode)(ref branchOpCode)).FlowControl != 3) { throw new ArgumentException($"Invalid branch OpCode: {branchOpCode}"); } if (method == null) { MethodReference val = default(MethodReference); if (!ILPatternMatchingExt.MatchCallOrCallvirt(c.Next, ref val)) { Log.Error($"Failed to find method call to skip: {((MemberReference)c.Context.Method).FullName} at instruction {c.Next} ({c.Index})", "X:\\Git\\RoR2\\InfestorFix\\InfestorFix\\Utilities\\Extensions\\PatchExtensions.cs", "EmitSkipMethodCall", 33); return; } method = Extensions.SafeResolve(val); if (method == null) { Log.Error($"Failed to resolve method '{((MemberReference)val).FullName}': {((MemberReference)c.Context.Method).FullName} at instruction {c.Next} ({c.Index})", "X:\\Git\\RoR2\\InfestorFix\\InfestorFix\\Utilities\\Extensions\\PatchExtensions.cs", "EmitSkipMethodCall", 41); return; } } int num = ((MethodReference)method).Parameters.Count + ((!method.IsStatic) ? 1 : 0); bool flag = Extensions.Is((MemberReference)(object)((MethodReference)method).ReturnType, (MemberInfo)typeof(void)); ILLabel val2 = c.DefineLabel(); c.Emit(branchOpCode, (object)val2); int index = c.Index; c.Index = index + 1; if (num > 0 || !flag) { ILLabel val3 = c.DefineLabel(); c.Emit(OpCodes.Br, (object)val3); c.MarkLabel(val2); for (int i = 0; i < num; i++) { c.Emit(OpCodes.Pop); } if (emitSkippedReturnValue != null) { emitSkippedReturnValue(c); } else if (!flag) { Log.Warning($"Skipped method ({((MemberReference)method).FullName}) is not void, emitting default value: {((MemberReference)c.Context.Method).FullName} at instruction {c.Next} ({c.Index})", "X:\\Git\\RoR2\\InfestorFix\\InfestorFix\\Utilities\\Extensions\\PatchExtensions.cs", "EmitSkipMethodCall", 73); if (((MethodReference)method).ReturnType.IsValueType) { VariableDefinition val4 = c.Context.AddVariable(((MethodReference)method).ReturnType); c.Emit(OpCodes.Ldloca, val4); c.Emit(OpCodes.Initobj, ((MethodReference)method).ReturnType); c.Emit(OpCodes.Ldloc, val4); } else { c.Emit(OpCodes.Ldnull); } } c.MarkLabel(val3); } else { c.MarkLabel(val2); } } public static bool TryFindParameter(this MethodReference method, Type type, string name, out ParameterDefinition parameter) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) Enumerator<ParameterDefinition> enumerator = method.Parameters.GetEnumerator(); try { while (enumerator.MoveNext()) { ParameterDefinition current = enumerator.Current; if ((string.IsNullOrEmpty(name) || ((ParameterReference)current).Name == name) && (type == null || Extensions.Is((MemberReference)(object)((ParameterReference)current).ParameterType, (MemberInfo)type))) { parameter = current; return true; } } } finally { ((IDisposable)enumerator).Dispose(); } parameter = null; return false; } public static bool TryFindParameter(this MethodReference method, string name, out ParameterDefinition parameter) { return method.TryFindParameter(null, name, out parameter); } public static bool TryFindParameter(this MethodReference method, Type type, out ParameterDefinition parameter) { return method.TryFindParameter(type, null, out parameter); } public static bool TryFindParameter<T>(this MethodReference method, string name, out ParameterDefinition parameter) { return method.TryFindParameter(typeof(T), name, out parameter); } public static bool TryFindParameter<T>(this MethodReference method, out ParameterDefinition parameter) { return method.TryFindParameter(typeof(T), null, out parameter); } public static VariableDefinition AddVariable(this ILContext context, TypeReference variableType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown VariableDefinition val = new VariableDefinition(variableType); context.Method.Body.Variables.Add(val); return val; } public static VariableDefinition AddVariable(this ILContext context, Type variableType) { return context.AddVariable(context.Import(variableType)); } public static VariableDefinition AddVariable<T>(this ILContext context) { return context.AddVariable(context.Import(typeof(T))); } public static void EmitStoreStack(this ILCursor cursor, params VariableDefinition[] variables) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (cursor == null) { throw new ArgumentNullException("cursor"); } if (variables == null) { throw new ArgumentNullException("variables"); } if (variables.Length != 0) { for (int num = variables.Length - 1; num >= 1; num--) { cursor.Emit(OpCodes.Stloc, variables[num]); } cursor.Emit(OpCodes.Dup); cursor.Emit(OpCodes.Stloc, variables[0]); for (int i = 1; i < variables.Length; i++) { cursor.Emit(OpCodes.Ldloc, variables[i]); } } } } }