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 OldEnemyModFix v1.0.0
OldEnemyModFix.dll
Decompiled 17 hours agousing System; using System.Collections.Generic; 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 BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using REPOLib.Modules; using REPOLib.Objects.Sdk; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("OldEnemyModFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("OldEnemyModFix")] [assembly: AssemblyTitle("OldEnemyModFix")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 OldEnemyModFix { [BepInPlugin("themorningstar.oldenemymodfix", "Old Enemy Mod Fix", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "themorningstar.oldenemymodfix"; internal static ManualLogSource Log; private void Awake() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; try { MethodInfo methodInfo = AccessTools.Method(typeof(Enemies), "RegisterEnemy", (Type[])null, (Type[])null); if (methodInfo == null) { Log.LogError((object)"OldEnemyModFix: Enemies.RegisterEnemy not found - REPOLib layout changed? No patch applied."); return; } new Harmony("themorningstar.oldenemymodfix").Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Relink).GetMethod("Prefix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"OldEnemyModFix: watching for old-SDK enemy content to re-link."); } catch (Exception ex) { Log.LogError((object)("OldEnemyModFix: patch failed: " + ex)); } } } internal static class Relink { private static readonly FieldInfo FSetup = AccessTools.Field(typeof(EnemyContent), "_setup"); private static readonly FieldInfo FSpawn = AccessTools.Field(typeof(EnemyContent), "_spawnObjects"); public static void Prefix(EnemyContent enemyContent) { if ((Object)(object)enemyContent == (Object)null || ((Object)(object)enemyContent.Setup != (Object)null && enemyContent.SpawnObjects != null && enemyContent.SpawnObjects.Count > 0)) { return; } AssetBundle bundle = ((Content)enemyContent).Bundle; string text = Norm(((Object)enemyContent).name + " " + (((Object)(object)bundle != (Object)null) ? ((Object)bundle).name : "")); if (text.Length == 0) { Plugin.Log.LogWarning((object)"OldEnemyModFix: an enemy content has no name/bundle to identify it by; skipping."); return; } EnemyParent val = null; int num = 0; EnemyParent[] array = Resources.FindObjectsOfTypeAll<EnemyParent>(); foreach (EnemyParent val2 in array) { if (!((Object)(object)val2 == (Object)null) && !string.IsNullOrEmpty(val2.enemyName)) { string text2 = Norm(val2.enemyName); if (text2.Length >= 3 && text2.Length > num && text.Contains(text2)) { val = val2; num = text2.Length; } } } if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("OldEnemyModFix: couldn't identify the enemy for content '" + ((Object)enemyContent).name + "' (bundle '" + (((Object)(object)bundle != (Object)null) ? ((Object)bundle).name : "?") + "'); skipping.")); return; } GameObject gameObject = ((Component)((Component)val).transform.root).gameObject; string token = Norm(val.enemyName); EnemySetup val3 = (from s in Resources.FindObjectsOfTypeAll<EnemySetup>() where (Object)(object)s != (Object)null && Norm(((Object)s).name).Contains(token) orderby s.spawnObjects?.Count ?? 0 descending select s).FirstOrDefault(); if ((Object)(object)val3 == (Object)null) { Plugin.Log.LogWarning((object)("OldEnemyModFix: found prefab '" + ((Object)gameObject).name + "' for '" + ((Object)enemyContent).name + "' but no matching EnemySetup ('" + token + "'); skipping.")); return; } if ((Object)(object)enemyContent.Setup == (Object)null && FSetup != null) { FSetup.SetValue(enemyContent, val3); } if (FSpawn != null) { FSpawn.SetValue(enemyContent, new List<GameObject> { gameObject }); } Plugin.Log.LogInfo((object)("OldEnemyModFix: re-linked '" + ((Object)enemyContent).name + "' -> enemy '" + val.enemyName + "' (setup '" + ((Object)val3).name + "', prefab '" + ((Object)gameObject).name + "').")); } private static string Norm(string s) { return (s ?? "").ToLowerInvariant().Replace(" ", "").Replace("-", "") .Replace("_", ""); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }