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 Neighbor v1.0.0
HelloNeighbor.dll
Decompiled 2 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HelloNeighbor.NetcodePatcher; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; [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("HelloNeighbor")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("My first plugin")] [assembly: AssemblyTitle("HelloNeighbor")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 HelloNeighbor { public class lcmanager { public static void configurelc() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0028: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_004d: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0053: 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_005f: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0071: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown ConfigEntry<float> speed = Plugin.Speed; FloatSliderOptions val = new FloatSliderOptions(); ((BaseRangeOptions<float>)val).Min = 2f; ((BaseRangeOptions<float>)val).Max = 8f; FloatSliderConfigItem val2 = new FloatSliderConfigItem(speed, val); ConfigEntry<int> fovRange = Plugin.FovRange; IntSliderOptions val3 = new IntSliderOptions(); ((BaseRangeOptions<int>)val3).Min = 90; ((BaseRangeOptions<int>)val3).Max = 180; IntSliderConfigItem val4 = new IntSliderConfigItem(fovRange, val3); ConfigEntry<int> timeToStartGoingToRandomPlayer = Plugin.TimeToStartGoingToRandomPlayer; IntSliderOptions val5 = new IntSliderOptions(); ((BaseRangeOptions<int>)val5).Min = 0; ((BaseRangeOptions<int>)val5).Max = 240; IntSliderConfigItem val6 = new IntSliderConfigItem(timeToStartGoingToRandomPlayer, val5); EnumDropDownConfigItem<Plugin.musicenum> val7 = new EnumDropDownConfigItem<Plugin.musicenum>(Plugin.ChaseMusic); BoolCheckBoxConfigItem val8 = new BoolCheckBoxConfigItem(Plugin.NoSongInRandom); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val4); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val6); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val7); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val8); } } public class NeighborAI : EnemyAI { public enum State { Idle, Roaming, Chasing, Investigating } private AudioSource chase; private AudioSource nearchase; private AudioClip chasealpha1; private AudioClip chasealpha1scary; private AudioClip chaseprealpha; private AudioClip chasesong; private Animator controller; private DoorLock currentdoor = null; private bool passingthroughdoor = false; private Vector3 doorposition; private float investigatetimer = 0f; private float maxinvestigatetime = 9f; private float nearchaseupdatetimer; private bool goingtorandomplayer = false; private float randomplayertimer = 0f; private int state = -1; private float killcooldown = 0f; private static readonly FieldInfo openedfield = typeof(DoorLock).GetField("isDoorOpened", BindingFlags.Instance | BindingFlags.NonPublic); private NetworkVariable<int> nearchasemask; public void Awake() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown base.enemyBehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[4] { new EnemyBehaviourState { name = "Idle" }, new EnemyBehaviourState { name = "Roaming" }, new EnemyBehaviourState { name = "Chasing" }, new EnemyBehaviourState { name = "Investigating" } }; nearchasemask = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); ((EnemyAI)this).Awake(); } public override void Start() { AudioSource[] components = ((Component)this).GetComponents<AudioSource>(); chase = components[0]; nearchase = components[1]; base.agent = ((Component)this).GetComponent<NavMeshAgent>(); if ((Object)(object)base.agent == (Object)null) { Log("No navmesh agent found on enemy. not good", isError: true); } base.agent.updateRotation = false; base.agent.updateUpAxis = false; base.agent.stoppingDistance = 0.8f; base.agent.angularSpeed = 360f; controller = ((Component)this).GetComponent<Animator>(); if ((Object)(object)controller == (Object)null) { Log("No animator found on enemy. not good", isError: true); } chaseprealpha = Plugin.bundle.LoadAsset<AudioClip>("prealpha"); chasealpha1scary = Plugin.bundle.LoadAsset<AudioClip>("scarychase"); chasealpha1 = Plugin.bundle.LoadAsset<AudioClip>("chasealpha1"); chasesong = Plugin.bundle.LoadAsset<AudioClip>("chase"); if ((Object)(object)chaseprealpha == (Object)null) { Log("Missing AudioClip: prealpha ", isError: true); } if ((Object)(object)chasealpha1scary == (Object)null) { Log("Missing AudioClip: scarychase ", isError: true); } if ((Object)(object)chasealpha1 == (Object)null) { Log("Missing AudioClip: chasealpha1 ", isError: true); } if ((Object)(object)chasesong == (Object)null) { Log("Missing AudioClip: chase ", isError: true); } base.eye = ((Component)this).transform.Find("eye"); if ((Object)(object)base.eye == (Object)null) { Log("Za eye not found prob assetbundle is corrupted or not accessible.", isError: true); } if ((Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.currentLevel != (Object)null) { switch (StartOfRound.Instance.currentLevel.riskLevel) { case "S++": maxinvestigatetime += 4f; break; case "S+": maxinvestigatetime += 3.5f; break; case "S": maxinvestigatetime += 3f; break; case "A": maxinvestigatetime += 3f; break; } } base.updatePositionThreshold = 0.2f; ((EnemyAI)this).Start(); ((EnemyAI)this).SwitchToBehaviourState(1); } public override void Update() { //IL_008d: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_016d: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).Update(); FaceMovementDirection(); updatenearchasemask(); checknearchase(); statesbehaviour(); if (killcooldown > 0f) { killcooldown -= Time.deltaTime; } PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)localPlayerController != (Object)null && !localPlayerController.isPlayerDead && localPlayerController.isInsideFactory) { bool flag = base.currentBehaviourStateIndex == 2 || base.currentBehaviourStateIndex == 3; float num = Vector3.Distance(((Component)this).transform.position, ((Component)localPlayerController).transform.position); if (flag && killcooldown <= 0f && num < 1.8f) { killcooldown = 1f; localPlayerController.KillPlayer(Vector3.zero, true, (CauseOfDeath)6, 0, default(Vector3), false); } } NavMeshHit val = default(NavMeshHit); if (((NetworkBehaviour)this).IsServer && (base.currentBehaviourStateIndex == 2 || base.currentBehaviourStateIndex == 3) && (Object)(object)base.targetPlayer != (Object)null && !base.targetPlayer.isPlayerDead && base.targetPlayer.isInsideFactory && NavMesh.SamplePosition(((Component)base.targetPlayer).transform.position, ref val, 5f, -1)) { base.agent.SetDestination(((NavMeshHit)(ref val)).position); } } public override void DoAIInterval() { ((EnemyAI)this).DoAIInterval(); if (!StartOfRound.Instance.allPlayersDead && ((NetworkBehaviour)this).IsServer) { switch (base.currentBehaviourStateIndex) { case 0: break; case 1: investigatetimer = 0f; Roaming(); break; case 2: Chasing(); break; case 3: Investigating(); break; } } } private void statesbehaviour() { if (base.currentBehaviourStateIndex == state) { return; } switch (base.currentBehaviourStateIndex) { case 0: chase.Stop(); controller.SetBool("IsChasing", false); controller.SetBool("IsWalking", false); controller.SetBool("IsLookingAround", false); break; case 1: chase.Stop(); controller.SetBool("IsChasing", false); controller.SetBool("IsWalking", true); controller.SetBool("IsLookingAround", false); break; case 2: if (!chase.isPlaying) { chase.clip = getchasemusic(); chase.Play(); } controller.SetBool("IsChasing", true); controller.SetBool("IsWalking", false); controller.SetBool("IsLookingAround", false); break; case 3: if (!chase.isPlaying) { chase.clip = getchasemusic(); chase.Play(); } controller.SetBool("IsChasing", true); controller.SetBool("IsWalking", false); controller.SetBool("IsLookingAround", false); break; } if (((NetworkBehaviour)this).IsServer) { switch (base.currentBehaviourStateIndex) { case 0: base.agent.speed = 0f; base.agent.isStopped = true; break; case 1: base.agent.speed = Plugin.Speed.Value * 0.4f; base.agent.isStopped = false; base.agent.ResetPath(); goingtorandomplayer = false; randomplayertimer = 0f; break; case 2: base.agent.speed = Plugin.Speed.Value; base.agent.isStopped = false; randomplayertimer = 30f; break; case 3: base.agent.speed = Plugin.Speed.Value * 0.9f; base.agent.isStopped = false; investigatetimer = 0f; randomplayertimer = 30f; break; } } state = base.currentBehaviourStateIndex; } private void Roaming() { //IL_00b8: 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_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: 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_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: 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_0160: 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_022b: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0256: 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_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.agent != (Object)null && base.agent.pathPending) { return; } randomplayertimer += base.AIIntervalTime; if (goingtorandomplayer && !base.agent.hasPath && !base.agent.pathPending) { goingtorandomplayer = false; } DoorLock val = getdoor(); if (((Object)(object)val != (Object)null || passingthroughdoor) && !openandclosedoor(val)) { base.agent.ResetPath(); } if (goingtorandomplayer && Vector3.Distance(((Component)this).transform.position, base.agent.destination) < 4f) { goingtorandomplayer = false; base.agent.ResetPath(); } if (!goingtorandomplayer && randomplayertimer >= (float)Plugin.TimeToStartGoingToRandomPlayer.Value) { PlayerControllerB farPlayer = GetFarPlayer(); if ((Object)(object)farPlayer != (Object)null) { goingtorandomplayer = true; NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(((Component)farPlayer).transform.position, ref val2, 5f, -1)) { base.agent.SetDestination(((NavMeshHit)(ref val2)).position); } } } PlayerControllerB val3 = getclosetfov(Plugin.FovRange.Value, (int)Plugin.DetectionRange); if ((Object)(object)val3 != (Object)null) { Vector3 desiredVelocity = base.agent.desiredVelocity; Vector3 normalized = ((Vector3)(ref desiredVelocity)).normalized; RaycastHit val4 = default(RaycastHit); if (!Physics.Raycast(((Component)this).transform.position + Vector3.up, normalized, ref val4, Plugin.DetectionRange) || !((Object)(object)((Component)((RaycastHit)(ref val4)).collider).GetComponent<DoorLock>() != (Object)null)) { base.targetPlayer = val3; SwitchState(2); } } else { if (goingtorandomplayer || (base.agent.hasPath && !(Vector3.Distance(((Component)this).transform.position, base.agent.destination) < 2f))) { return; } Vector3 randomDestinationAtLeastDistance = GetRandomDestinationAtLeastDistance(100f); if (randomDestinationAtLeastDistance != Vector3.zero) { NavMeshHit val5 = default(NavMeshHit); if (NavMesh.SamplePosition(randomDestinationAtLeastDistance, ref val5, 5f, -1)) { base.agent.SetDestination(((NavMeshHit)(ref val5)).position); } } else { Log("No random destination found for roaming??"); } } } private void Chasing() { if ((Object)(object)base.targetPlayer == (Object)null || base.targetPlayer.isPlayerDead || !base.targetPlayer.isInsideFactory) { SwitchState(1); return; } DoorLock val = getdoor(); if ((Object)(object)val != (Object)null || passingthroughdoor) { if (!openandclosedoor(val)) { base.agent.ResetPath(); } } else if (!((Object)(object)base.agent != (Object)null) || !base.agent.pathPending) { PlayerControllerB val2 = getclosetfov(360, (int)Plugin.DetectionRange * 2); if ((Object)(object)val2 != (Object)null) { base.targetPlayer = val2; } else { SwitchState(3); } } } private void Investigating() { //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) investigatetimer += base.AIIntervalTime; if (investigatetimer >= maxinvestigatetime) { investigatetimer = 0f; SwitchState(1); return; } PlayerControllerB val = getclosetfov(360, (int)Plugin.DetectionRange * 2); if ((Object)(object)val != (Object)null) { base.targetPlayer = val; SwitchState(2); return; } DoorLock val2 = getdoor(); if ((Object)(object)val2 != (Object)null || passingthroughdoor) { if (!openandclosedoor(val2)) { base.agent.ResetPath(); } } else if (!base.agent.pathPending) { NavMeshHit val3 = default(NavMeshHit); if ((Object)(object)base.targetPlayer == (Object)null || base.targetPlayer.isPlayerDead || !base.targetPlayer.isInsideFactory) { SwitchState(1); } else if (NavMesh.SamplePosition(((Component)base.targetPlayer).transform.position, ref val3, 5f, -1)) { base.agent.SetDestination(((NavMeshHit)(ref val3)).position); } } } private void Log(string message, bool isError = false) { if (isError) { Plugin.Logger.LogError((object)message); } else { Plugin.Logger.LogInfo((object)message); } } private PlayerControllerB GetFarPlayer() { List<PlayerControllerB> list = (from p in StartOfRound.Instance.allPlayerScripts where (Object)(object)p != (Object)null && !p.isPlayerDead && !p.isInHangarShipRoom && p.isInsideFactory orderby Vector3.Distance(((Component)this).transform.position, ((Component)p).transform.position) descending select p).ToList(); if (list.Count == 0) { return null; } List<PlayerControllerB> list2 = list.Take(Mathf.CeilToInt((float)list.Count / 2f)).ToList(); return list2[Random.Range(0, list2.Count)]; } private DoorLock getdoor() { //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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) Vector3 desiredVelocity = base.agent.desiredVelocity; Vector3 normalized = ((Vector3)(ref desiredVelocity)).normalized; if (normalized == Vector3.zero) { return null; } RaycastHit val = default(RaycastHit); if (Physics.Raycast(((Component)this).transform.position + Vector3.up, normalized, ref val, 2f)) { return ((Component)((RaycastHit)(ref val)).collider).GetComponent<DoorLock>(); } return null; } private bool openandclosedoor(DoorLock door) { //IL_005f: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) if (passingthroughdoor && (Object)(object)currentdoor != (Object)null) { if ((bool)openedfield.GetValue(currentdoor)) { if (Vector3.Distance(((Component)this).transform.position, doorposition) > 3f) { currentdoor.CloseDoorNonPlayerServerRpc(); AnimatedObjectTrigger component = ((Component)currentdoor).GetComponent<AnimatedObjectTrigger>(); if ((Object)(object)component != (Object)null) { component.TriggerAnimationNonPlayer(false, true, false); } currentdoor = null; passingthroughdoor = false; } return true; } door = currentdoor; passingthroughdoor = false; currentdoor = null; } if ((Object)(object)door == (Object)null || door.isLocked) { return false; } if (!(bool)openedfield.GetValue(door)) { door.OpenDoorAsEnemyServerRpc(); AnimatedObjectTrigger component2 = ((Component)door).GetComponent<AnimatedObjectTrigger>(); if ((Object)(object)component2 != (Object)null) { component2.TriggerAnimationNonPlayer(false, true, false); } } currentdoor = door; doorposition = ((Component)door).transform.position; passingthroughdoor = true; return true; } private PlayerControllerB getclosetfov(int fov, int distance) { //IL_009e: 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) PlayerControllerB[] allPlayersInLineOfSight = ((EnemyAI)this).GetAllPlayersInLineOfSight((float)fov, distance, (Transform)null, -1f, -1); if (allPlayersInLineOfSight == null || allPlayersInLineOfSight.Length == 0) { return null; } if ((Object)(object)base.targetPlayer != (Object)null && !base.targetPlayer.isPlayerDead && allPlayersInLineOfSight.Contains(base.targetPlayer)) { return base.targetPlayer; } PlayerControllerB result = null; float num = float.MaxValue; PlayerControllerB[] array = allPlayersInLineOfSight; foreach (PlayerControllerB val in array) { if (!((Object)(object)val == (Object)null) && !val.isPlayerDead) { float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position); if (num2 < num) { num = num2; result = val; } } } return result; } private Vector3 GetRandomDestinationAtLeastDistance(float minDist) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) GameObject[] allAINodes = base.allAINodes; if (allAINodes == null || allAINodes.Length == 0) { return Vector3.zero; } List<GameObject> list = allAINodes.Where((GameObject n) => (Object)(object)n != (Object)null && Vector3.Distance(((Component)this).transform.position, n.transform.position) >= minDist).ToList(); if (list.Count == 0) { return allAINodes[Random.Range(0, allAINodes.Length)].transform.position; } return list[Random.Range(0, list.Count)].transform.position; } private void FaceMovementDirection() { //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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0045: 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_0056: Unknown result type (might be due to invalid IL or missing references) Vector3 velocity = base.agent.velocity; velocity.y = 0f; if (((Vector3)(ref velocity)).sqrMagnitude > 0.1f) { Quaternion val = Quaternion.LookRotation(((Vector3)(ref velocity)).normalized); ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val, Time.deltaTime * 10f); } } private void updatenearchasemask() { //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_0120: 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_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_0170: 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) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)this).IsServer) { return; } nearchaseupdatetimer -= Time.deltaTime; if (nearchaseupdatetimer > 0f) { return; } nearchaseupdatetimer = 0.2f; if (base.agent.path == null || base.agent.path.corners.Length == 0) { nearchasemask.Value = 0; return; } int num = 0; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val == (Object)null || val.isPlayerDead || !val.isInsideFactory || Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) > 30f) { continue; } Vector3[] corners = base.agent.path.corners; foreach (Vector3 val2 in corners) { if (!(Vector3.Distance(val2, ((Component)val).transform.position) > 20f)) { Vector3 val3 = val2 + Vector3.up * 1.8f; Vector3 val4 = ((Component)val).transform.position + Vector3.up * 1.8f; if (!Physics.Linecast(val3, val4, StartOfRound.Instance.collidersAndRoomMask)) { num |= 1 << (int)val.playerClientId; break; } } } } nearchasemask.Value = num; } private void checknearchase() { if (base.currentBehaviourStateIndex == 0) { if (nearchase.isPlaying) { nearchase.Stop(); } return; } PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)localPlayerController == (Object)null) { return; } if ((nearchasemask.Value & (1 << (int)localPlayerController.playerClientId)) != 0) { if (!nearchase.isPlaying) { nearchase.Play(); } } else if (nearchase.isPlaying) { nearchase.Stop(); } } private AudioClip getchasemusic() { if (Plugin.ChaseMusic.Value == Plugin.musicenum.Alpha1) { return chasealpha1; } if (Plugin.ChaseMusic.Value == Plugin.musicenum.Alpha1second) { return chasealpha1scary; } if (Plugin.ChaseMusic.Value == Plugin.musicenum.PreAlpha) { return chaseprealpha; } if (Plugin.ChaseMusic.Value == Plugin.musicenum.Song) { return chasesong; } if (Plugin.ChaseMusic.Value == Plugin.musicenum.Random) { int num = Random.Range(0, 10); if (num < 5) { return chasealpha1; } if (num < 8) { return chaseprealpha; } if (num == 8 && !Plugin.NoSongInRandom.Value) { return chasesong; } return chasealpha1scary; } return null; } private void SwitchState(int newState) { if (base.currentBehaviourStateIndex != newState) { ((EnemyAI)this).SwitchToBehaviourState(newState); } } protected override void __initializeVariables() { if (nearchasemask == null) { throw new Exception("NeighborAI.nearchasemask cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)nearchasemask).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)nearchasemask, "nearchasemask"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)nearchasemask); ((EnemyAI)this).__initializeVariables(); } protected internal override string __getTypeName() { return "NeighborAI"; } } [BepInPlugin("HelloNeighbor", "HelloNeighbor", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public enum musicenum { PreAlpha, Alpha1, Alpha1second, Song, Random } internal static ManualLogSource Logger; public static AssetBundle bundle; public static ConfigEntry<float> Speed; public static float DetectionRange = 45f; public static ConfigEntry<int> FovRange; public static ConfigEntry<int> TimeToStartGoingToRandomPlayer; public static ConfigEntry<musicenum> ChaseMusic; public static ConfigEntry<bool> NoSongInRandom; private void Awake() { //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: 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_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown //IL_0320: 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_0383: Unknown result type (might be due to invalid IL or missing references) Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Hello I'm your neighbor, goodbye, I'll see you later is loadingings"); NetcodePatcher(); Speed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Speed", 4.6f, "Speed of Hello i'm your neighbor"); FovRange = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Fov range", 120, "Fov of neighbor can detect you idk"); TimeToStartGoingToRandomPlayer = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Time to start going to random player", 140, "Determins how much time it takes for neighbor to start going to random player when he can't find you after selecting random rooms"); ChaseMusic = ((BaseUnityPlugin)this).Config.Bind<musicenum>("Music", "Chase music", musicenum.Random, "Music that will play when neighbor is chasing you (Client only)"); NoSongInRandom = ((BaseUnityPlugin)this).Config.Bind<bool>("Music", "No song in random", true, "If true the hello im your neighbor song won't be selected when neighbor is chasing. (Client only)"); if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig")) { lcmanager.configurelc(); } string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); bundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "modassets")); if ((Object)(object)bundle == (Object)null) { Logger.LogError((object)"there aint no bundle"); return; } GameObject val = bundle.LoadAsset<GameObject>("EnemyNeighbor"); if ((Object)(object)val == (Object)null) { Logger.LogError((object)"BUNDLE EXISTS BUT NO PREFAB WHAZAHELL"); return; } EnemyType val2 = ScriptableObject.CreateInstance<EnemyType>(); val2.enemyName = "Neighbor"; val2.enemyPrefab = val; val2.MaxCount = 1; val2.PowerLevel = 2f; val2.isOutsideEnemy = false; val2.isDaytimeEnemy = false; val2.canDie = false; val2.probabilityCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[3] { new Keyframe(0f, 0.3f), new Keyframe(0.4f, 0.9f), new Keyframe(1f, 1f) }); NeighborAI neighborAI = val.AddComponent<NeighborAI>(); ((EnemyAI)neighborAI).enemyType = val2; val2.enemyPrefab = val; Transform val3 = val.transform.Find("ScanNode"); if ((Object)(object)val3 != (Object)null) { ScanNodeProperties val4 = ((Component)val3).gameObject.AddComponent<ScanNodeProperties>(); val4.headerText = "Neighbor"; val4.subText = "He's your neighbor"; val4.nodeType = 1; val4.minRange = 1; val4.maxRange = 20; val4.creatureScanID = 73109; val4.requiresLineOfSight = true; } else { Logger.LogError((object)"ScanNode object not found"); } Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int> { { (LevelTypes)4, 10 }, { (LevelTypes)8, 0 }, { (LevelTypes)16, 30 }, { (LevelTypes)32, 10 }, { (LevelTypes)64, 25 }, { (LevelTypes)2048, 60 }, { (LevelTypes)128, 300 }, { (LevelTypes)256, 100 }, { (LevelTypes)512, 800 }, { (LevelTypes)4096, 1000 } }; SpawnType val5 = (SpawnType)0; LevelTypes val6 = (LevelTypes)(-1); TerminalNode val7 = ScriptableObject.CreateInstance<TerminalNode>(); val7.clearPreviousText = true; val7.displayText = "NEIGHBOR\n\nSigurd's danger level: 80%\n\nThe Neighbor watches his property closely. Given enough time, he will begin actively hunting trespassers. Once spotted, he will pursue relentlessly - only losing interest after a while."; val7.maxCharactersToType = 200; val7.creatureName = "Neighbor"; val7.creatureFileID = 73109; TerminalKeyword val8 = TerminalUtils.CreateTerminalKeyword("neighbor", false, (CompatibleNoun[])null, val7, (TerminalKeyword)null, false); NetworkPrefabs.RegisterNetworkPrefab(val2.enemyPrefab); Enemies.RegisterEnemy(val2, val5, dictionary, (Dictionary<string, int>)null, val7, val8); Logger.LogInfo((object)"Finished loading plugin"); } private static void NetcodePatcher() { try { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } } catch (Exception arg) { Logger.LogWarning((object)$"Couldn't patch netcode fuhh: {arg}"); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "HelloNeighbor"; public const string PLUGIN_NAME = "My first plugin"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace HelloNeighbor.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }