using 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 Enabled; public static ConfigEntry MinScale; public static ConfigEntry MaxScale; public static ConfigEntry MinSpeedMultiplier; public static ConfigEntry MaxSpeedMultiplier; private static readonly Dictionary SpeedMultipliers = new Dictionary(); private static readonly Dictionary AnimatorMultipliers = new Dictionary(); private void Awake() { Enabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Turn the mod on or off"); MinScale = ((BaseUnityPlugin)this).Config.Bind("Size", "MinScale", 0.6f, "Smallest size (0.6 = 60%)"); MaxScale = ((BaseUnityPlugin)this).Config.Bind("Size", "MaxScale", 2.2f, "Biggest size (2.2 = 220%)"); MinSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind("Speed", "MinSpeedMultiplier", 0.75f, "Slowest enemy speed (0.75 = 75%)"); MaxSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind("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(true); if ((Object)(object)componentInChildren != (Object)null) { SpeedMultipliers[componentInChildren] = num2; componentInChildren.DefaultSpeed *= num2; componentInChildren.DefaultAcceleration *= num2; } Animator[] componentsInChildren = ((Component)__instance).GetComponentsInChildren(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 animatorMultiplier in AnimatorMultipliers) { Animator key = animatorMultiplier.Key; if (!((Object)(object)key == (Object)null) && ((Behaviour)key).enabled) { key.speed = animatorMultiplier.Value; } } } } }