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 MutantEnderman v0.2.8
MutantEndermanV81.dll
Decompiled 31 minutes ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using LethalLib.Modules; using Microsoft.CodeAnalysis; using MutantEndermanV81.NetcodePatcher; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Networking; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] 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 MutantEndermanV81 { public sealed class EndermanPurpleSparkBurst : MonoBehaviour { private static Material _purple; private Mesh _mesh; private float _birth; private float _duration; internal static void Create(Vector3 point, float intensity) { //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_purple == (Object)null) { Shader val = Shader.Find("HDRP/Unlit") ?? Shader.Find("HDRP/Lit") ?? Shader.Find("Standard"); if ((Object)(object)val == (Object)null) { return; } _purple = new Material(val); ((Object)_purple).name = "MutantEnderman_PurpleSparks"; Color val2 = default(Color); ((Color)(ref val2))..ctor(0.72f, 0.19f, 1f, 1f); if (_purple.HasProperty("_BaseColor")) { _purple.SetColor("_BaseColor", val2); } if (_purple.HasProperty("_Color")) { _purple.SetColor("_Color", val2); } if (_purple.HasProperty("_EmissiveColor")) { _purple.SetColor("_EmissiveColor", new Color(1.1f, 0.19f, 2f, 1f)); } if (_purple.HasProperty("_CullMode")) { _purple.SetFloat("_CullMode", 0f); } if (_purple.HasProperty("_DoubleSidedEnable")) { _purple.SetFloat("_DoubleSidedEnable", 1f); } } GameObject val3 = new GameObject("MutantEnderman_PurpleSparkBurst"); val3.transform.position = point + Vector3.up * 1.5f; MeshFilter val4 = val3.AddComponent<MeshFilter>(); ((Renderer)val3.AddComponent<MeshRenderer>()).sharedMaterial = _purple; EndermanPurpleSparkBurst endermanPurpleSparkBurst = val3.AddComponent<EndermanPurpleSparkBurst>(); endermanPurpleSparkBurst._birth = Time.time; endermanPurpleSparkBurst._duration = Mathf.Clamp(0.85f + intensity * 0.18f, 0.8f, 1.4f); endermanPurpleSparkBurst._mesh = CreateMesh(intensity); val4.sharedMesh = endermanPurpleSparkBurst._mesh; Object.Destroy((Object)val3, endermanPurpleSparkBurst._duration + 0.2f); } private static Mesh CreateMesh(float intensity) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Expected O, but got Unknown int num = Mathf.Clamp(Mathf.RoundToInt(22f * intensity), 16, 55); Vector3[] array = (Vector3[])(object)new Vector3[num * 4]; int[] array2 = new int[num * 12]; for (int i = 0; i < num; i++) { Vector3 val = Random.insideUnitSphere * (1.05f * intensity); val.y *= 1.25f; float num2 = Random.Range(0.075f, 0.19f); int num3 = i * 4; array[num3] = val + new Vector3(0f, num2, 0f); array[num3 + 1] = val + new Vector3(0f - num2, 0f - num2, 0f - num2); array[num3 + 2] = val + new Vector3(num2, 0f - num2, 0f - num2); array[num3 + 3] = val + new Vector3(0f, 0f - num2, num2); int num4 = i * 12; array2[num4] = num3; array2[num4 + 1] = num3 + 2; array2[num4 + 2] = num3 + 1; array2[num4 + 3] = num3; array2[num4 + 4] = num3 + 3; array2[num4 + 5] = num3 + 2; array2[num4 + 6] = num3; array2[num4 + 7] = num3 + 1; array2[num4 + 8] = num3 + 3; array2[num4 + 9] = num3 + 1; array2[num4 + 10] = num3 + 2; array2[num4 + 11] = num3 + 3; } Mesh val2 = new Mesh { name = "MutantEnderman_OneShotPurpleSparks", vertices = array, triangles = array2 }; val2.RecalculateNormals(); val2.RecalculateBounds(); return val2; } private void Update() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp01((Time.time - _birth) / Mathf.Max(0.05f, _duration)); ((Component)this).transform.Rotate(0f, 170f * Time.deltaTime, 0f, (Space)0); ((Component)this).transform.localScale = Vector3.one * (0.45f + 0.7f * Mathf.Sin(num * MathF.PI)) * (1f - 0.65f * num); } private void OnDestroy() { if ((Object)(object)_mesh != (Object)null) { Object.Destroy((Object)(object)_mesh); } } } public sealed class EndermanDeathVisualFinale : MonoBehaviour { private float _endAt; private bool _finished; private bool _hidden; internal void Initialize(float deathAnimationLength) { _endAt = Time.time + Mathf.Max(0.5f, deathAnimationLength - 0.14f); Object.Destroy((Object)(object)((Component)this).gameObject, deathAnimationLength + 0.9f); } private void Update() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!_finished && Time.time >= _endAt) { _finished = true; EndermanTeleportParticles.PlayDeath(((Component)this).transform.position); } if (!_finished || _hidden || !(Time.time >= _endAt + 0.45f)) { return; } _hidden = true; Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if ((Object)(object)val != (Object)null) { val.enabled = false; } } } } internal static class EndermanRuntimeVisual { internal sealed class NodeData { internal string name; internal int parent; internal int mesh; internal Vector3 position; internal Vector3 scale; internal Quaternion rotation; } internal sealed class TrackData { internal int node; internal int property; internal float[] times; internal Vector4[] values; } internal sealed class ClipData { internal string name; internal float duration; internal TrackData[] tracks; } private static NodeData[] nodes; private static Mesh[] meshes; private static Material sharedMaterial; internal static ClipData[] Clips { get; private set; } internal static NodeData[] Nodes => nodes; internal static void Load(string directory) { //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Expected O, but got Unknown //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Expected O, but got Unknown //IL_05a9: Unknown result type (might be due to invalid IL or missing references) //IL_05ce: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) if (nodes != null) { return; } string path = Path.Combine(directory, "mutantenderman.model"); string path2 = Path.Combine(directory, "MutantEnderman_Texture.png"); if (!File.Exists(path) || !File.Exists(path2)) { throw new FileNotFoundException("Runtime model/texture missing in " + directory); } using (FileStream fileStream = File.OpenRead(path)) { using BinaryReader binaryReader = new BinaryReader(fileStream); if (new string(binaryReader.ReadChars(4)) != "MEND" || binaryReader.ReadInt32() != 1) { throw new InvalidDataException("Unsupported Mutant Enderman runtime model format"); } int num = binaryReader.ReadInt32(); if (num < 1 || num > 2000) { throw new InvalidDataException("Invalid node count"); } NodeData[] array = new NodeData[num]; for (int i = 0; i < num; i++) { array[i] = new NodeData { name = binaryReader.ReadString(), parent = binaryReader.ReadInt32(), mesh = binaryReader.ReadInt32(), position = ReadVector3(binaryReader), rotation = ReadQuaternion(binaryReader), scale = ReadVector3(binaryReader) }; } int num2 = binaryReader.ReadInt32(); if (num2 < 1 || num2 > 1000) { throw new InvalidDataException("Invalid mesh count"); } Mesh[] array2 = (Mesh[])(object)new Mesh[num2]; for (int j = 0; j < num2; j++) { int num3 = binaryReader.ReadInt32(); if (num3 < 3 || num3 > 300000) { throw new InvalidDataException("Invalid vertex count"); } Vector3[] array3 = (Vector3[])(object)new Vector3[num3]; Vector3[] array4 = (Vector3[])(object)new Vector3[num3]; Vector2[] array5 = (Vector2[])(object)new Vector2[num3]; for (int k = 0; k < num3; k++) { array3[k] = ReadVector3(binaryReader); } for (int l = 0; l < num3; l++) { array4[l] = ReadVector3(binaryReader); } for (int m = 0; m < num3; m++) { array5[m] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } int num4 = binaryReader.ReadInt32(); if (num4 < 3 || num4 > 1000000 || num4 % 3 != 0) { throw new InvalidDataException("Invalid triangle count"); } int[] array6 = new int[num4]; for (int n = 0; n < num4; n++) { array6[n] = binaryReader.ReadInt32(); } Mesh val = new Mesh(); ((Object)val).name = "MutantEnderman_Mesh_" + j; if (num3 > 65535) { val.indexFormat = (IndexFormat)1; } val.vertices = array3; val.normals = array4; val.uv = array5; val.triangles = array6; val.RecalculateBounds(); array2[j] = val; } int num5 = binaryReader.ReadInt32(); if (num5 != 9) { throw new InvalidDataException("Expected 9 animation clips, got " + num5); } ClipData[] array7 = new ClipData[num5]; Vector4 val2 = default(Vector4); for (int num6 = 0; num6 < num5; num6++) { ClipData clipData = new ClipData(); clipData.name = binaryReader.ReadString(); clipData.duration = binaryReader.ReadSingle(); int num7 = binaryReader.ReadInt32(); if (num7 < 0 || num7 > 1000) { throw new InvalidDataException("Invalid track count"); } clipData.tracks = new TrackData[num7]; for (int num8 = 0; num8 < num7; num8++) { TrackData trackData = new TrackData(); trackData.node = binaryReader.ReadInt32(); trackData.property = binaryReader.ReadByte(); int num9 = binaryReader.ReadInt32(); if (trackData.node < 0 || trackData.node >= num || trackData.property < 0 || trackData.property > 2 || num9 < 1 || num9 > 200000) { throw new InvalidDataException("Invalid animation track"); } trackData.times = new float[num9]; trackData.values = (Vector4[])(object)new Vector4[num9]; for (int num10 = 0; num10 < num9; num10++) { trackData.times[num10] = binaryReader.ReadSingle(); ((Vector4)(ref val2))..ctor(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), 0f); if (trackData.property == 1) { val2.w = binaryReader.ReadSingle(); } trackData.values[num10] = val2; } clipData.tracks[num8] = trackData; } array7[num6] = clipData; } if (fileStream.Position != fileStream.Length) { throw new InvalidDataException("Trailing model data, possible format mismatch"); } nodes = array; meshes = array2; Clips = array7; } byte[] array8 = File.ReadAllBytes(path2); Texture2D val3 = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val3, array8, false)) { throw new InvalidDataException("Failed to decode Enderman texture PNG"); } ((Texture)val3).filterMode = (FilterMode)0; ((Texture)val3).wrapMode = (TextureWrapMode)1; ((Object)val3).name = "MutantEnderman_Texture"; Shader obj = Shader.Find("HDRP/Lit") ?? Shader.Find("HDRP/Unlit") ?? Shader.Find("Standard") ?? Shader.Find("Unlit/Texture"); if ((Object)(object)obj == (Object)null) { throw new InvalidOperationException("Could not find a compatible Unity shader"); } sharedMaterial = new Material(obj); ((Object)sharedMaterial).name = "MutantEnderman_Material"; if (sharedMaterial.HasProperty("_BaseColorMap")) { sharedMaterial.SetTexture("_BaseColorMap", (Texture)(object)val3); } if (sharedMaterial.HasProperty("_MainTex")) { sharedMaterial.SetTexture("_MainTex", (Texture)(object)val3); } if (sharedMaterial.HasProperty("_BaseColor")) { sharedMaterial.SetColor("_BaseColor", Color.white); } if (sharedMaterial.HasProperty("_Color")) { sharedMaterial.SetColor("_Color", Color.white); } if (sharedMaterial.HasProperty("_AlphaCutoffEnable")) { sharedMaterial.SetFloat("_AlphaCutoffEnable", 1f); } if (sharedMaterial.HasProperty("_AlphaCutoff")) { sharedMaterial.SetFloat("_AlphaCutoff", 0.05f); } if (sharedMaterial.HasProperty("_Cutoff")) { sharedMaterial.SetFloat("_Cutoff", 0.05f); } if (sharedMaterial.HasProperty("_CullMode")) { sharedMaterial.SetFloat("_CullMode", 0f); } if (sharedMaterial.HasProperty("_DoubleSidedEnable")) { sharedMaterial.SetFloat("_DoubleSidedEnable", 1f); } sharedMaterial.EnableKeyword("_ALPHATEST_ON"); sharedMaterial.EnableKeyword("_DOUBLESIDED_ON"); } internal static GameObject Create(Transform parent) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) if (nodes == null) { throw new InvalidOperationException("Load runtime model before creating enemies"); } GameObject val = new GameObject("MutantEndermanVisual"); val.transform.SetParent(parent, false); val.transform.localScale = Vector3.one * 0.8750591f; val.transform.localPosition = new Vector3(0f, 0.01065873f, 0f); Transform[] array = (Transform[])(object)new Transform[nodes.Length]; for (int i = 0; i < nodes.Length; i++) { NodeData nodeData = nodes[i]; GameObject val2 = new GameObject(nodeData.name); array[i] = val2.transform; val2.transform.SetParent(val.transform, false); val2.transform.localPosition = nodeData.position; val2.transform.localRotation = nodeData.rotation; val2.transform.localScale = nodeData.scale; if (nodeData.mesh >= 0) { val2.AddComponent<MeshFilter>().sharedMesh = meshes[nodeData.mesh]; ((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = sharedMaterial; } } for (int j = 0; j < nodes.Length; j++) { if (nodes[j].parent >= 0) { array[j].SetParent(array[nodes[j].parent], false); } } val.AddComponent<Animator>().applyRootMotion = false; val.AddComponent<EndermanRuntimeAnimator>(); return val; } private static Vector3 ReadVector3(BinaryReader r) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); } private static Quaternion ReadQuaternion(BinaryReader r) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new Quaternion(r.ReadSingle(), r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); } } public sealed class EndermanRuntimeAnimator : MonoBehaviour { private Transform[] _nodes; private EndermanRuntimeVisual.ClipData _active; private float _startTime; private string _state; private string _lastLocomotion = "Idle"; private float GestureLength() { if (_active == null) { return 0f; } float num = ((_state == "Roar") ? _active.duration : ((_state == "RangeAttack") ? 1f : 1.5f)); return Mathf.Min(_active.duration, num); } private void Bind() { if (_nodes != null || EndermanRuntimeVisual.Nodes == null) { return; } EndermanRuntimeVisual.NodeData[] nodes = EndermanRuntimeVisual.Nodes; _nodes = (Transform[])(object)new Transform[nodes.Length]; Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>(StringComparer.Ordinal); Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if ((Object)(object)val != (Object)(object)((Component)this).transform) { dictionary[((Object)val).name] = val; } } for (int j = 0; j < nodes.Length; j++) { if (!dictionary.TryGetValue(nodes[j].name, out var value)) { ManualLogSource modLogger = Plugin.ModLogger; if (modLogger != null) { modLogger.LogWarning((object)("Animation node missing: " + nodes[j].name)); } return; } _nodes[j] = value; } Play("Idle"); } private void Start() { Bind(); } internal void Play(string name) { if (_nodes == null) { Bind(); } if (_nodes == null || EndermanRuntimeVisual.Clips == null) { return; } if (name == "Idle" || name == "Walk") { _lastLocomotion = name; if ((_state == "Roar" || _state == "Attack" || _state == "AttackHeavy" || _state == "RangeAttack" || _state == "TargetFound") && _active != null && Time.time - _startTime < GestureLength()) { return; } } if (name == _state) { return; } EndermanRuntimeVisual.ClipData[] clips = EndermanRuntimeVisual.Clips; foreach (EndermanRuntimeVisual.ClipData clipData in clips) { if (string.Equals(clipData.name, name, StringComparison.Ordinal)) { _active = clipData; _state = name; _startTime = Time.time; break; } } } private void Update() { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) if (_nodes == null) { Bind(); } if (_active == null || _nodes == null) { return; } EndermanRuntimeVisual.NodeData[] nodes = EndermanRuntimeVisual.Nodes; float num = Time.time - _startTime; bool flag = _state == "Idle" || _state == "Walk"; float num2 = Mathf.Max(0.001f, _active.duration); float num3 = (flag ? Mathf.Repeat(num, num2) : Mathf.Min(num, num2)); for (int i = 0; i < _nodes.Length; i++) { _nodes[i].localPosition = nodes[i].position; _nodes[i].localRotation = nodes[i].rotation; _nodes[i].localScale = nodes[i].scale; } EndermanRuntimeVisual.TrackData[] tracks = _active.tracks; foreach (EndermanRuntimeVisual.TrackData trackData in tracks) { Transform val = _nodes[trackData.node]; int num4 = trackData.times.Length; int num5 = Array.BinarySearch(trackData.times, num3); if (num5 < 0) { num5 = ~num5; } int num6 = ((num5 > 0) ? (num5 - 1) : 0); int num7 = ((num5 >= num4) ? (num4 - 1) : num5); float num8 = ((num6 == num7) ? 0f : Mathf.Clamp01((num3 - trackData.times[num6]) / Mathf.Max(1E-05f, trackData.times[num7] - trackData.times[num6]))); Vector4 val2 = trackData.values[num6]; Vector4 val3 = trackData.values[num7]; if (trackData.property == 1) { val.localRotation = Quaternion.Slerp(new Quaternion(val2.x, val2.y, val2.z, val2.w), new Quaternion(val3.x, val3.y, val3.z, val3.w), num8); continue; } Vector4 val4 = Vector4.Lerp(val2, val3, num8); if (trackData.property == 0) { val.localPosition = new Vector3(val4.x, val4.y, val4.z); } else { val.localScale = new Vector3(val4.x, val4.y, val4.z); } } if (!flag && num >= GestureLength() && (_state == "Attack" || _state == "AttackHeavy" || _state == "Roar" || _state == "RangeAttack" || _state == "TargetFound")) { _state = null; Play(_lastLocomotion); } } } internal enum EndermanCue : byte { Idle, Hurt, Angry, Death, Stare, Teleport } internal static class EndermanSounds { private static readonly Dictionary<EndermanCue, string[]> Files = new Dictionary<EndermanCue, string[]> { { EndermanCue.Idle, new string[5] { "idle1", "idle2", "idle3", "idle4", "idle5" } }, { EndermanCue.Hurt, new string[4] { "hit1", "hit2", "hit3", "hit4" } }, { EndermanCue.Angry, new string[4] { "scream1", "scream2", "scream3", "scream4" } }, { EndermanCue.Death, new string[1] { "death" } }, { EndermanCue.Stare, new string[1] { "stare" } }, { EndermanCue.Teleport, new string[2] { "portal", "portal2" } } }; private static readonly Dictionary<string, AudioClip> Loaded = new Dictionary<string, AudioClip>(StringComparer.OrdinalIgnoreCase); private static readonly HashSet<string> MissingWarned = new HashSet<string>(StringComparer.OrdinalIgnoreCase); internal static int LoadedCount => Loaded.Count; internal static IEnumerator LoadAll(string folder) { int loadedNow = 0; foreach (KeyValuePair<EndermanCue, string[]> file in Files) { string[] value = file.Value; foreach (string soundName in value) { string text = Path.Combine(folder, soundName + ".ogg"); if (!File.Exists(text)) { ManualLogSource modLogger = Plugin.ModLogger; if (modLogger != null) { modLogger.LogWarning((object)("Audio file not found: " + text)); } continue; } string absoluteUri = new Uri(Path.GetFullPath(text)).AbsoluteUri; UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(absoluteUri, (AudioType)14); try { yield return request.SendWebRequest(); if ((int)request.result != 1) { ManualLogSource modLogger2 = Plugin.ModLogger; if (modLogger2 != null) { modLogger2.LogWarning((object)("Could not load " + soundName + ": " + request.error)); } continue; } AudioClip content = DownloadHandlerAudioClip.GetContent(request); if ((Object)(object)content == (Object)null) { ManualLogSource modLogger3 = Plugin.ModLogger; if (modLogger3 != null) { modLogger3.LogWarning((object)("Empty decoded clip: " + soundName)); } } else { ((Object)content).name = "MutantEnderman_" + soundName; Loaded[soundName] = content; loadedNow++; } } finally { ((IDisposable)request)?.Dispose(); } } } ManualLogSource modLogger4 = Plugin.ModLogger; if (modLogger4 != null) { modLogger4.LogInfo((object)("Mutant Enderman: loaded " + loadedNow + "/17 OGG sounds (runtime files).")); } } private static AudioClip Pick(EndermanCue cue) { if (!Files.TryGetValue(cue, out var value) || value.Length == 0) { return null; } int num = Random.Range(0, value.Length); for (int i = 0; i < value.Length; i++) { if (Loaded.TryGetValue(value[(num + i) % value.Length], out var value2)) { return value2; } } string text = cue.ToString(); if (MissingWarned.Add(text)) { ManualLogSource modLogger = Plugin.ModLogger; if (modLogger != null) { modLogger.LogWarning((object)("No loaded sound for category " + text + ". Check Sounds folder.")); } } return null; } private static void ConfigureSpatial(AudioSource source, bool isEffect) { float num = (isEffect ? Plugin.SfxFullVolumeDistance.Value : Plugin.VoiceFullVolumeDistance.Value); float num2 = (isEffect ? Plugin.SfxMaxDistance.Value : Plugin.VoiceMaxDistance.Value); num = Mathf.Clamp(num, 1f, 200f); num2 = Mathf.Clamp(num2, num + 1f, 500f); source.spatialBlend = 1f; source.rolloffMode = (AudioRolloffMode)1; source.dopplerLevel = 0f; source.minDistance = num; source.maxDistance = num2; source.volume = 1f; } internal static void Play(EndermanCue cue, AudioSource source) { if (Plugin.SoundEnabled != null && Plugin.SoundEnabled.Value && !((Object)(object)source == (Object)null)) { AudioClip val = Pick(cue); if (!((Object)(object)val == (Object)null)) { ConfigureSpatial(source, cue == EndermanCue.Teleport || cue == EndermanCue.Death); source.PlayOneShot(val, Mathf.Clamp(Plugin.SoundVolume.Value, 0f, 2f)); } } } internal static void PlayAt(EndermanCue cue, Vector3 point, float multiplier = 1f) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown if (Plugin.SoundEnabled != null && Plugin.SoundEnabled.Value) { AudioClip val = Pick(cue); if (!((Object)(object)val == (Object)null)) { GameObject val2 = new GameObject("MutantEnderman_PointSFX"); val2.transform.position = point; AudioSource obj = val2.AddComponent<AudioSource>(); obj.playOnAwake = false; ConfigureSpatial(obj, isEffect: true); obj.PlayOneShot(val, Mathf.Clamp(Plugin.SoundVolume.Value * multiplier, 0f, 2f)); Object.Destroy((Object)val2, Mathf.Max(val.length + 0.3f, 0.5f)); } } } } internal static class EndermanTeleportParticles { private static ParticleSystem _brackenDeathEmitter; private static float _nextSourceSearchTime; private static Material _fallbackMaterial; private static bool _warnedNoShader; private static bool _hasLoggedSource; private static int _playDiagnostics; internal static void Play(Vector3 position) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (Plugin.TeleportParticlesEnabled != null && Plugin.TeleportParticlesEnabled.Value) { Burst(position, 1f, isDeath: false); } } internal static void PlayDeath(Vector3 position) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (Plugin.DeathParticlesEnabled != null && Plugin.DeathParticlesEnabled.Value) { Burst(position, 1.7f, isDeath: true); } } private unsafe static void Burst(Vector3 position, float multiplier, bool isDeath) { //IL_0039: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) float intensity = Mathf.Clamp(Plugin.TeleportParticlesIntensity.Value, 0.25f, 2f) * multiplier; try { if (Plugin.TeleportParticlesPreferBracken.Value && TryGetBrackenDeathEmitter(out var source)) { PlayCopiedBrackenDust(source, position, intensity); } PlayFallbackPurpleDust(position, intensity); EndermanPurpleSparkBurst.Create(position, intensity); if (isDeath || _playDiagnostics++ < 8) { ManualLogSource modLogger = Plugin.ModLogger; if (modLogger != null) { string obj = (isDeath ? "Death" : "Teleport"); Vector3 val = position; modLogger.LogInfo((object)(obj + " purple VFX emitted at " + ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString() + ".")); } } } catch (Exception ex) { ManualLogSource modLogger2 = Plugin.ModLogger; if (modLogger2 != null) { modLogger2.LogWarning((object)("Purple VFX failed: " + ex)); } } } private static bool TryGetBrackenDeathEmitter(out ParticleSystem source) { if ((Object)(object)_brackenDeathEmitter != (Object)null) { source = _brackenDeathEmitter; return true; } source = null; if (Time.time < _nextSourceSearchTime) { return false; } _nextSourceSearchTime = Time.time + 30f; try { FlowermanAI[] array = Resources.FindObjectsOfTypeAll<FlowermanAI>(); foreach (FlowermanAI val in array) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null) { continue; } ParticleSystem[] componentsInChildren = ((Component)val).GetComponentsInChildren<ParticleSystem>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { continue; } ParticleSystem val2 = null; int num = -1; ParticleSystem[] array2 = componentsInChildren; foreach (ParticleSystem val3 in array2) { if (!((Object)(object)val3 == (Object)null) && !((Object)(object)((Component)val3).gameObject == (Object)null) && !((Object)(object)((Component)val3).GetComponent<EnemyAI>() != (Object)null) && !((Object)(object)((Component)val3).GetComponent<NetworkObject>() != (Object)null)) { string text = ((Object)((Component)val3).gameObject).name.ToLowerInvariant(); int num2 = 0; if (text.Contains("death") || text.Contains("dying") || text.Contains("die")) { num2 += 5; } if (text.Contains("dust") || text.Contains("ash") || text.Contains("poof") || text.Contains("decompose")) { num2 += 4; } if (text.Contains("smoke") || text.Contains("disappear")) { num2 += 2; } if (componentsInChildren.Length == 1) { num2++; } if (num2 > num) { val2 = val3; num = num2; } } } if ((Object)(object)val2 == (Object)null || num <= 0) { continue; } _brackenDeathEmitter = val2; source = val2; if (!_hasLoggedSource) { ManualLogSource modLogger = Plugin.ModLogger; if (modLogger != null) { modLogger.LogInfo((object)("Teleport particles: using a PURPLE CLONE of Bracken particle emitter '" + ((Object)((Component)val2).gameObject).name + "'.")); } _hasLoggedSource = true; } return true; } } catch (Exception ex) { ManualLogSource modLogger2 = Plugin.ModLogger; if (modLogger2 != null) { modLogger2.LogWarning((object)("Bracken particle lookup unavailable: " + ex.Message)); } } return false; } private static void PlayCopiedBrackenDust(ParticleSystem original, Vector3 position, float intensity) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)original == (Object)null || (Object)(object)((Component)original).gameObject == (Object)null) { PlayFallbackPurpleDust(position, intensity); return; } GameObject val = Object.Instantiate<GameObject>(((Component)original).gameObject); ((Object)val).name = "MutantEnderman_PurpleBrackenDeathDust"; val.transform.SetParent((Transform)null, true); val.transform.position = position + Vector3.up * 0.85f; val.SetActive(true); ParticleSystem[] componentsInChildren = val.GetComponentsInChildren<ParticleSystem>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { Object.Destroy((Object)(object)val); PlayFallbackPurpleDust(position, intensity); return; } ParticleSystem[] array = componentsInChildren; foreach (ParticleSystem val2 in array) { if (!((Object)(object)val2 == (Object)null)) { ((Component)val2).gameObject.SetActive(true); MainModule main = val2.main; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).playOnAwake = false; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.5f, 1.2f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.12f, 0.35f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(1f, 3.4f); ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; EmissionModule emission = val2.emission; ((EmissionModule)(ref emission)).enabled = true; ((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.32f, 0.07f, 0.65f, 0.95f), new Color(0.84f, 0.43f, 1f, 1f)); ((MainModule)(ref main)).maxParticles = Mathf.Max(((MainModule)(ref main)).maxParticles, 96); ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(MakePurpleFade()); val2.Clear(true); val2.Play(true); val2.Emit(Mathf.Clamp(Mathf.RoundToInt(28f * intensity), 8, 80)); } } Object.Destroy((Object)(object)val, 5f); } private static Gradient MakePurpleFade() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) Gradient val = new Gradient(); val.SetKeys((GradientColorKey[])(object)new GradientColorKey[3] { new GradientColorKey(new Color(0.81f, 0.39f, 1f), 0f), new GradientColorKey(new Color(0.49f, 0.12f, 0.91f), 0.5f), new GradientColorKey(new Color(0.16f, 0.02f, 0.37f), 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[3] { new GradientAlphaKey(0.98f, 0f), new GradientAlphaKey(0.7f, 0.55f), new GradientAlphaKey(0f, 1f) }); return val; } private static void PlayFallbackPurpleDust(Vector3 position, float intensity) { //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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Expected O, but got Unknown GameObject val = new GameObject("MutantEnderman_PurpleDustFallback"); val.transform.position = position + Vector3.up * 0.85f; ParticleSystem obj = val.AddComponent<ParticleSystem>(); obj.Stop(true, (ParticleSystemStopBehavior)0); MainModule main = obj.main; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).playOnAwake = false; ((MainModule)(ref main)).duration = 0.7f; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.45f, 1.15f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.5f, 2.6f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.06f, 0.21f); ((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.32f, 0.06f, 0.75f, 0.95f), new Color(0.86f, 0.4f, 1f, 0.98f)); ((MainModule)(ref main)).maxParticles = 120; EmissionModule emission = obj.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f); ShapeModule shape = obj.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = 0.85f; ColorOverLifetimeModule colorOverLifetime = obj.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(MakePurpleFade()); SizeOverLifetimeModule sizeOverLifetime = obj.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.EaseInOut(0f, 1f, 1f, 0f)); ParticleSystemRenderer component = ((Component)obj).GetComponent<ParticleSystemRenderer>(); if ((Object)(object)component != (Object)null) { component.renderMode = (ParticleSystemRenderMode)0; Material fallbackMaterial = GetFallbackMaterial(); if ((Object)(object)fallbackMaterial != (Object)null) { ((Renderer)component).sharedMaterial = fallbackMaterial; } } obj.Play(true); obj.Emit(Mathf.Clamp(Mathf.RoundToInt(52f * intensity), 12, 110)); Object.Destroy((Object)val, 3f); } private static Material GetFallbackMaterial() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_fallbackMaterial != (Object)null) { return _fallbackMaterial; } Shader val = Shader.Find("HDRP/Unlit"); if ((Object)(object)val == (Object)null) { val = Shader.Find("HDRP/Lit"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Particles/Standard Unlit"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Sprites/Default"); } if ((Object)(object)val == (Object)null) { if (!_warnedNoShader) { _warnedNoShader = true; ManualLogSource modLogger = Plugin.ModLogger; if (modLogger != null) { modLogger.LogWarning((object)"No compatible particle shader found; fallback dust may be invisible."); } } return null; } _fallbackMaterial = new Material(val); ((Object)_fallbackMaterial).name = "MutantEnderman_PurpleTeleportDustMaterial"; if (_fallbackMaterial.HasProperty("_BaseColor")) { _fallbackMaterial.SetColor("_BaseColor", new Color(0.73f, 0.22f, 1f, 1f)); } if (_fallbackMaterial.HasProperty("_Color")) { _fallbackMaterial.SetColor("_Color", new Color(0.73f, 0.22f, 1f, 1f)); } return _fallbackMaterial; } } public sealed class MutantEndermanAI : EnemyAI { private static readonly Dictionary<string, List<int>> MoonOrders = new Dictionary<string, List<int>>(); private readonly Dictionary<int, int> _successfulTeleports = new Dictionary<int, int>(); private readonly Dictionary<int, int> _teleportsAfterAttack = new Dictionary<int, int>(); private List<int> _orderedPlayers; private int _orderIndex = -1; private int _victimIndex = -1; private int _priorityAttacker = -1; private int _gazeProvoker = -1; private int _angerTargetIndex = -1; private float _roarUntil; private float _nextFearPulse; private static MethodInfo _fearMethod; private static bool _fearMethodSearched; private bool _holding; private float _releaseTime; private float _nextRetarget; private float _nextPathUpdate; private float _nextApproachTeleportTime; private int _chainBlinksLeft; private int _chainTargetIndex = -1; private bool _waitingBetweenHunts; private float _nextHuntTime; private float _nextRestTeleportTime; private float _nextRestWanderTime; private bool _counterAttacking; private int _counterTargetIndex = -1; private int _counterHitsDone; private float _nextCounterHitTime; private bool _isWalking; private bool _isProvoked; private bool _localFrozen; private float _eyeContactTime; private float _nextGazeTime; private float _nextGazeNotify; private Random _random; private bool _initialized; private bool _initialSearch; private float _nextSearchScan; private float _nextSearchPatrol; private float _searchStartedAt; private float _clientRoarUntil; private int _clientRoarTarget = -1; private float _nextIdleSoundTime; private float _nextStareSoundTime; private bool _deathSoundEmitted; private bool _deathVisualEmitted; private bool _deathRpcSent; private bool _insideZone = true; private GameObject[] _insideNodes = (GameObject[])(object)new GameObject[0]; private GameObject[] _outsideNodes = (GameObject[])(object)new GameObject[0]; private bool _pendingPostCaptureEscape; private float _postCaptureEscapeAt; private Vector3 _localGrabGroundPosition; private Vector3 _localGrabStartingPosition; private float _localGrabStartTime; private int _localGrabbedIndex = -1; public override void Start() { ((EnemyAI)this).Start(); if (!((NetworkBehaviour)this).IsServer) { return; } if (!Plugin.TryClaimLiveSpawn(this)) { ManualLogSource modLogger = Plugin.ModLogger; if (modLogger != null) { modLogger.LogInfo((object)"Extra Mutant Enderman spawn suppressed: another one is already ALIVE. No second live instance is allowed."); } ((EnemyAI)this).KillEnemy(true); NetworkObject component = ((Component)this).GetComponent<NetworkObject>(); if ((Object)(object)component != (Object)null && component.IsSpawned) { component.Despawn(true); } } else { CacheAINodesAndResolveZone(); _random = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex * 1679 + ((!_insideZone) ? 43 : 0)); _orderedPlayers = GetShuffledPlayersForCurrentMoon(); base.enemyHP = Math.Max(1, Plugin.HitPoints.Value); _initialized = true; _nextApproachTeleportTime = Time.time + 3f; ScheduleNextIdleSound(); _initialSearch = true; _searchStartedAt = Time.time; _nextSearchScan = Time.time; _nextSearchPatrol = 0f; Plugin.DebugLog("Initial Bracken-style search: roaming for a player before the first capture."); } } public override void Update() { //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).Update(); if (!((NetworkBehaviour)this).IsSpawned || base.isEnemyDead) { return; } DetectLocalEyeContact(); UpdateLocalFear(); UpdateLocalLift(); if (!((NetworkBehaviour)this).IsServer || !_initialized || (Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.inShipPhase) { return; } if (_roarUntil > 0f) { if (Time.time < _roarUntil) { if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.isStopped = true; } FaceAngerTarget(); return; } _roarUntil = 0f; _nextApproachTeleportTime = Time.time + 0.25f; _nextPathUpdate = 0f; Plugin.DebugLog("Anger roar finished: faster chase and short-hop teleports now enabled."); } if (Time.time >= _nextIdleSoundTime) { ScheduleNextIdleSound(); if (!_holding && !_counterAttacking && !_isProvoked) { EmitCueClientRpc(0); } } if (_counterAttacking) { UpdateCounterattack(); return; } if (_holding) { if (Time.time >= _releaseTime || !IsAvailable(_victimIndex, checkZone: false)) { FinishCapture(); } return; } if (_pendingPostCaptureEscape) { if (Time.time < _postCaptureEscapeAt) { return; } _pendingPostCaptureEscape = false; if (TryFindTeleportDestination(((Component)this).transform.position, out var destination, 22f) && WarpEnderman(destination)) { Plugin.DebugLog("Post-capture Enderman escaped alone to a distant floor."); } else { Plugin.DebugLog("Post-capture escape skipped: no safe floor found. Will try again while roaming."); } } if (_waitingBetweenHunts) { if (Time.time < _nextHuntTime) { UpdateRestWandering(); return; } _waitingBetweenHunts = false; _nextHuntTime = 0f; _nextRestTeleportTime = 0f; _nextRestWanderTime = 0f; Plugin.DebugLog("Phase 3 finished. Selecting next target."); SelectNextTarget(); } if (_initialSearch) { UpdateFirstSearch(); return; } if (_priorityAttacker >= 0 && _victimIndex != _priorityAttacker && IsAvailable(_priorityAttacker, checkZone: true)) { SelectNextTarget(); } if (!IsAvailable(_victimIndex, checkZone: true)) { if (Time.time >= _nextRetarget) { SelectNextTarget(); } return; } PlayerControllerB player = GetPlayer(_victimIndex); if ((Object)(object)player == (Object)null) { return; } float distance = Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position); if (distance > Math.Max(5f, Plugin.DetectionDistance.Value) && _victimIndex != _priorityAttacker && _victimIndex != _angerTargetIndex) { if (Time.time >= _nextRetarget) { SelectNextTarget(); } return; } UpdateChaseBlink(player, ref distance); float val = (_isProvoked ? Plugin.ProvokedSpeed.Value : Plugin.StalkSpeed.Value); if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.speed = Math.Max(0.2f, val); if (Time.time >= _nextPathUpdate) { _nextPathUpdate = Time.time + 0.3f; base.agent.isStopped = false; ((EnemyAI)this).SetDestinationToPosition(((Component)player).transform.position, false); } } SetWalkingState(walking: true); if (distance <= Math.Max(0.7f, Plugin.GrabDistance.Value)) { StartCapture(_victimIndex); } } private void UpdateChaseBlink(PlayerControllerB player, ref float distance) { //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.ApproachTeleportEnabled.Value || (Object)(object)player == (Object)null) { CancelChaseBlinkChain(); return; } if (_chainBlinksLeft > 0 && _chainTargetIndex != _victimIndex) { CancelChaseBlinkChain(); } if (Time.time < _nextApproachTeleportTime) { return; } float num = Mathf.Clamp(Plugin.ApproachTeleportRadius.Value, 4.8f, 15f); float num2 = Mathf.Clamp(Plugin.ApproachTeleportCooldown.Value, 3f, 120f); if (_chainBlinksLeft > 0) { if (distance <= num + 3f) { CancelChaseBlinkChain(); _nextApproachTeleportTime = Time.time + num2; return; } bool flag = distance <= num + Mathf.Clamp(Plugin.ChaseBlinkStepDistance.Value, 4f, 15f) + 2f; Vector3 destination; bool flag2 = (flag ? TryFindApproachDestination(player, out destination) : TryFindChaseStepDestination(player, out destination)); if (!flag2 && !flag) { flag2 = TryFindApproachDestination(player, out destination); } if (!flag2 || !WarpEnderman(destination)) { Plugin.DebugLog("Short chase blink cancelled: no validated floor between Enderman and target."); CancelChaseBlinkChain(); _nextApproachTeleportTime = Time.time + num2; return; } distance = Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position); _chainBlinksLeft--; Plugin.DebugLog("Short blink reached " + distance.ToString("0.#") + "m from player=" + _victimIndex + "; hops left=" + _chainBlinksLeft); if (flag || distance <= num + 3f || _chainBlinksLeft <= 0) { CancelChaseBlinkChain(); _nextApproachTeleportTime = Time.time + num2; } else { _nextApproachTeleportTime = Time.time + Mathf.Clamp(Plugin.ChaseBlinkStepInterval.Value, 0.5f, 3.5f); } } else { if (distance < Mathf.Max(8.5f, Plugin.ApproachTeleportMinChaseDistance.Value)) { return; } if (Plugin.ChaseBlinkChainEnabled.Value && _random != null && distance >= Mathf.Max(17f, num + Plugin.ChaseBlinkStepDistance.Value * 1.1f) && _random.NextDouble() < (double)Mathf.Clamp01(Plugin.ChaseBlinkChainChance.Value)) { _chainTargetIndex = _victimIndex; _chainBlinksLeft = Mathf.Clamp(Plugin.ChaseBlinkMaxSteps.Value, 2, 20); _nextApproachTeleportTime = Time.time; Plugin.DebugLog("Started short-blink chain toward player=" + _victimIndex + ", up to " + _chainBlinksLeft + " hops."); UpdateChaseBlink(player, ref distance); } else { _nextApproachTeleportTime = Time.time + num2; if (TryFindApproachDestination(player, out var destination2) && WarpEnderman(destination2)) { distance = Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position); Plugin.DebugLog("Direct chase blink landed " + distance.ToString("0.#") + "m from player=" + _victimIndex + "."); } else { Plugin.DebugLog("Direct chase blink skipped: no safe floor near target."); } } } } private void CancelChaseBlinkChain() { _chainBlinksLeft = 0; _chainTargetIndex = -1; } private void LateUpdate() { //IL_0051: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) if (_localFrozen && !base.isEnemyDead) { UpdateLocalLift(); } if (base.isEnemyDead || Time.time >= _clientRoarUntil) { return; } PlayerControllerB player = GetPlayer(_clientRoarTarget); if (!((Object)(object)player == (Object)null) && !player.isPlayerDead) { Vector3 val = ((Component)player).transform.position - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.1f) { ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, Quaternion.LookRotation(val), 620f * Time.deltaTime); } } } private void ScheduleNextIdleSound() { float num = Mathf.Clamp(Plugin.IdleSoundMinInterval.Value, 1f, 300f); float num2 = Mathf.Clamp(Plugin.IdleSoundMaxInterval.Value, num, 300f); _nextIdleSoundTime = Time.time + Random.Range(num, num2); } [ClientRpc] private void EmitCueClientRpc(byte cue) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: 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) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1319170586u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref cue, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1319170586u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; byte num = cue; EndermanSounds.Play((EndermanCue)num, (num == 5) ? base.creatureSFX : base.creatureVoice); } } } [ClientRpc] private void EmitTeleportClientRpc(Vector3 from, Vector3 to) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(665492886u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe(ref from); ((FastBufferWriter)(ref val)).WriteValueSafe(ref to); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 665492886u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; EndermanSounds.PlayAt(EndermanCue.Teleport, from); EndermanTeleportParticles.Play(from); if (Vector3.Distance(from, to) > 0.4f) { EndermanSounds.PlayAt(EndermanCue.Teleport, to); EndermanTeleportParticles.Play(to); } } } private PlayerControllerB GetPlayer(int index) { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.allPlayerScripts == null || index < 0 || index >= instance.allPlayerScripts.Length) { return null; } return instance.allPlayerScripts[index]; } private bool IsAvailable(int index, bool checkZone) { PlayerControllerB player = GetPlayer(index); if ((Object)(object)player == (Object)null || !player.isPlayerControlled || player.isPlayerDead) { return false; } if (checkZone) { if (player.isInsideFactory != _insideZone) { return false; } if (!_insideZone && !Plugin.AllowExteriorTeleport.Value) { return false; } if (player.inSpecialInteractAnimation) { return false; } } return true; } private List<int> GetShuffledPlayersForCurrentMoon() { StartOfRound instance = StartOfRound.Instance; string key = instance.randomMapSeed + ":" + instance.currentLevelID; if (!MoonOrders.TryGetValue(key, out var value)) { value = Enumerable.Range(0, instance.allPlayerScripts.Length).ToList(); Random random = new Random(instance.randomMapSeed ^ (instance.currentLevelID * 4049)); for (int num = value.Count - 1; num > 0; num--) { int index = random.Next(num + 1); int value2 = value[index]; value[index] = value[num]; value[num] = value2; } MoonOrders[key] = value; if (MoonOrders.Count > 16) { MoonOrders.Clear(); } } return new List<int>(value); } private void UpdateFirstSearch() { //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_0093: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)this).IsServer || !_initialSearch || _random == null) { return; } if (Time.time >= _nextSearchScan) { _nextSearchScan = Time.time + 0.35f; PlayerControllerB[] array = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.allPlayerScripts : null); int num = -1; float num2 = float.PositiveInfinity; if (array != null) { for (int i = 0; i < array.Length; i++) { if (IsAvailable(i, checkZone: true)) { Vector3 val = ((Component)array[i]).transform.position + Vector3.up * 1.35f; float num3 = Vector3.Distance(((Component)this).transform.position, val); if (!(num3 >= num2) && !(num3 > Mathf.Clamp(Plugin.SearchNoticeRange.Value, 8f, 90f)) && HasClearView(((Component)this).transform.position + Vector3.up * 1.8f, val)) { num = i; num2 = num3; } } } } if (num >= 0) { _initialSearch = false; _victimIndex = num; base.targetPlayer = GetPlayer(num); _isProvoked = false; _nextApproachTeleportTime = Time.time + 1.25f; Plugin.DebugLog("Initial search acquired visible player=" + num + " at " + num2.ToString("0.#") + "m."); PlayAnimationClientRpc("TargetFound"); return; } if (Time.time - _searchStartedAt > 28f) { if (array != null) { for (int j = 0; j < array.Length; j++) { if (IsAvailable(j, checkZone: true)) { float num4 = Vector3.Distance(((Component)this).transform.position, ((Component)array[j]).transform.position); if (!(num4 >= num2) && !(num4 > Mathf.Clamp(Plugin.SearchNoticeRange.Value * 1.8f, 15f, 150f))) { num = j; num2 = num4; } } } } if (num >= 0) { _initialSearch = false; _victimIndex = num; base.targetPlayer = GetPlayer(num); _nextApproachTeleportTime = Time.time + 1f; Plugin.DebugLog("Extended search heard/located player=" + num + "."); return; } } } if (!((Object)(object)base.agent != (Object)null) || !((Behaviour)base.agent).enabled || !base.agent.isOnNavMesh) { return; } base.agent.speed = Mathf.Max(0.3f, Plugin.StalkSpeed.Value * 0.75f); if (Time.time >= _nextSearchPatrol || (!base.agent.pathPending && (!base.agent.hasPath || base.agent.remainingDistance < 1.8f))) { _nextSearchPatrol = Time.time + Random.Range(3f, 7f); if (TryFindRestWanderDestination(out var destination)) { base.agent.isStopped = false; ((EnemyAI)this).SetDestinationToPosition(destination, false); } } SetWalkingState(!base.agent.isStopped && base.agent.hasPath); } private void SelectNextTarget() { int victimIndex = _victimIndex; _nextRetarget = Time.time + 2f; _initialSearch = false; if (_orderedPlayers == null || _orderedPlayers.Count == 0) { return; } bool flag = _priorityAttacker >= 0 && IsAvailable(_priorityAttacker, checkZone: true); bool flag2 = !flag && _gazeProvoker >= 0 && IsAvailable(_gazeProvoker, checkZone: true); if (flag) { _victimIndex = _priorityAttacker; } else if (flag2) { _victimIndex = _gazeProvoker; _gazeProvoker = -1; } else { _victimIndex = -1; for (int i = 0; i < _orderedPlayers.Count; i++) { _orderIndex = (_orderIndex + 1) % _orderedPlayers.Count; if (IsAvailable(_orderedPlayers[_orderIndex], checkZone: true)) { _victimIndex = _orderedPlayers[_orderIndex]; break; } } } if (victimIndex != _victimIndex) { CancelChaseBlinkChain(); } _isProvoked = flag || flag2 || _victimIndex == _angerTargetIndex; if (_victimIndex >= 0) { base.targetPlayer = GetPlayer(_victimIndex); Plugin.DebugLog("Next target player index=" + _victimIndex + (flag ? " (retaliation priority)" : (flag2 ? " (eye contact)" : " (shuffled order)"))); return; } base.targetPlayer = null; SetWalkingState(walking: false); if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.isStopped = true; } } private void StartCapture(int index) { if (!_holding && !_waitingBetweenHunts && !_pendingPostCaptureEscape && IsAvailable(index, checkZone: true)) { _holding = true; CancelChaseBlinkChain(); _victimIndex = index; _releaseTime = Time.time + Mathf.Clamp(Plugin.HoldSeconds.Value, 0.5f, 60f); if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.isStopped = true; } SetWalkingState(walking: false); PlayAnimationClientRpc("Grab"); EmitCueClientRpc(4); ToggleHoldClientRpc(index, enable: true); Plugin.DebugLog("Grabbed player=" + index + ", duration=" + Plugin.HoldSeconds.Value); } } private void FinishCapture() { //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) if (!_holding) { return; } int victimIndex = _victimIndex; _holding = false; PlayerControllerB player = GetPlayer(victimIndex); if ((Object)(object)player == (Object)null || player.isPlayerDead || !player.isPlayerControlled) { ToggleHoldClientRpc(victimIndex, enable: false); if (_priorityAttacker == victimIndex) { _priorityAttacker = -1; } SelectNextTarget(); return; } int value; int num = (_successfulTeleports.TryGetValue(victimIndex, out value) ? value : 0); int num2 = Math.Max(0, Plugin.TeleportsBeforeKill.Value); int value2; bool flag = _teleportsAfterAttack.TryGetValue(victimIndex, out value2); int num3 = Math.Max(0, Plugin.TeleportsAfterAttackBeforeKill.Value); bool flag2 = num >= num2; bool flag3 = flag && value2 >= num3; bool flag4 = false; if (flag2 || flag3) { flag4 = true; EmitCueClientRpc(2); PlayAnimationClientRpc("AttackHeavy"); ResolveCaptureClientRpc(victimIndex, kill: true, Vector3.zero); Plugin.DebugLog("Lethal capture player=" + victimIndex + ", total teleports=" + num + ", since attack=" + (flag ? value2.ToString() : "not attacked") + ", reason=" + (flag2 ? "normal limit" : "retaliation limit")); if (_priorityAttacker == victimIndex) { _priorityAttacker = -1; } } else { Vector3 destination = ((Component)this).transform.position; float num4 = Mathf.Clamp01(Plugin.CrossZoneChance.Value); bool flag5 = _random != null && _random.NextDouble() < (double)num4 && TryFindOppositeZoneDestination(((Component)player).transform.position, out destination); bool flag6 = false; int num5 = 0; if (!flag5) { for (int i = 1; i <= 3; i++) { if (TryFindTeleportDestination(((Component)player).transform.position, out destination)) { flag6 = true; break; } num5++; Plugin.DebugLog("Same-zone capture destination search " + i + "/" + 3 + " failed."); } } bool flag7 = false; if (!flag5 && !flag6 && num5 == 3 && Plugin.ShipFallbackEnabled.Value) { flag7 = TryFindShipFallbackDestination(out destination); ManualLogSource modLogger = Plugin.ModLogger; if (modLogger != null) { modLogger.LogInfo((object)(flag7 ? "[MutantEnderman Teleport] EMERGENCY SURFACE FALLBACK selected after 3 failed same-zone searches (not the cross-zone probability)." : "[MutantEnderman Teleport] All 3 same-zone searches failed; emergency surface position was also unsafe/unavailable.")); } } bool num6 = flag5 || flag6; if (flag5) { ManualLogSource modLogger2 = Plugin.ModLogger; if (modLogger2 != null) { modLogger2.LogInfo((object)("[MutantEnderman Teleport] CROSS-ZONE RANDOM ROLL succeeded; configured probability=" + num4 + ".")); } } if ((num6 || flag7) && WarpEnderman(destination)) { flag4 = true; _successfulTeleports[victimIndex] = num + 1; if (flag) { _teleportsAfterAttack[victimIndex] = value2 + 1; } bool flag8 = (flag5 ? (!_insideZone) : (!flag7 && _insideZone)); bool flag9 = flag8 != _insideZone; ResolveCaptureClientRpc(victimIndex, kill: false, destination, flag9, flag8); if (flag9) { _insideZone = flag8; base.isOutside = !flag8; player.isInsideFactory = flag8; player.isInElevator = false; player.isInHangarShipRoom = false; ManualLogSource modLogger3 = Plugin.ModLogger; if (modLogger3 != null) { modLogger3.LogInfo((object)("Mutant Enderman carried player between zones: " + (flag8 ? "EXTERIOR -> FACILITY" : "FACILITY -> EXTERIOR") + (flag5 ? " (CROSS-ZONE RANDOM ROLL)." : " (EMERGENCY SURFACE FALLBACK AFTER 3 FAILED SAME-ZONE SEARCHES)."))); } } _pendingPostCaptureEscape = true; _postCaptureEscapeAt = Time.time + Mathf.Clamp(Plugin.PostCaptureEscapeDelay.Value, 0.25f, 8f); Plugin.DebugLog((flag7 ? "Ship fallback carried" : "Teleported") + " player=" + victimIndex + ", total=" + _successfulTeleports[victimIndex] + "/" + num2 + (flag ? (", after attack=" + _teleportsAfterAttack[victimIndex] + "/" + num3) : "")); } else { ToggleHoldClientRpc(victimIndex, enable: false); Plugin.DebugLog("No validated teleport destination (including 3 same-zone searches and emergency surface fallback). Player released; counters unchanged."); } } if (!_pendingPostCaptureEscape) { PlayAnimationClientRpc("Idle"); } float seconds = (flag4 ? Plugin.HuntCooldownSeconds.Value : 2f); BeginHuntCooldown(seconds); } private void BeginHuntCooldown(float seconds) { CancelChaseBlinkChain(); _nextApproachTeleportTime = Time.time + 2f; float num = Mathf.Clamp(seconds, 0f, 7200f); _victimIndex = -1; base.targetPlayer = null; _isProvoked = false; _initialSearch = false; _roarUntil = 0f; _angerTargetIndex = -1; _nextPathUpdate = 0f; _nextRestWanderTime = 0f; _nextRestTeleportTime = 0f; SetWalkingState(walking: false); if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.isStopped = true; base.agent.ResetPath(); } if (num <= 0f) { _waitingBetweenHunts = false; _nextHuntTime = 0f; SelectNextTarget(); } else { _waitingBetweenHunts = true; _nextHuntTime = Time.time + num; _nextRestTeleportTime = Time.time + ChooseRestTeleportDelay(); Plugin.DebugLog("Phase 3: roaming for " + num.ToString("0.##") + "s before next hunt (unless attacked). Random self-teleports active. Priority=" + _priorityAttacker); } } private float ChooseRestTeleportDelay() { float num = Mathf.Clamp(Plugin.RestTeleportMinInterval.Value, 1f, 600f); float num2 = Mathf.Clamp(Plugin.RestTeleportMaxInterval.Value, num, 600f); return Mathf.Lerp(num, num2, (float)_random.NextDouble()); } private void UpdateRestWandering() { //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) if (_random == null) { return; } if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.speed = Mathf.Max(0.2f, Plugin.StalkSpeed.Value * 0.65f); if (Time.time >= _nextRestWanderTime || !base.agent.hasPath || (!base.agent.pathPending && base.agent.remainingDistance < 1.6f)) { _nextRestWanderTime = Time.time + Mathf.Lerp(3f, 7f, (float)_random.NextDouble()); if (TryFindRestWanderDestination(out var destination)) { base.agent.isStopped = false; ((EnemyAI)this).SetDestinationToPosition(destination, false); } } SetWalkingState(!base.agent.isStopped && base.agent.hasPath); } else { SetWalkingState(walking: false); } if (!(Time.time < _nextRestTeleportTime)) { _nextRestTeleportTime = Time.time + ChooseRestTeleportDelay(); if (TryFindTeleportDestination(((Component)this).transform.position, out var destination2, 12f) && WarpEnderman(destination2)) { Plugin.DebugLog("Phase 3 random self-teleport; next in " + (_nextRestTeleportTime - Time.time).ToString("0.#") + "s."); } else { Plugin.DebugLog("Phase 3 random teleport skipped: no safe NavMesh point."); } } } private bool TryFindRestWanderDestination(out Vector3 destination) { //IL_0007: 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) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) destination = ((Component)this).transform.position; if (_random == null || (Object)(object)base.agent == (Object)null || !base.agent.isOnNavMesh) { return false; } NavMeshHit val = default(NavMeshHit); for (int i = 0; i < 24; i++) { float num = (float)(_random.NextDouble() * Math.PI * 2.0); float num2 = Mathf.Lerp(4f, 14f, (float)_random.NextDouble()); if (NavMesh.SamplePosition(((Component)this).transform.position + new Vector3(Mathf.Cos(num) * num2, 0f, Mathf.Sin(num) * num2), ref val, 3f, base.agent.areaMask) && !(Mathf.Abs(((NavMeshHit)(ref val)).position.y - ((Component)this).transform.position.y) > 6f)) { NavMeshPath val2 = new NavMeshPath(); if (base.agent.CalculatePath(((NavMeshHit)(ref val)).position, val2) && (int)val2.status == 0) { destination = ((NavMeshHit)(ref val)).position; return true; } } } return false; } private bool WarpEnderman(Vector3 position) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.agent == (Object)null || !((Behaviour)base.agent).enabled) { return false; } NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(position, ref val, 1f, base.agent.areaMask)) { return false; } if (!IsSafeFloorPosition(((NavMeshHit)(ref val)).position, forEnderman: true)) { return false; } Vector3 position2 = ((Component)this).transform.position; if (base.agent.isOnNavMesh) { base.agent.ResetPath(); } if (!base.agent.Warp(((NavMeshHit)(ref val)).position)) { Plugin.DebugLog("Enemy Warp rejected by NavMeshAgent; no movement occurred."); return false; } EmitTeleportClientRpc(position2, ((NavMeshHit)(ref val)).position); _nextPathUpdate = 0f; _nextRestWanderTime = 0f; SetWalkingState(walking: false); PlayAnimationClientRpc("RangeAttack"); WarpEndermanClientRpc(((NavMeshHit)(ref val)).position); return true; } [ClientRpc] private void WarpEndermanClientRpc(Vector3 position) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1042414285u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe(ref position); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1042414285u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (!((NetworkBehaviour)this).IsServer) { if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.ResetPath(); base.agent.Warp(position); } else { ((Component)this).transform.position = position; } } } private void InterruptCaptureForCounterattack(int attackerIndex) { if (_holding && !_counterAttacking) { int victimIndex = _victimIndex; _holding = false; _victimIndex = -1; _releaseTime = 0f; base.targetPlayer = null; ToggleHoldClientRpc(victimIndex, enable: false); if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.isStopped = true; base.agent.ResetPath(); } SetWalkingState(walking: false); _counterAttacking = true; EmitCueClientRpc(2); _counterTargetIndex = attackerIndex; _counterHitsDone = 0; _nextCounterHitTime = Time.time + 0.25f; Plugin.DebugLog("Grab of player=" + victimIndex + " cancelled by attacker=" + attackerIndex + ". Two 35-damage counterstrikes queued."); } } private void UpdateCounterattack() { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) if (Time.time < _nextCounterHitTime) { return; } int counterTargetIndex = _counterTargetIndex; PlayerControllerB player = GetPlayer(counterTargetIndex); if ((Object)(object)player != (Object)null && player.isPlayerControlled && !player.isPlayerDead) { PlayAnimationClientRpc((_counterHitsDone == 0) ? "Attack" : "AttackHeavy"); CounterStrikeClientRpc(counterTargetIndex, Mathf.Clamp(Plugin.CounterAttackDamage.Value, 0, 999)); Plugin.DebugLog("Counterstrike " + (_counterHitsDone + 1) + "/2 sent to player=" + counterTargetIndex + "."); } _counterHitsDone++; if (_counterHitsDone < 2) { _nextCounterHitTime = Time.time + 0.7f; return; } _counterAttacking = false; _counterTargetIndex = -1; if (TryFindFleeDestination(counterTargetIndex, out var destination) && WarpEnderman(destination)) { Plugin.DebugLog("Counterattack flee was successful."); } else { Plugin.DebugLog("Counterattack flee teleport: no safe destination; starting double cooldown anyway."); } BeginHuntCooldown(Mathf.Clamp(Plugin.HuntCooldownSeconds.Value, 0f, 3600f) * 2f); Plugin.DebugLog("Counterattack completed. Phase 3 duration x2. Priority=" + _priorityAttacker); } private bool TryFindFleeDestination(int attackerIndex, out Vector3 destination) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return TryFindTeleportDestination(((Component)this).transform.position, out destination, 22f); } [ClientRpc] private void CounterStrikeClientRpc(int playerIndex, int damage) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2050192812u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, playerIndex); BytePacker.WriteValueBitPacked(val, damage); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2050192812u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; GameNetworkManager instance = GameNetworkManager.Instance; PlayerControllerB val3 = (((Object)(object)instance != (Object)null) ? instance.localPlayerController : null); if (!((Object)(object)val3 == (Object)null) && (int)val3.playerClientId == playerIndex && !val3.isPlayerDead) { val3.DamagePlayer(damage, true, true, (CauseOfDeath)0, 0, false, default(Vector3)); } } } private static GameObject[] FindNodes(string tag) { try { return GameObject.FindGameObjectsWithTag(tag); } catch (UnityException) { return (GameObject[])(object)new GameObject[0]; } } private static float NearestNodeDistance(Vector3 origin, GameObject[] nodes) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_002b: Unknown result type (might be due to invalid IL or missing references) float num = float.PositiveInfinity; foreach (GameObject val in nodes) { if ((Object)(object)val != (Object)null) { float num2 = num; Vector3 val2 = val.transform.position - origin; num = Mathf.Min(num2, ((Vector3)(ref val2)).sqrMagnitude); } } return num; } private void CacheAINodesAndResolveZone() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) _insideNodes = FindNodes("AINode"); _outsideNodes = FindNodes("OutsideAINode"); float num = NearestNodeDistance(((Component)this).transform.position, _insideNodes); float num2 = NearestNodeDistance(((Component)this).transform.position, _outsideNodes); if (!float.IsPositiveInfinity(num) || !float.IsPositiveInfinity(num2)) { _insideZone = num <= num2; } else { _insideZone = !base.enemyType.isOutsideEnemy; } Plugin.DebugLog("Spawn region=" + (_insideZone ? "facility" : "exterior") + ", inside nodes=" + _insideNodes.Length + ", outside nodes=" + _outsideNodes.Length); } private bool IsSafeFloorPosition(Vector3 point, bool forEnderman) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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) //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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (!Physics.Raycast(point + Vector3.up * 1.4f, Vector3.down, ref val, 2.6f, -5, (QueryTriggerInteraction)1)) { return false; } Collider collider = ((RaycastHit)(ref val)).collider; if ((Object)(object)collider == (Object)null || collider.isTrigger || (Object)(object)collider.attachedRigidbody != (Object)null) { return false; } if (((RaycastHit)(ref val)).normal.y < 0.87f || Mathf.Abs(((RaycastHit)(ref val)).point.y - point.y) > 0.32f) { return false; } if ((Object)(object)((Component)collider).GetComponentInParent<GrabbableObject>() != (Object)null) { return false; } string text = LayerMask.LayerToName(((Component)collider).gameObject.layer); if (text.IndexOf("Prop", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Enemy", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Player", StringComparison.OrdinalIgnoreCase) >= 0) { return false; } Bounds bounds = collider.bounds; if (((Bounds)(ref bounds)).size.x < 1.15f) { bounds = collider.bounds; if (((Bounds)(ref bounds)).size.z < 1.15f) { return false; } } NavMeshHit val2 = default(NavMeshHit); if (!NavMesh.FindClosestEdge(point, ref val2, -1) || ((NavMeshHit)(ref val2)).distance < 0.8f) { return false; } float num = (forEnderman ? 2.8f : 1.95f); if (Physics.CheckCapsule(point + Vector3.up * 0.5f, point + Vector3.up * num, 0.34f, -5, (QueryTriggerInteraction)1)) { return false; } return true; } private bool IsFarFromPlayers(Vector3 candidate, int exemptIndex, float clearance, out float nearest) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) nearest = float.PositiveInfinity; StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.allPlayerScripts == null) { return false; } for (int i = 0; i < instance.allPlayerScripts.Length; i++) { if (i == exemptIndex) { continue; } PlayerControllerB val = instance.allPlayerScripts[i]; if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && !val.isPlayerDead) { float num = Vector3.Distance(candidate, ((Component)val).transform.position); nearest = Mathf.Min(nearest, num); if (num < clearance) { return false; } } } return true; } private bool TryFindTeleportDestination(Vector3 currentPosition, out Vector3 destination, float minimumOverride = -1f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) destination = currentPosition; if (_random == null) { return false; } GameObject[] array = (_insideZone ? _insideNodes : _outsideNodes); if (array == null || array.Length == 0) { CacheAINodesAndResolveZone(); array