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 DisfiguredEnemies v1.0.0
DisfiguredEnemies.dll
Decompiled 3 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.Configuration; using BepInEx.Logging; using DisfiguredEnemies.Patches; using HarmonyLib; using Microsoft.CodeAnalysis; 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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.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 DisfiguredEnemies { [BepInPlugin("benjamin.disfiguredenemies", "DisfiguredEnemies", "1.0.0")] [BepInProcess("REPO.exe")] public class Plugin : BaseUnityPlugin { public const string Guid = "benjamin.disfiguredenemies"; public const string Name = "DisfiguredEnemies"; public const string Version = "1.0.0"; internal static ManualLogSource Log; private Harmony _harmony; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> ScaleDistortion; internal static ConfigEntry<float> MinStretch; internal static ConfigEntry<float> MaxStretch; internal static ConfigEntry<float> MinSquash; internal static ConfigEntry<float> MaxSquash; internal static ConfigEntry<bool> ColorTint; internal static ConfigEntry<Color> TintColor; internal static ConfigEntry<float> TintStrength; internal static ConfigEntry<bool> EyeGlow; internal static ConfigEntry<Color> GlowColor; internal static ConfigEntry<float> GlowIntensity; internal static ConfigEntry<float> GlowRange; internal static ConfigEntry<bool> Verbose; private void Awake() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Expected O, but got Unknown //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Expected O, but got Unknown //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Expected O, but got Unknown //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master switch."); ScaleDistortion = ((BaseUnityPlugin)this).Config.Bind<bool>("Scale", "ScaleDistortion", true, "Randomly stretch/squash each enemy's proportions per spawn - uneven limbs, elongated frames, that kind of wrongness."); MinStretch = ((BaseUnityPlugin)this).Config.Bind<float>("Scale", "MinStretch", 1f, new ConfigDescription("Minimum height multiplier.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f), Array.Empty<object>())); MaxStretch = ((BaseUnityPlugin)this).Config.Bind<float>("Scale", "MaxStretch", 1.35f, new ConfigDescription("Maximum height multiplier.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f), Array.Empty<object>())); MinSquash = ((BaseUnityPlugin)this).Config.Bind<float>("Scale", "MinSquash", 0.85f, new ConfigDescription("Minimum width/depth multiplier - lower than 1 makes it gaunt.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 2f), Array.Empty<object>())); MaxSquash = ((BaseUnityPlugin)this).Config.Bind<float>("Scale", "MaxSquash", 1.15f, new ConfigDescription("Maximum width/depth multiplier.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 2f), Array.Empty<object>())); ColorTint = ((BaseUnityPlugin)this).Config.Bind<bool>("Tint", "ColorTint", true, "Tint every renderer on the enemy toward TintColor. Uses a MaterialPropertyBlock per-renderer, so it never modifies the shared material asset other instances (or other mods) also use."); TintColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Tint", "TintColor", new Color(0.55f, 0.05f, 0.05f), "Colour tinted toward. Default is a sickly dark red."); TintStrength = ((BaseUnityPlugin)this).Config.Bind<float>("Tint", "TintStrength", 0.35f, new ConfigDescription("0 = no tint, 1 = fully replaced by TintColor.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); EyeGlow = ((BaseUnityPlugin)this).Config.Bind<bool>("EyeGlow", "EyeGlow", true, "Attach a small glowing point light near the top of each enemy - an approximation of glowing eyes without needing a custom model."); GlowColor = ((BaseUnityPlugin)this).Config.Bind<Color>("EyeGlow", "GlowColor", new Color(1f, 0.15f, 0.1f), "Glow colour."); GlowIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("EyeGlow", "GlowIntensity", 1.4f, new ConfigDescription("Light intensity.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 8f), Array.Empty<object>())); GlowRange = ((BaseUnityPlugin)this).Config.Bind<float>("EyeGlow", "GlowRange", 1.2f, new ConfigDescription("Light range in metres - kept small so it reads as eyes, not a lamp.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 5f), Array.Empty<object>())); Verbose = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Verbose", false, "Log every distortion applied, with the values rolled."); _harmony = new Harmony("benjamin.disfiguredenemies"); _harmony.PatchAll(typeof(SpawnDistortPatch)); Log.LogInfo((object)"DisfiguredEnemies v1.0.0 loaded."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } internal static void Trace(string msg) { if (Verbose != null && Verbose.Value) { Log.LogInfo((object)msg); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "DisfiguredEnemies"; public const string PLUGIN_NAME = "DisfiguredEnemies"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace DisfiguredEnemies.Patches { [HarmonyPatch(typeof(EnemyParent))] internal static class SpawnDistortPatch { [HarmonyPostfix] [HarmonyPatch("Spawn")] private static void AfterSpawn(EnemyParent __instance) { if (!Plugin.Enabled.Value) { return; } Enemy enemy = __instance.Enemy; if (!((Object)(object)enemy == (Object)null)) { int num = (((Object)(object)enemy.PhotonView != (Object)null) ? enemy.PhotonView.ViewID : ((Object)enemy).GetInstanceID()); Random rng = new Random(num); Plugin.Trace($"[DisfiguredEnemies] Distorting '{__instance.enemyName}' (seed {num})."); if (Plugin.ScaleDistortion.Value) { ApplyScale(enemy, rng); } if (Plugin.ColorTint.Value) { ApplyTint(enemy); } if (Plugin.EyeGlow.Value) { ApplyGlow(enemy, rng); } } } private static void ApplyScale(Enemy enemy, Random rng) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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) Transform transform = ((Component)enemy).transform; float num = Lerp(rng, Plugin.MinStretch.Value, Plugin.MaxStretch.Value); float num2 = Lerp(rng, Plugin.MinSquash.Value, Plugin.MaxSquash.Value); Vector3 localScale = transform.localScale; transform.localScale = new Vector3(localScale.x * num2, localScale.y * num, localScale.z * num2); Plugin.Trace($"[DisfiguredEnemies] scale: height x{num:F2}, width x{num2:F2}"); } private static void ApplyTint(Enemy enemy) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) Color value = Plugin.TintColor.Value; float value2 = Plugin.TintStrength.Value; Renderer[] componentsInChildren = ((Component)enemy).GetComponentsInChildren<Renderer>(true); MaterialPropertyBlock val = new MaterialPropertyBlock(); Renderer[] array = componentsInChildren; foreach (Renderer obj in array) { obj.GetPropertyBlock(val); Vector4 vector = val.GetVector("_Color"); Color val2 = Color.Lerp((vector != Vector4.zero) ? Color.op_Implicit(vector) : Color.white, value, value2); val.SetColor("_Color", val2); val.SetColor("_BaseColor", val2); obj.SetPropertyBlock(val); } Plugin.Trace($"[DisfiguredEnemies] tinted {componentsInChildren.Length} renderer(s)"); } private static void ApplyGlow(Enemy enemy, Random rng) { //IL_0010: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = ((Component)enemy).GetComponentsInChildren<Renderer>(true); if (componentsInChildren.Length != 0) { Bounds bounds = componentsInChildren[0].bounds; Renderer[] array = componentsInChildren; foreach (Renderer val in array) { ((Bounds)(ref bounds)).Encapsulate(val.bounds); } GameObject val2 = new GameObject("DisfiguredEnemies_EyeGlow"); val2.transform.SetParent(((Component)enemy).transform, false); val2.transform.position = new Vector3(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).max.y - ((Bounds)(ref bounds)).size.y * 0.12f, ((Bounds)(ref bounds)).center.z); Light obj = val2.AddComponent<Light>(); obj.type = (LightType)2; obj.color = Plugin.GlowColor.Value; obj.intensity = Plugin.GlowIntensity.Value; obj.range = Plugin.GlowRange.Value; obj.shadows = (LightShadows)0; rng.NextDouble(); Plugin.Trace($"[DisfiguredEnemies] eye glow placed at {val2.transform.position}"); } } private static float Lerp(Random rng, float min, float max) { return min + (float)rng.NextDouble() * (max - min); } } }