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 EnemySizeRandomizer v1.1.0
BepInEx/plugins/EnemySizeRandomizer.dll
Decompiled 2 hours agousing System; using System.Collections.Generic; 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.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("basra")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("EnemySizeRandomizer")] [assembly: AssemblyTitle("EnemySizeRandomizer")] [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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 EnemySizeRandomizer { [BepInPlugin("Grungler.EnemySizeRandomizer", "Enemy Size Randomizer", "1.1.0")] public class EnemySizeRandomizerPlugin : BaseUnityPlugin { public static ConfigEntry<bool> Enabled; public static ConfigEntry<float> MinScale; public static ConfigEntry<float> MaxScale; public static ConfigEntry<float> MinSpeedMultiplier; public static ConfigEntry<float> MaxSpeedMultiplier; private static readonly Dictionary<EnemyNavMeshAgent, float> SpeedMultipliers = new Dictionary<EnemyNavMeshAgent, float>(); private static readonly Dictionary<Animator, float> AnimatorMultipliers = new Dictionary<Animator, float>(); private void Awake() { Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Turn the mod on or off"); MinScale = ((BaseUnityPlugin)this).Config.Bind<float>("Size", "MinScale", 0.6f, "Smallest size (0.6 = 60%)"); MaxScale = ((BaseUnityPlugin)this).Config.Bind<float>("Size", "MaxScale", 2.2f, "Biggest size (2.2 = 220%)"); MinSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Speed", "MinSpeedMultiplier", 0.75f, "Slowest enemy speed (0.75 = 75%)"); MaxSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Speed", "MaxSpeedMultiplier", 1.5f, "Fastest enemy speed (1.5 = 150%)"); Harmony.CreateAndPatchAll(typeof(EnemySizeRandomizerPlugin), (string)null); Debug.Log((object)"[EnemySizeRandomizer] Loaded."); } [HarmonyPostfix] [HarmonyPatch(typeof(EnemyParent), "SpawnRPC")] private static void OnEnemySpawn(EnemyParent __instance) { //IL_0042: 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) if (!Enabled.Value || (Object)(object)__instance == (Object)null) { return; } float num = Random.Range(MinScale.Value, MaxScale.Value); ((Component)__instance).transform.localScale = Vector3.one * num; float num2 = Random.Range(MinSpeedMultiplier.Value, MaxSpeedMultiplier.Value); EnemyNavMeshAgent componentInChildren = ((Component)__instance).GetComponentInChildren<EnemyNavMeshAgent>(true); if ((Object)(object)componentInChildren != (Object)null) { SpeedMultipliers[componentInChildren] = num2; componentInChildren.DefaultSpeed *= num2; componentInChildren.DefaultAcceleration *= num2; } Animator[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Animator>(true); Animator[] array = componentsInChildren; foreach (Animator val in array) { if (!((Object)(object)val == (Object)null)) { AnimatorMultipliers[val] = num2; val.speed = num2; } } Debug.Log((object)("[EnemySizeRandomizer] Enemy spawned! " + $"Scale: {num:F2}x | " + $"Speed: {num2:F2}x | " + $"Animators: {componentsInChildren.Length}")); } [HarmonyPrefix] [HarmonyPatch(typeof(EnemyNavMeshAgent), "OverrideAgent")] private static void OverrideAgentPatch(EnemyNavMeshAgent __instance, ref float speed, ref float acceleration) { if (Enabled.Value && !((Object)(object)__instance == (Object)null) && SpeedMultipliers.TryGetValue(__instance, out var value)) { speed *= value; acceleration *= value; } } [HarmonyPostfix] [HarmonyPatch(typeof(EnemyNavMeshAgent), "Update")] private static void OnEnemyNavUpdate(EnemyNavMeshAgent __instance) { if (Enabled.Value && !((Object)(object)__instance == (Object)null) && SpeedMultipliers.TryGetValue(__instance, out var _) && (Object)(object)__instance.Agent != (Object)null && ((Behaviour)__instance.Agent).enabled) { float defaultSpeed = __instance.DefaultSpeed; if (__instance.Agent.speed < defaultSpeed) { __instance.Agent.speed = defaultSpeed; } float defaultAcceleration = __instance.DefaultAcceleration; if (__instance.Agent.acceleration < defaultAcceleration) { __instance.Agent.acceleration = defaultAcceleration; } } } private void Update() { if (!Enabled.Value) { return; } foreach (KeyValuePair<Animator, float> animatorMultiplier in AnimatorMultipliers) { Animator key = animatorMultiplier.Key; if (!((Object)(object)key == (Object)null) && ((Behaviour)key).enabled) { key.speed = animatorMultiplier.Value; } } } } }