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 TemerskieModLethal v1.0.5
TemerskieModLethal.dll
Decompiled 2 months 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.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Linq; using PathfindingLib.API.SmartPathfinding; using PathfindingLib.Utilities; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TemerskieModLethal")] [assembly: AssemblyConfiguration("production")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TemerskieModLethal")] [assembly: AssemblyTitle("TemerskieModLethal")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace TemerskieModLethal { internal static class AssetBundleLoader { private static AssetBundle? _bundle; internal static GameObject? TemerskieFlaskPrefab { get; private set; } internal static GameObject? BottlesCratePrefab { get; private set; } internal static GameObject? ZmoraPrefab { get; private set; } internal static bool IsLoaded => (Object)(object)_bundle != (Object)null; internal static bool TryLoad() { //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_bundle != (Object)null) { return true; } string pluginDir = TemerskieMod._pluginDir; if (pluginDir == null) { return false; } string text = Path.Combine(pluginDir, "temerskiemod"); if (!File.Exists(text)) { ManualLogSource? log = TemerskieMod._log; if (log != null) { log.LogInfo((object)"AssetBundle 'temerskiemod' not found, will use procedural generation"); } return false; } try { _bundle = AssetBundle.LoadFromFile(text); if ((Object)(object)_bundle == (Object)null) { ManualLogSource? log2 = TemerskieMod._log; if (log2 != null) { log2.LogWarning((object)"Failed to load AssetBundle (LoadFromFile returned null)"); } return false; } TemerskieFlaskPrefab = _bundle.LoadAsset<GameObject>("TemerskieScrap"); BottlesCratePrefab = _bundle.LoadAsset<GameObject>("BottlesOfTemerskieScrap"); ZmoraPrefab = _bundle.LoadAsset<GameObject>("ZmoraEnemy"); ManualLogSource? log3 = TemerskieMod._log; if (log3 != null) { log3.LogInfo((object)$"AssetBundle loaded: flask={(Object)(object)TemerskieFlaskPrefab != (Object)null} bottles={(Object)(object)BottlesCratePrefab != (Object)null} zmora={(Object)(object)ZmoraPrefab != (Object)null}"); } if ((Object)(object)TemerskieFlaskPrefab != (Object)null) { ManualLogSource? log4 = TemerskieMod._log; if (log4 != null) { log4.LogInfo((object)$" Flask scale={TemerskieFlaskPrefab.transform.localScale} children={TemerskieFlaskPrefab.transform.childCount}"); } } if ((Object)(object)BottlesCratePrefab != (Object)null) { ManualLogSource? log5 = TemerskieMod._log; if (log5 != null) { log5.LogInfo((object)$" Bottles scale={BottlesCratePrefab.transform.localScale} children={BottlesCratePrefab.transform.childCount}"); } } if ((Object)(object)ZmoraPrefab != (Object)null) { ManualLogSource? log6 = TemerskieMod._log; if (log6 != null) { log6.LogInfo((object)$" Zmora children={ZmoraPrefab.transform.childCount}"); } } return true; } catch (Exception ex) { ManualLogSource? log7 = TemerskieMod._log; if (log7 != null) { log7.LogError((object)("AssetBundle load failed: " + ex.Message)); } _bundle = null; return false; } } internal static GameObject? InstantiatePrefab(GameObject? bundlePrefab, string name) { if ((Object)(object)bundlePrefab == (Object)null) { return null; } GameObject val = Object.Instantiate<GameObject>(bundlePrefab); ((Object)val).name = name; Object.DontDestroyOnLoad((Object)(object)val); if ((Object)(object)val.GetComponent<NetworkObject>() == (Object)null) { val.AddComponent<NetworkObject>().SynchronizeTransform = true; } NetworkPrefabs.RegisterNetworkPrefab(val); return val; } internal static void EnsureShaders() { if ((Object)(object)_bundle == (Object)null) { return; } MeshRenderer[] array = Object.FindObjectsOfType<MeshRenderer>(); Shader shader = Shader.Find("HDRP/Lit") ?? Shader.Find("Standard"); MeshRenderer[] array2 = array; foreach (MeshRenderer val in array2) { if (!((Object)(object)((Renderer)val).sharedMaterial == (Object)null) && ((Object)(object)((Renderer)val).sharedMaterial.shader == (Object)null || ((Object)((Renderer)val).sharedMaterial.shader).name == "Hidden/InternalErrorShader")) { ((Renderer)val).sharedMaterial.shader = shader; } } } internal static void Unload(bool allObjects) { AssetBundle? bundle = _bundle; if (bundle != null) { bundle.Unload(allObjects); } _bundle = null; TemerskieFlaskPrefab = null; BottlesCratePrefab = null; ZmoraPrefab = null; } } [HarmonyPatch(typeof(HUDManager))] internal static class HUDManagerPatches { private static NavMeshPath? _cachedPath; [HarmonyPrefix] [HarmonyPatch("AddTextToChatOnServer")] private static bool BeforeAddTextToChat(HUDManager __instance, string chatMessage, int playerId) { //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0306: 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_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) try { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val == (Object)null || playerId != (int)val.playerClientId) { return true; } string text = chatMessage.Trim(); ManualLogSource? log = TemerskieMod._log; if (log != null) { log.LogInfo((object)("Chat from local player: \"" + text + "\"")); } switch (text) { case "/debug": { AllItemsList val3 = StartOfRound.Instance?.allItemsList; int num = val3?.itemsList?.Count ?? (-1); bool valueOrDefault = val3?.itemsList?.Any((Item i) => i.itemName == "Temerskie") == true; __instance.AddTextToChatOnServer($"[Temerskie] Debug: itemsList.Count={num} found={valueOrDefault}", playerId); return false; } case "/test": { TemerskieMod.ForceBialaMewa = !TemerskieMod.ForceBialaMewa; string text2 = (TemerskieMod.ForceBialaMewa ? "[Temerskie] Biała Mewa forced ON (100% chance)" : "[Temerskie] Biała Mewa forced OFF"); ManualLogSource? log2 = TemerskieMod._log; if (log2 != null) { log2.LogInfo((object)text2); } HUDManager.Instance.AddTextToChatOnServer(text2, (int)val.playerClientId); return false; } case "/zmora": SpawnZmora(val); return false; default: if (text.StartsWith("/tp")) { string query = ((text.Length > 3) ? text.Substring(3).Trim().ToLower() : "temerskie"); string itemName = MatchItemName(query); TeleportToNearestItem(val, itemName); return false; } switch (text) { case "/spawnbottles": SpawnBottlesItem(val); return false; case "/mesh": InspectNearestMesh(val); return false; case "/nv": NightVisionController.Toggle(playerId); return false; case "/noclip": { CharacterController component = ((Component)val).GetComponent<CharacterController>(); NoclipController component2 = ((Component)val).GetComponent<NoclipController>(); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); if ((Object)(object)component != (Object)null) { Rigidbody component3 = ((Component)val).GetComponent<Rigidbody>(); if ((Object)(object)component3 != (Object)null) { component3.velocity = Vector3.zero; } ((Collider)component).enabled = true; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(((Component)val).transform.position, Vector3.down, ref val2, 50f)) { ((Component)val).transform.position = ((RaycastHit)(ref val2)).point + Vector3.up * (component.height * 0.5f + 0.1f); } } val.isMovementHindered = 0; HUDManager.Instance.AddTextToChatOnServer("[Temerskie] Noclip OFF", playerId); } else { ((Component)val).gameObject.AddComponent<NoclipController>(); if ((Object)(object)component != (Object)null) { ((Collider)component).enabled = false; } val.isMovementHindered = 2; HUDManager.Instance.AddTextToChatOnServer("[Temerskie] Noclip ON (WASD+Space/Shift)", playerId); } return false; } } break; } } catch (Exception arg) { ManualLogSource? log3 = TemerskieMod._log; if (log3 != null) { log3.LogError((object)$"Chat handler error: {arg}"); } } return true; } private static string MatchItemName(string query) { if (string.IsNullOrEmpty(query)) { return "Temerskie"; } List<Item> list = StartOfRound.Instance?.allItemsList?.itemsList; if (list == null) { return query; } foreach (Item item in list) { if (item.itemName.Equals(query, StringComparison.OrdinalIgnoreCase)) { return item.itemName; } } foreach (Item item2 in list) { if (item2.itemName.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0) { return item2.itemName; } } if (query.Contains("case") || query.Contains("crate") || query.Contains("create") || query.Contains("bottle")) { return "Bottles of Temerskie"; } if (query.Contains("temer") || query.Contains("flask") || query.Contains("vodk")) { return "Temerskie"; } return query; } private static void TeleportToNearestItem(PlayerControllerB player, string itemName) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_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_008f: 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) PhysicsProp[] array = Object.FindObjectsOfType<PhysicsProp>(); PhysicsProp val = null; float num = float.MaxValue; Vector3 position = ((Component)player).transform.position; PhysicsProp[] array2 = array; foreach (PhysicsProp val2 in array2) { if (((GrabbableObject)val2).itemProperties?.itemName != itemName || !((NetworkBehaviour)val2).IsSpawned || ((GrabbableObject)val2).isHeld) { continue; } Vector3 position2 = ((Component)val2).transform.position; if (!(((Vector3)(ref position2)).sqrMagnitude < 1f)) { float num2 = Vector3.Distance(position, ((Component)val2).transform.position); if (num2 < num) { num = num2; val = val2; } } } if ((Object)(object)val == (Object)null) { HUDManager.Instance.AddTextToChatOnServer("[Temerskie] No " + itemName + " scrap found on the map.", (int)player.playerClientId); return; } Vector3 val3 = FindSafePosition(((Component)val).transform.position); player.TeleportPlayer(val3, false, 0f, false, true); HUDManager.Instance.AddTextToChatOnServer($"[Temerskie] Teleported to ({val3.x:F1}, {val3.y:F1}, {val3.z:F1})", (int)player.playerClientId); } private static Vector3 FindSafePosition(Vector3 scrapPos) { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_00ff: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: 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_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0180: 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_0183: 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_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref scrapPos)).sqrMagnitude < 1f) { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val != (Object)null) { return ((Component)val).transform.position + ((Component)val).transform.forward * 3f; } return Vector3.up * 2f; } int num = ((NavMesh.GetAreaFromName("Default") != -1) ? LayerMask.GetMask(new string[4] { "Default", "Terrain", "Room", "Colliders" }) : LayerMask.GetMask(new string[4] { "Default", "Terrain", "Room", "Colliders" })); NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(scrapPos, ref val2, 5f, -1)) { Vector3 position = ((NavMeshHit)(ref val2)).position; if (!Physics.CheckSphere(position + Vector3.up * 0.8f, 0.3f, num)) { return position; } } Vector3 val3 = default(Vector3); NavMeshHit val5 = default(NavMeshHit); for (float num2 = 0.5f; num2 <= 3f; num2 += 0.5f) { for (int i = 0; i < 16; i++) { float num3 = (float)i / 16f * 360f * (MathF.PI / 180f); ((Vector3)(ref val3))..ctor(Mathf.Cos(num3) * num2, 0f, Mathf.Sin(num3) * num2); Vector3 val4 = scrapPos + val3; if (NavMesh.SamplePosition(val4, ref val5, 2f, -1) && !Physics.CheckSphere(((NavMeshHit)(ref val5)).position + Vector3.up * 0.8f, 0.3f, num)) { return ((NavMeshHit)(ref val5)).position; } } } Vector3 val6 = default(Vector3); ((Vector3)(ref val6))..ctor(scrapPos.x, scrapPos.y + 3f, scrapPos.z); RaycastHit val7 = default(RaycastHit); if (Physics.Raycast(val6, Vector3.down, ref val7, 10f, num)) { return ((RaycastHit)(ref val7)).point; } return scrapPos + Vector3.up * 1.5f; } private static void SpawnZmora(PlayerControllerB player) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_008a: 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_00a1: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer || (Object)(object)TemerskieMod.ZmoraEnemyType == (Object)null) { return; } float num = Random.Range(10f, 20f); float num2 = Random.Range(0f, 360f); Vector3 val = Quaternion.Euler(0f, num2, 0f) * Vector3.forward; Vector3 val2 = ((Component)player).transform.position + val * num; Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(val2.x, val2.y + 5f, val2.z); NavMeshHit val4 = default(NavMeshHit); if (!NavMesh.SamplePosition(val3, ref val4, 20f, -1)) { ManualLogSource? log = TemerskieMod._log; if (log != null) { log.LogWarning((object)"Zmora spawn aborted: no valid NavMesh near player"); } HUDManager.Instance.AddTextToChatOnServer("[Temerskie] No valid spawn point for Zmora.", (int)player.playerClientId); return; } ZmoraAI.PrepareSpawn(TemerskieMod.ZmoraEnemyType, ((NetworkBehaviour)player).NetworkObjectId); RoundManager.Instance.SpawnEnemyGameObject(((NavMeshHit)(ref val4)).position, 0f, -1, TemerskieMod.ZmoraEnemyType); ManualLogSource? log2 = TemerskieMod._log; if (log2 != null) { log2.LogInfo((object)$"Zmora spawned at {((NavMeshHit)(ref val4)).position}"); } HUDManager.Instance.AddTextToChatOnServer("[Temerskie] Zmora summoned!", (int)player.playerClientId); } private static void SpawnBottlesItem(PlayerControllerB player) { //IL_00ee: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021a: 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_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer) { HUDManager.Instance.AddTextToChatOnServer("[Temerskie] Must be host to spawn.", (int)player.playerClientId); return; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance?.allItemsList == (Object)null) { return; } Item val = null; foreach (Item items in instance.allItemsList.itemsList) { if (items.itemName == "Bottles of Temerskie") { val = items; break; } } if ((Object)(object)val == (Object)null || (Object)(object)val.spawnPrefab == (Object)null) { HUDManager.Instance.AddTextToChatOnServer("[Temerskie] Bottles item not found in allItemsList.", (int)player.playerClientId); return; } Vector3 val2 = ((Component)player).transform.position + ((Component)player).transform.forward * 2f + Vector3.up * 0.5f; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(val2, Vector3.down, ref val3, 5f, LayerMask.GetMask(new string[3] { "Default", "Terrain", "Room" }))) { val2 = ((RaycastHit)(ref val3)).point + Vector3.up * 0.3f; } GameObject val4 = Object.Instantiate<GameObject>(val.spawnPrefab, val2, Quaternion.identity); NetworkObject component = val4.GetComponent<NetworkObject>(); if ((Object)(object)component != (Object)null && !component.IsSpawned) { component.Spawn(false); } PhysicsProp component2 = val4.GetComponent<PhysicsProp>(); if ((Object)(object)component2 != (Object)null) { ((GrabbableObject)component2).itemProperties = val; } MeshFilter component3 = val4.GetComponent<MeshFilter>(); MeshRenderer component4 = val4.GetComponent<MeshRenderer>(); Mesh val5 = ((component3 != null) ? component3.sharedMesh : null) ?? ((component3 != null) ? component3.mesh : null); Bounds val6 = (Bounds)((val5 != null) ? val5.bounds : default(Bounds)); string text = string.Format("Spawned at ({0:F1},{1:F1},{2:F1}) mesh={3} verts={4} bounds=[({5:F2},{6:F2},{7:F2})-({8:F2},{9:F2},{10:F2})] mf={11} mr={12}", val2.x, val2.y, val2.z, (val5 != null) ? ((Object)val5).name : null, (val5 != null) ? val5.vertexCount : 0, ((Bounds)(ref val6)).min.x, ((Bounds)(ref val6)).min.y, ((Bounds)(ref val6)).min.z, ((Bounds)(ref val6)).max.x, ((Bounds)(ref val6)).max.y, ((Bounds)(ref val6)).max.z, ((Object)(object)component3 != (Object)null) ? "YES" : "NO", ((Object)(object)component4 != (Object)null) ? "YES" : "NO"); ManualLogSource? log = TemerskieMod._log; if (log != null) { log.LogInfo((object)("[spawnbottles] " + text)); } HUDManager.Instance.AddTextToChatOnServer("[Temerskie] " + text, (int)player.playerClientId); } private static void InspectNearestMesh(PlayerControllerB player) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0059: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) PhysicsProp[] array = Object.FindObjectsOfType<PhysicsProp>(); PhysicsProp val = null; float num = float.MaxValue; Vector3 position = ((Component)player).transform.position; PhysicsProp[] array2 = array; foreach (PhysicsProp val2 in array2) { if (!(((GrabbableObject)val2).itemProperties?.itemName != "Bottles of Temerskie")) { float num2 = Vector3.Distance(position, ((Component)val2).transform.position); if (num2 < num) { num = num2; val = val2; } } } if ((Object)(object)val == (Object)null) { HUDManager.Instance.AddTextToChatOnServer("[Temerskie] No Bottles item found nearby.", (int)player.playerClientId); return; } GameObject gameObject = ((Component)val).gameObject; MeshFilter component = gameObject.GetComponent<MeshFilter>(); MeshRenderer component2 = gameObject.GetComponent<MeshRenderer>(); Mesh val3 = ((component != null) ? component.sharedMesh : null) ?? ((component != null) ? component.mesh : null); List<string> list = new List<string>(); list.Add($"pos=({((Component)val).transform.position.x:F1},{((Component)val).transform.position.y:F1},{((Component)val).transform.position.z:F1})"); list.Add($"localScale=({gameObject.transform.localScale.x:F4},{gameObject.transform.localScale.y:F4},{gameObject.transform.localScale.z:F4})"); list.Add("MeshFilter=" + (((Object)(object)component != (Object)null) ? "YES" : "NO") + " MeshRenderer=" + (((Object)(object)component2 != (Object)null) ? "YES" : "NO")); if ((Object)(object)val3 != (Object)null) { Bounds bounds = val3.bounds; list.Add($"mesh.name={((Object)val3).name} verts={val3.vertexCount} tris={val3.triangles.Length / 3}"); list.Add($"bounds=[({((Bounds)(ref bounds)).min.x:F2},{((Bounds)(ref bounds)).min.y:F2},{((Bounds)(ref bounds)).min.z:F2})-({((Bounds)(ref bounds)).max.x:F2},{((Bounds)(ref bounds)).max.y:F2},{((Bounds)(ref bounds)).max.z:F2})] size=[{((Bounds)(ref bounds)).size.x:F2},{((Bounds)(ref bounds)).size.y:F2},{((Bounds)(ref bounds)).size.z:F2}]"); list.Add($"subMeshCount={val3.subMeshCount} normals={val3.normals.Length} uv={val3.uv.Length}"); if (val3.vertexCount > 0) { Vector3 val4 = val3.vertices[0]; list.Add($"firstVert=({val4.x:F4},{val4.y:F4},{val4.z:F4})"); } } else { list.Add("NO MESH on MeshFilter"); } if ((Object)(object)component2 != (Object)null) { list.Add("material=" + (((Object)(object)((Renderer)component2).sharedMaterial != (Object)null) ? ((Object)((Renderer)component2).sharedMaterial).name : "null")); object[] obj = new object[7] { ((Renderer)component2).enabled, null, null, null, null, null, null }; Bounds bounds2 = ((Renderer)component2).bounds; obj[1] = ((Bounds)(ref bounds2)).center.x; bounds2 = ((Renderer)component2).bounds; obj[2] = ((Bounds)(ref bounds2)).center.y; bounds2 = ((Renderer)component2).bounds; obj[3] = ((Bounds)(ref bounds2)).center.z; bounds2 = ((Renderer)component2).bounds; obj[4] = ((Bounds)(ref bounds2)).size.x; bounds2 = ((Renderer)component2).bounds; obj[5] = ((Bounds)(ref bounds2)).size.y; bounds2 = ((Renderer)component2).bounds; obj[6] = ((Bounds)(ref bounds2)).size.z; list.Add(string.Format("enabled={0} boundsCenter=({1:F1},{2:F1},{3:F1}) size=({4:F1},{5:F1},{6:F1})", obj)); } else { list.Add("NO MeshRenderer"); } TemerskieProp component3 = ((Component)val).GetComponent<TemerskieProp>(); if ((Object)(object)component3 != (Object)null) { list.Add("TemerskieProp=YES"); } string text = string.Join(" | ", list); ManualLogSource? log = TemerskieMod._log; if (log != null) { log.LogInfo((object)("[mesh] " + text)); } HUDManager.Instance.AddTextToChatOnServer("[mesh] " + text, (int)player.playerClientId); } } internal class NightVisionController { private static bool _active; internal static void Toggle(int playerId) { _active = !_active; PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val == (Object)null) { HUDManager instance = HUDManager.Instance; if (instance != null) { instance.AddTextToChatOnServer("[Temerskie] Night vision: no player", playerId); } return; } NightVisionToggle component = ((Component)val).GetComponent<NightVisionToggle>(); if (_active) { if ((Object)(object)component == (Object)null) { ((Component)val).gameObject.AddComponent<NightVisionToggle>(); } else { ((Behaviour)component).enabled = true; } HUDManager instance2 = HUDManager.Instance; if (instance2 != null) { instance2.AddTextToChatOnServer("[Temerskie] Night vision ON", playerId); } } else { if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } HUDManager instance3 = HUDManager.Instance; if (instance3 != null) { instance3.AddTextToChatOnServer("[Temerskie] Night vision OFF", playerId); } } } } internal class NightVisionToggle : MonoBehaviour { private Light? _camLight; private void OnEnable() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_004b: 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_00a8: Unknown result type (might be due to invalid IL or missing references) Camera main = Camera.main; if ((Object)(object)main != (Object)null && (Object)(object)_camLight == (Object)null) { GameObject val = new GameObject("NV_Light"); val.transform.SetParent(((Component)main).transform, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; _camLight = val.AddComponent<Light>(); _camLight.type = (LightType)2; _camLight.range = 120f; _camLight.intensity = 20f; _camLight.color = Color.white; _camLight.renderMode = (LightRenderMode)1; _camLight.shadows = (LightShadows)0; _camLight.cullingMask = -1; } } private void OnDisable() { if ((Object)(object)_camLight != (Object)null) { Object.Destroy((Object)(object)((Component)_camLight).gameObject); _camLight = null; } } private void OnDestroy() { OnDisable(); } private void LateUpdate() { //IL_00c1: 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: Expected O, but got Unknown //IL_004e: 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) if ((Object)(object)_camLight == (Object)null) { Camera main = Camera.main; if ((Object)(object)main != (Object)null) { GameObject val = new GameObject("NV_Light"); val.transform.SetParent(((Component)main).transform, false); val.transform.localPosition = Vector3.zero; _camLight = val.AddComponent<Light>(); _camLight.type = (LightType)2; _camLight.range = 120f; _camLight.intensity = 20f; _camLight.color = Color.white; _camLight.renderMode = (LightRenderMode)1; _camLight.shadows = (LightShadows)0; } } RenderSettings.ambientLight = Color.white; RenderSettings.ambientIntensity = 5f; RenderSettings.fog = false; RenderSettings.fogDensity = 0f; } } internal class NoclipController : MonoBehaviour { private float _speed = 10f; private float _sprintMul = 3f; private void Update() { //IL_0066: 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_007d: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_0100: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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) PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val == (Object)null) { Object.Destroy((Object)(object)this); return; } Keyboard current = Keyboard.current; if (current == null) { return; } Camera main = Camera.main; Transform val2 = ((main != null) ? ((Component)main).transform : null); if (!((Object)(object)val2 == (Object)null)) { Vector3 val3 = Vector3.zero; if (((ButtonControl)current.wKey).isPressed) { val3 += val2.forward; } if (((ButtonControl)current.sKey).isPressed) { val3 -= val2.forward; } if (((ButtonControl)current.aKey).isPressed) { val3 -= val2.right; } if (((ButtonControl)current.dKey).isPressed) { val3 += val2.right; } if (((ButtonControl)current.spaceKey).isPressed) { val3 += Vector3.up; } if (((ButtonControl)current.leftShiftKey).isPressed) { val3 -= Vector3.up; } float num = _speed; if (((ButtonControl)current.leftCtrlKey).isPressed) { num *= _sprintMul; } if (((Vector3)(ref val3)).sqrMagnitude > 0.001f) { Transform transform = ((Component)val).transform; transform.position += ((Vector3)(ref val3)).normalized * num * Time.deltaTime; } } } } public class ZmoraAI : EnemyAI, ISmartAI { private const int STATE_ROAM = 0; private const int STATE_HUNT = 1; private const int STATE_ATTACK = 2; public NetworkVariable<ulong> targetPlayerId = new NetworkVariable<ulong>(ulong.MaxValue, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private PlayerControllerB? _targetPlayer; private float _phaseTimer = 10f; private float _flickerTimer; private bool _isFlickering; private Vector3 _roamTarget; private bool _hasRoamTarget; private Vector3 _huntTarget; private bool _hasHuntTarget; private Vector3 _lastNoisePos; private float _noiseAge = float.MaxValue; private bool _hasAttacked; internal ulong pendingTargetPlayerId = ulong.MaxValue; private float _targetRefreshTimer = 0f; private float _huntTimer = 0f; private bool _hasSeenPlayer = false; private bool _isRetreating = false; private float _retreatTimer = 0f; private float _teleportCooldown = 0f; private const float TELEPORT_COOLDOWN = 3f; private const float TELEPORT_RANGE = 15f; private const float TELEPORT_MIN_DIST = 5f; private SmartPathTask? _currentPathTask; private float _pathRecalcTimer = 0f; private const float PATH_TIMEOUT = 5f; private Vector3 _directMoveTarget; private float _directMoveSpeed; private bool _useDirectMovement; private MeshRenderer[]? _myRenderers; private ParticleSystem? _smokeParticles; private bool _callbacksHooked; private bool _initialized; private float _aiTimer; private bool _spawnedByServer; private Vector3 _lastPosition; private float _stuckTimer; internal static void PrepareSpawn(EnemyType type, ulong targetPlayerId) { ZmoraSpawnContext.NextEnemyType = type; ZmoraSpawnContext.NextTargetId = targetPlayerId; } internal bool IsTargetingPlayer(ulong playerNetworkObjectId) { if (targetPlayerId.Value == playerNetworkObjectId) { return true; } return pendingTargetPlayerId == playerNetworkObjectId; } public override void Start() { if (!((Object)(object)((NetworkBehaviour)this).NetworkObject == (Object)null) && ((NetworkBehaviour)this).NetworkObject.IsSpawned) { if (base.meshRenderers == null || base.meshRenderers.Length == 0) { base.meshRenderers = ((Component)this).GetComponentsInChildren<MeshRenderer>(true); } if (base.skinnedMeshRenderers == null || base.skinnedMeshRenderers.Length == 0) { base.skinnedMeshRenderers = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true); } if ((Object)(object)base.creatureSFX == (Object)null) { base.creatureSFX = ((Component)this).GetComponent<AudioSource>(); } if ((Object)(object)base.creatureAnimator == (Object)null) { base.creatureAnimator = ((Component)this).GetComponentInChildren<Animator>(true); } InitializeEnemy(); } } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); ManualLogSource? log = TemerskieMod._log; if (log != null) { object arg = ((NetworkBehaviour)this).IsServer; NetworkObject networkObject = ((NetworkBehaviour)this).NetworkObject; log.LogInfo((object)$"Zmora OnNetworkSpawn - IsServer: {arg}, IsSpawned: {((networkObject != null) ? new bool?(networkObject.IsSpawned) : ((bool?)null))}, IsOwner: {((NetworkBehaviour)this).IsOwner}"); } ZmoraSpawnContext.Consume(this); InitializeEnemy(); if (((NetworkBehaviour)this).IsServer) { ApplyPendingTarget(); } } private IEnumerator ApplyPendingTargetDeferred() { yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)((NetworkBehaviour)this).NetworkObject != (Object)null && ((NetworkBehaviour)this).NetworkObject.IsSpawned)); yield return (object)new WaitForSeconds(0.1f); ApplyPendingTarget(); } internal void ApplyPendingTarget() { if (!((NetworkBehaviour)this).IsServer || pendingTargetPlayerId == ulong.MaxValue) { return; } if ((Object)(object)((NetworkBehaviour)this).NetworkObject == (Object)null || !((NetworkBehaviour)this).NetworkObject.IsSpawned) { ManualLogSource? log = TemerskieMod._log; if (log != null) { log.LogInfo((object)"Zmora: NetworkObject not spawned yet, deferring target assignment"); } ((MonoBehaviour)this).StartCoroutine(ApplyPendingTargetDeferred()); return; } targetPlayerId.Value = pendingTargetPlayerId; pendingTargetPlayerId = ulong.MaxValue; ResolveTargetPlayer(); ManualLogSource? log2 = TemerskieMod._log; if (log2 != null) { log2.LogInfo((object)$"Zmora target set to player id {targetPlayerId.Value}"); } } internal void ConfigureAfterSpawn(EnemyType type) { _spawnedByServer = true; base.enemyType = type; base.ventAnimationFinished = true; DisableBasePathfinding(); if ((Object)(object)base.agent == (Object)null) { base.agent = ((Component)this).GetComponent<NavMeshAgent>(); } if ((Object)(object)base.agent != (Object)null) { ((Behaviour)base.agent).enabled = true; base.agent.speed = 5f; base.agent.angularSpeed = 120f; base.agent.acceleration = 8f; base.agent.stoppingDistance = 1.5f; base.agent.updatePosition = true; base.agent.updateRotation = true; try { SmartPathfinding.RegisterSmartAgent(base.agent); } catch { } } SnapToNavMesh(); ApplyPendingTarget(); if ((Object)(object)RoundManager.Instance != (Object)null && !RoundManager.Instance.SpawnedEnemies.Contains((EnemyAI)(object)this)) { RoundManager.Instance.SpawnedEnemies.Add((EnemyAI)(object)this); } } private void DisableBasePathfinding() { base.moveTowardsDestination = false; base.movingTowardsTargetPlayer = false; } private void InitializeEnemy() { //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Expected O, but got Unknown //IL_0193: 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_01ca: 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) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: 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) if (_initialized) { return; } _initialized = true; if ((Object)(object)base.enemyType == (Object)null) { base.enemyType = ZmoraSpawnContext.NextEnemyType ?? TemerskieMod.ZmoraEnemyType; } base.ventAnimationFinished = true; base.timeSinceSpawn = base.exitVentAnimationTime + 1f; if ((Object)(object)base.agent == (Object)null) { base.agent = ((Component)this).GetComponent<NavMeshAgent>(); } if ((Object)(object)base.agent != (Object)null) { ((Behaviour)base.agent).enabled = true; base.agent.radius = 0.4f; base.agent.height = 1.8f; base.agent.speed = 5f; base.agent.angularSpeed = 120f; base.agent.acceleration = 8f; base.agent.stoppingDistance = 1.5f; base.agent.autoRepath = false; base.agent.updatePosition = true; base.agent.updateRotation = true; try { SmartPathfinding.RegisterSmartAgent(base.agent); } catch (Exception ex) { ManualLogSource? log = TemerskieMod._log; if (log != null) { log.LogWarning((object)("Zmora: Failed to register smart agent: " + ex.Message)); } } } _currentPathTask = new SmartPathTask(); DisableBasePathfinding(); SnapToNavMesh(); ((Behaviour)this).enabled = true; DisableBasePathfinding(); base.ventAnimationFinished = true; SnapToNavMesh(); Vector3 position = ((Component)this).transform.position; if (((Vector3)(ref position)).sqrMagnitude < 1f && (Object)(object)_targetPlayer != (Object)null) { Vector3 val = FindSafeSpawnNearTarget(((Component)_targetPlayer).transform.position); if (val != Vector3.zero) { TeleportTo(val); } } if (base.meshRenderers == null || base.meshRenderers.Length == 0) { base.meshRenderers = ((Component)this).GetComponentsInChildren<MeshRenderer>(true); } if ((Object)(object)base.creatureAnimator == (Object)null) { base.creatureAnimator = ((Component)this).GetComponentInChildren<Animator>(true); } if ((Object)(object)base.creatureSFX == (Object)null) { base.creatureSFX = ((Component)this).GetComponent<AudioSource>(); } base.AIIntervalTime = 0.3f; base.enemyHP = 20; base.openDoorSpeedMultiplier = 1f; base.currentBehaviourStateIndex = 0; _phaseTimer = 10f; _flickerTimer = Random.Range(3f, 5f); _aiTimer = base.AIIntervalTime; _myRenderers = ((Component)this).GetComponentsInChildren<MeshRenderer>(true); _smokeParticles = ((Component)this).GetComponentInChildren<ParticleSystem>(true); ResolveTargetPlayer(); if (!_callbacksHooked) { NetworkVariable<ulong> obj = targetPlayerId; obj.OnValueChanged = (OnValueChangedDelegate<ulong>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<ulong>)delegate { ResolveTargetPlayer(); }); _callbacksHooked = true; } } public override void Update() { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_021f: 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_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: 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_0183: 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_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: 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_026f: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) UpdateVisibility(); if (!((NetworkBehaviour)this).IsServer && !_spawnedByServer) { return; } DisableBasePathfinding(); if (_aiTimer > 0f) { _aiTimer -= Time.deltaTime; } else { _aiTimer = base.AIIntervalTime + Random.Range(-0.015f, 0.015f); ((EnemyAI)this).DoAIInterval(); } _targetRefreshTimer += Time.deltaTime; if (_targetRefreshTimer > 5f) { _targetRefreshTimer = 0f; if (base.currentBehaviourStateIndex == 0 && _hasRoamTarget) { float num = Vector3.Distance(_roamTarget, ((Component)_targetPlayer).transform.position); if (num > 20f) { _hasRoamTarget = false; } } else if (base.currentBehaviourStateIndex == 1 && _hasHuntTarget) { float num2 = Vector3.Distance(_huntTarget, ((Component)_targetPlayer).transform.position); if (num2 > 20f) { _hasHuntTarget = false; } } } if (base.isEnemyDead || (Object)(object)_targetPlayer == (Object)null) { return; } if (_useDirectMovement) { Vector3 val = _directMoveTarget - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude > 0.1f) { float num3 = _directMoveSpeed * Time.deltaTime; if (((Vector3)(ref val)).magnitude < num3) { ((Component)this).transform.position = _directMoveTarget; _useDirectMovement = false; } else { Transform transform = ((Component)this).transform; transform.position += ((Vector3)(ref val)).normalized * num3; } } else { _useDirectMovement = false; } } Vector3 val2 = ((Component)_targetPlayer).transform.position - ((Component)this).transform.position; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude > 0.001f) { Quaternion val3 = Quaternion.LookRotation(val2); ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val3, 5f * Time.deltaTime); } if (IsAgentUsable() && base.agent.hasPath) { ((Component)this).transform.position = base.agent.nextPosition; } if (((NetworkBehaviour)this).IsOwner) { SyncPositionToClients(); } } private void SyncPositionToClients() { } private void TickSmartPathFollowing() { //IL_00be: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) if (_currentPathTask == null) { return; } if (!_currentPathTask.IsStarted || !_currentPathTask.IsComplete) { _pathRecalcTimer += Time.deltaTime; if (_pathRecalcTimer > 5f) { ManualLogSource? log = TemerskieMod._log; if (log != null) { log.LogInfo((object)"Zmora: SmartPathTask timed out"); } _pathRecalcTimer = 0f; } return; } _pathRecalcTimer = 0f; if (_currentPathTask.PathSucceeded(0)) { SmartPathDestination? result = _currentPathTask.GetResult(0); if (result.HasValue) { SmartPathDestination dest = result.Value; ManualLogSource? log2 = TemerskieMod._log; if (log2 != null) { log2.LogInfo((object)$"Zmora: Smart path completed - Type={((SmartPathDestination)(ref dest)).Type}, Position={((SmartPathDestination)(ref dest)).Position}"); } HandleSmartDestination(in dest); } else { ManualLogSource? log3 = TemerskieMod._log; if (log3 != null) { log3.LogInfo((object)"Zmora: Smart path succeeded but GetResult returned null"); } FallBackToAgentMovement(); } } else { ManualLogSource? log4 = TemerskieMod._log; if (log4 != null) { log4.LogInfo((object)"Zmora: Smart path failed, using direct approach"); } FallBackToAgentMovement(); } } public void GoToSmartPathDestination(in SmartPathDestination destination) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) ManualLogSource? log = TemerskieMod._log; if (log != null) { log.LogInfo((object)$"Zmora GoToSmartPathDestination - Type={((SmartPathDestination)(ref destination)).Type}, Position={((SmartPathDestination)(ref destination)).Position}"); } HandleSmartDestination(in destination); } private void HandleSmartDestination(in SmartPathDestination dest) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0020: Expected I4, but got Unknown //IL_0027: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0114: 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_00cd: Unknown result type (might be due to invalid IL or missing references) SmartDestinationType type = ((SmartPathDestination)(ref dest)).Type; SmartDestinationType val = type; switch ((int)val) { case 0: SetAgentDestination(((SmartPathDestination)(ref dest)).Position); break; case 2: { TeleportTo(((SmartPathDestination)(ref dest)).Position); ManualLogSource? log3 = TemerskieMod._log; if (log3 != null) { log3.LogInfo((object)$"Zmora: Using entrance teleport to {((SmartPathDestination)(ref dest)).Position}"); } break; } case 3: if (((SmartPathDestination)(ref dest)).ElevatorFloor == null) { break; } if (!((SmartPathDestination)(ref dest)).ElevatorFloor.Elevator.DoorsAreOpen && ((SmartPathDestination)(ref dest)).CanActivateDestination(((Component)this).transform.position)) { ((SmartPathDestination)(ref dest)).ElevatorFloor.CallElevator(); ManualLogSource? log2 = TemerskieMod._log; if (log2 != null) { log2.LogInfo((object)"Zmora: Called elevator"); } } SetAgentDestination(((SmartPathDestination)(ref dest)).Position); break; case 1: if (((SmartPathDestination)(ref dest)).InternalTeleport != null) { TeleportTo(((SmartPathDestination)(ref dest)).Position); ManualLogSource? log = TemerskieMod._log; if (log != null) { log.LogInfo((object)$"Zmora: Using internal teleport '{((SmartPathDestination)(ref dest)).InternalTeleport.Name}' to {((SmartPathDestination)(ref dest)).Position}"); } } else { SetAgentDestination(((SmartPathDestination)(ref dest)).Position); } break; default: SetAgentDestination(((SmartPathDestination)(ref dest)).Position); break; } } private void FallBackToAgentMovement() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_targetPlayer != (Object)null) { SetAgentDestination(((Component)_targetPlayer).transform.position); } } private void SetAgentDestination(Vector3 destination) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled) { base.agent.SetDestination(destination); } else { TeleportTo(destination); } } public override void DoAIInterval() { //IL_0031: 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_0052: 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_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_00c0: 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_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: 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_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) DisableBasePathfinding(); if (base.isEnemyDead) { return; } if ((Object)(object)_targetPlayer != (Object)null) { float num = Vector3.Distance(((Component)this).transform.position, ((Component)_targetPlayer).transform.position); float num2 = Vector3.Distance(((Component)this).transform.position, _lastPosition); if (num2 < 0.3f) { _stuckTimer += base.AIIntervalTime; if (_stuckTimer > 5f) { ManualLogSource? log = TemerskieMod._log; if (log != null) { log.LogWarning((object)$"Zmora: Stuck for {_stuckTimer:F0}s at {((Component)this).transform.position}, attempting recovery"); } _stuckTimer = 0f; if (!SnapToNavMesh()) { Vector3 val = FindSafeSpawnNearTarget(((Component)_targetPlayer).transform.position); if (val != Vector3.zero) { TeleportTo(val); } } _hasRoamTarget = false; _hasHuntTarget = false; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled) { base.agent.ResetPath(); } } } else { _stuckTimer = 0f; } _lastPosition = ((Component)this).transform.position; if (num > 200f) { ManualLogSource? log2 = TemerskieMod._log; if (log2 != null) { log2.LogWarning((object)$"Zmora: Drifted {num:F0}m from player, snapping back"); } Vector3 val2 = FindSafeSpawnNearTarget(((Component)_targetPlayer).transform.position); if (val2 != Vector3.zero) { TeleportTo(val2); } _hasRoamTarget = false; _hasHuntTarget = false; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled) { base.agent.ResetPath(); } } } if (HasValidTarget()) { switch (base.currentBehaviourStateIndex) { case 0: Phase1Roam(); break; case 1: Phase2Hunt(); break; case 2: Phase3Attack(); break; } UpdateVisibility(); } } private bool HasValidTarget() { if ((Object)(object)_targetPlayer != (Object)null) { return true; } ResolveTargetPlayer(); return (Object)(object)_targetPlayer != (Object)null; } private void ResolveTargetPlayer() { _targetPlayer = null; PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>(); HashSet<ulong> bialaMewaPlayers = TemerskieMod.BialaMewaPlayers; ulong value = targetPlayerId.Value; if (value == ulong.MaxValue && pendingTargetPlayerId != ulong.MaxValue) { value = pendingTargetPlayerId; } if (value != ulong.MaxValue) { PlayerControllerB[] array2 = array; foreach (PlayerControllerB val in array2) { if (((NetworkBehaviour)val).NetworkObjectId == value && bialaMewaPlayers.Contains(value)) { _targetPlayer = val; base.targetPlayer = val; return; } } } PlayerControllerB[] array3 = array; foreach (PlayerControllerB val2 in array3) { if (!val2.isPlayerDead && bialaMewaPlayers.Contains(((NetworkBehaviour)val2).NetworkObjectId)) { _targetPlayer = val2; base.targetPlayer = val2; targetPlayerId.Value = ((NetworkBehaviour)val2).NetworkObjectId; return; } } PlayerControllerB[] array4 = array; foreach (PlayerControllerB val3 in array4) { if (bialaMewaPlayers.Contains(((NetworkBehaviour)val3).NetworkObjectId)) { _targetPlayer = val3; base.targetPlayer = val3; break; } } } private bool SnapToNavMesh() { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0112: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_0098: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_00f7: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)this).transform.position; Vector3 val = position; if (((Vector3)(ref position)).sqrMagnitude < 1f && (Object)(object)_targetPlayer != (Object)null) { val = ((Component)_targetPlayer).transform.position; ManualLogSource? log = TemerskieMod._log; if (log != null) { log.LogInfo((object)$"Zmora SnapToNavMesh: at origin, searching near target player at {val}"); } } if ((Object)(object)RoundManager.Instance != (Object)null) { Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(val, RoundManager.Instance.navHit, 50f, -1); if (navMeshPosition != Vector3.zero) { ((Component)this).transform.position = navMeshPosition; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled) { base.agent.Warp(navMeshPosition); } ManualLogSource? log2 = TemerskieMod._log; if (log2 != null) { log2.LogInfo((object)$"Zmora SnapToNavMesh: snapped via RoundManager to {navMeshPosition}"); } return true; } } NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(val, ref val2, 50f, -1)) { ((Component)this).transform.position = ((NavMeshHit)(ref val2)).position; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled) { base.agent.Warp(((NavMeshHit)(ref val2)).position); } ManualLogSource? log3 = TemerskieMod._log; if (log3 != null) { log3.LogInfo((object)$"Zmora SnapToNavMesh: snapped via NavMesh.SamplePosition to {((NavMeshHit)(ref val2)).position}"); } return true; } ManualLogSource? log4 = TemerskieMod._log; if (log4 != null) { log4.LogWarning((object)$"Zmora SnapToNavMesh: failed to find NavMesh near {val}"); } return false; } private Vector3 FindSafeSpawnNearTarget(Vector3 targetPos) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val3 = default(NavMeshHit); for (int i = 0; i < 20; i++) { float num = Random.Range(0f, 360f); float num2 = Random.Range(8f, 15f); Vector3 val = Quaternion.Euler(0f, num, 0f) * Vector3.forward; Vector3 val2 = targetPos + val * num2; if (NavMesh.SamplePosition(val2, ref val3, 5f, -1)) { return ((NavMeshHit)(ref val3)).position; } } NavMeshHit val4 = default(NavMeshHit); if (NavMesh.SamplePosition(targetPos, ref val4, 10f, -1)) { return ((NavMeshHit)(ref val4)).position; } return Vector3.zero; } private void StartSmartPathTo(Vector3 destination, float speed = 7f) { //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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (!IsAgentUsable()) { _directMoveTarget = destination; _directMoveSpeed = speed; _useDirectMovement = true; return; } if (_currentPathTask == null) { _currentPathTask = new SmartPathTask(); } try { Vector3 pathOrigin = AgentExtensions.GetPathOrigin(base.agent); _currentPathTask.StartPathTask(base.agent, pathOrigin, destination, (SmartPathfindingLinkFlags)15); base.agent.speed = speed; _pathRecalcTimer = 0f; } catch (Exception ex) { ManualLogSource? log = TemerskieMod._log; if (log != null) { log.LogWarning((object)("Zmora StartSmartPathTo failed: " + ex.Message + ", falling back to direct agent movement")); } base.agent.SetDestination(destination); base.agent.speed = speed; } } private bool IsAgentUsable() { return (Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh; } private void MoveTo(Vector3 target, float speed = 7f) { //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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (!(target == Vector3.zero)) { if (IsAgentUsable()) { _useDirectMovement = false; base.agent.speed = speed; base.agent.SetDestination(target); } else { _directMoveTarget = target; _directMoveSpeed = speed; _useDirectMovement = true; } } } private void Phase1Roam() { //IL_0034: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_00b6: 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_00c6: 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_00cf: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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) if (!HasValidTarget()) { return; } _phaseTimer -= base.AIIntervalTime; if (!_hasRoamTarget || Vector3.Distance(((Component)this).transform.position, _roamTarget) < 2f) { Vector3 val = FindRoamPositionBehindCover(); NavMeshHit val2 = default(NavMeshHit); if (val != Vector3.zero && NavMesh.SamplePosition(val, ref val2, 3f, -1)) { _roamTarget = val; _hasRoamTarget = true; MoveTo(_roamTarget); } else { Vector3 val3 = ((Component)_targetPlayer).transform.position - ((Component)this).transform.position; Vector3 val4 = ((Vector3)(ref val3)).normalized; if (((Vector3)(ref val4)).sqrMagnitude < 0.01f) { val4 = Vector3.forward; } Vector3 val5 = val4 * Random.Range(3f, 8f); Vector3 val6 = ((Component)this).transform.position + val5; NavMeshHit val7 = default(NavMeshHit); if (NavMesh.SamplePosition(val6, ref val7, 5f, -1)) { _roamTarget = ((NavMeshHit)(ref val7)).position; _hasRoamTarget = true; MoveTo(_roamTarget); } } } if (_phaseTimer <= 0f) { _phaseTimer = float.MaxValue; _huntTimer = 0f; _hasSeenPlayer = false; base.currentBehaviourStateIndex = 1; } } private void Phase2Hunt() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_0100: 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_0140: 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_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021c: 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_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0244: 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_0252: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) if (!HasValidTarget()) { return; } if (_noiseAge < 5f) { _noiseAge += base.AIIntervalTime; TryTeleportToNoise(); if (_teleportCooldown <= 0f) { MoveTo(_lastNoisePos); } } bool flag = false; float num = Vector3.Distance(((Component)this).transform.position, ((Component)_targetPlayer).transform.position); Vector3 val3; if (num < 25f) { Vector3 val = ((Component)this).transform.position + Vector3.up * 1.5f; Vector3 val2 = ((Component)_targetPlayer).transform.position + Vector3.up * 1.5f; val3 = val2 - val; Vector3 normalized = ((Vector3)(ref val3)).normalized; float num2 = Vector3.Distance(val, val2); int mask = LayerMask.GetMask(new string[5] { "Default", "Terrain", "Room", "InteractableObject", "Colliders" }); RaycastHit val4 = default(RaycastHit); if (!Physics.Raycast(val, normalized, ref val4, num2, mask)) { flag = true; } } if (flag) { _hasSeenPlayer = true; } _huntTimer += base.AIIntervalTime; bool flag2 = _huntTimer >= 30f; if (_huntTimer >= 10f && (_hasSeenPlayer || flag2) && num < 15f) { ManualLogSource? log = TemerskieMod._log; if (log != null) { log.LogInfo((object)$"Zmora: ATTACK phase (seen: {_hasSeenPlayer}, force: {flag2}, dist: {num:F1})"); } base.currentBehaviourStateIndex = 2; _huntTimer = 0f; _hasSeenPlayer = false; } else { if (_hasHuntTarget && !(Vector3.Distance(((Component)this).transform.position, _huntTarget) < 2f)) { return; } Vector3 val5 = FindHuntPositionBehindCover(); NavMeshHit val6 = default(NavMeshHit); if (val5 != Vector3.zero && NavMesh.SamplePosition(val5, ref val6, 3f, -1)) { _huntTarget = val5; _hasHuntTarget = true; MoveTo(_huntTarget); return; } val3 = ((Component)_targetPlayer).transform.position - ((Component)this).transform.position; Vector3 val7 = ((Vector3)(ref val3)).normalized; if (((Vector3)(ref val7)).sqrMagnitude < 0.01f) { val7 = Vector3.forward; } Vector3 val8 = val7 * Random.Range(3f, 8f); Vector3 val9 = ((Component)this).transform.position + val8; NavMeshHit val10 = default(NavMeshHit); if (NavMesh.SamplePosition(val9, ref val10, 5f, -1)) { _huntTarget = ((NavMeshHit)(ref val10)).position; _hasHuntTarget = true; MoveTo(_huntTarget); } } } private void Phase3Attack() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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) //IL_0128: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_017f: 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_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: 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) if (!HasValidTarget()) { return; } float num = Vector3.Distance(((Component)this).transform.position, ((Component)_targetPlayer).transform.position); if (num > 20f) { _hasAttacked = false; _isRetreating = false; _noiseAge = float.MaxValue; base.currentBehaviourStateIndex = 1; return; } Vector3 val; if (num < 3f && !_hasAttacked) { _hasAttacked = true; _isRetreating = true; _retreatTimer = 0f; PlayerControllerB? targetPlayer = _targetPlayer; val = default(Vector3); targetPlayer.DamagePlayer(2, true, true, (CauseOfDeath)0, 0, false, val); ManualLogSource? log = TemerskieMod._log; if (log != null) { log.LogInfo((object)"Zmora: Melee attack! Retreating..."); } ((MonoBehaviour)this).Invoke("ResetAttack", 1f); } if (_isRetreating) { _retreatTimer += base.AIIntervalTime; val = ((Component)this).transform.position - ((Component)_targetPlayer).transform.position; Vector3 val2 = ((Vector3)(ref val)).normalized; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = Vector3.right; } Vector3 val3 = ((Component)this).transform.position + val2 * 10f; if ((Object)(object)RoundManager.Instance != (Object)null) { val3 = RoundManager.Instance.GetNavMeshPosition(val3, RoundManager.Instance.navHit, 8f, -1); } if (val3 != Vector3.zero) { MoveTo(val3, 12f); } if (num >= 10f || _retreatTimer >= 3f) { _hasAttacked = false; _isRetreating = false; _noiseAge = float.MaxValue; base.currentBehaviourStateIndex = 1; _hasHuntTarget = false; } } else { MoveTo(((Component)_targetPlayer).transform.position, 10f); } } private void ResetAttack() { _hasAttacked = false; _isRetreating = false; } private Vector3 FindRoamPositionBehindCover() { //IL_01af: 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_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_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) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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) //IL_00da: 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_00e8: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: 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) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_0151: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_targetPlayer == (Object)null || (Object)(object)RoundManager.Instance == (Object)null) { return Vector3.zero; } Vector3 position = ((Component)_targetPlayer).transform.position; Vector3 forward = ((Component)_targetPlayer).transform.forward; int mask = LayerMask.GetMask(new string[5] { "Default", "Terrain", "Room", "InteractableObject", "Colliders" }); RaycastHit val4 = default(RaycastHit); for (int i = 0; i < 20; i++) { float num = Random.Range(0f, 360f); float num2 = Random.Range(7f, 15f); Vector3 val = Quaternion.Euler(0f, num, 0f) * Vector3.forward; Vector3 val2 = position + val * num2; Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(val2, RoundManager.Instance.navHit, 5f, -1); if (navMeshPosition == Vector3.zero) { continue; } Vector3 val3 = navMeshPosition - position; Vector3 normalized = ((Vector3)(ref val3)).normalized; float num3 = Vector3.Dot(forward, normalized); if (num3 > -0.3f) { continue; } try { if (Physics.Raycast(position + Vector3.up * 1.5f, normalized, ref val4, num2, mask) && ((RaycastHit)(ref val4)).distance < num2 * 0.8f) { return navMeshPosition; } } catch { } try { if (Physics.CheckSphere(navMeshPosition, 1.5f, mask)) { continue; } } catch { } return navMeshPosition; } return Vector3.zero; } private Vector3 FindHuntPositionBehindCover() { //IL_01af: 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_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_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) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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) //IL_00da: 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_00e8: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: 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) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_0151: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_targetPlayer == (Object)null || (Object)(object)RoundManager.Instance == (Object)null) { return Vector3.zero; } Vector3 position = ((Component)_targetPlayer).transform.position; Vector3 forward = ((Component)_targetPlayer).transform.forward; int mask = LayerMask.GetMask(new string[5] { "Default", "Terrain", "Room", "InteractableObject", "Colliders" }); RaycastHit val4 = default(RaycastHit); for (int i = 0; i < 15; i++) { float num = Random.Range(0f, 360f); float num2 = Random.Range(7f, 15f); Vector3 val = Quaternion.Euler(0f, num, 0f) * Vector3.forward; Vector3 val2 = position + val * num2; Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(val2, RoundManager.Instance.navHit, 5f, -1); if (navMeshPosition == Vector3.zero) { continue; } Vector3 val3 = navMeshPosition - position; Vector3 normalized = ((Vector3)(ref val3)).normalized; float num3 = Vector3.Dot(forward, normalized); if (num3 > -0.5f) { continue; } try { if (Physics.Raycast(position + Vector3.up * 1.5f, normalized, ref val4, num2, mask) && ((RaycastHit)(ref val4)).distance < num2 * 0.7f) { return navMeshPosition; } } catch { } try { if (Physics.CheckSphere(navMeshPosition, 1.5f, mask)) { continue; } } catch { } return navMeshPosition; } return Vector3.zero; } private bool PlayerIsLooking() { //IL_0040: Unknown result type (might be