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 Haunted v1.2.0
Haunted.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; 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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.AI; using UnityEngine.Animations; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Haunted")] [assembly: AssemblyTitle("Haunted")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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] [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 RepoMods.DuplicatePlayers { public static class DuplicatePlayersPatcher { public static void Apply(Harmony harmony) { harmony.PatchAll(typeof(DuplicatePlayersPatcher).Assembly); Debug.Log((object)"[DuplicatePlayers] Patches applied."); } [RuntimeInitializeOnLoadMethod(/*Could not decode attribute arguments.*/)] private static void RuntimeInit() { SceneGuard.EnsureHooked(); LobbyLogGate.Ensure(); } } public static class Settings { public static bool IncludeLocalForTesting = true; public static bool ForceGameplayCheck = false; public static bool PreferLevelSpawnPoints = true; } public static class CloneTiming { public static readonly float MinSeconds = 30f; public static readonly float MaxSeconds = 60f; public static readonly float PostGenDelay = 10f; } public class LocalCloneMarker : MonoBehaviour { } public class CloneAnimationEventSink : MonoBehaviour { public void FootstepLight() { } public void PlayFootstep() { } public void Land() { } public void SlideStart() { } public void SlideStop() { } public void Roll() { } public void Jump() { } } public class CloneCollisionLocalizer : MonoBehaviour { private CharacterController _cc; private readonly HashSet<Collider> _currentlyIgnored = new HashSet<Collider>(); private float _nextRefreshAt; private void Awake() { _cc = ((Component)this).GetComponent<CharacterController>(); } private void OnEnable() { RefreshIgnores(fullReset: true); _nextRefreshAt = Time.time + 1f; } private void Update() { if (Time.time >= _nextRefreshAt) { _nextRefreshAt = Time.time + 1f; RefreshIgnores(fullReset: false); } } internal void RefreshIgnores(bool fullReset) { if ((Object)(object)_cc == (Object)null || (Object)(object)CloneManager.Instance == (Object)null) { return; } List<Collider> list = new List<Collider>(64); List<Collider> list2 = new List<Collider>(16); foreach (PlayerAvatar item in CloneManager.Instance.LiveAvatars()) { if ((Object)(object)item == (Object)null || (Object)(object)((Component)item).GetComponent<PlayerAvatarMenu>() != (Object)null) { continue; } bool flag = Patch_PlayerAvatar_Start.IsLocalPlayer(item); Collider[] componentsInChildren = ((Component)item).GetComponentsInChildren<Collider>(true); if (componentsInChildren != null && componentsInChildren.Length != 0) { if (flag) { list2.AddRange(componentsInChildren); } else { list.AddRange(componentsInChildren); } } } if (fullReset) { Collider[] array = _currentlyIgnored.ToArray(); foreach (Collider val in array) { if ((Object)(object)val == (Object)null) { _currentlyIgnored.Remove(val); continue; } Physics.IgnoreCollision((Collider)(object)_cc, val, false); _currentlyIgnored.Remove(val); } } for (int j = 0; j < list.Count; j++) { Collider val2 = list[j]; if (!((Object)(object)val2 == (Object)null) && _currentlyIgnored.Add(val2)) { Physics.IgnoreCollision((Collider)(object)_cc, val2, true); } } for (int k = 0; k < list2.Count; k++) { Collider val3 = list2[k]; if (!((Object)(object)val3 == (Object)null)) { if (_currentlyIgnored.Remove(val3)) { Physics.IgnoreCollision((Collider)(object)_cc, val3, false); } else { Physics.IgnoreCollision((Collider)(object)_cc, val3, false); } } } } } public class LobbyLogGate : MonoBehaviour { [CompilerGenerated] private static class <>O { public static LogCallback <0>__OnLog; } private static LobbyLogGate _instance; private static float _autoClearAt = -1f; public static bool IsBlocking { get; private set; } public static void Ensure() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (!((Object)(object)_instance != (Object)null)) { GameObject val = new GameObject("[DuplicatePlayers] LobbyLogGate"); Object.DontDestroyOnLoad((Object)(object)val); _instance = val.AddComponent<LobbyLogGate>(); } } private void OnEnable() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__OnLog; if (obj == null) { LogCallback val = OnLog; <>O.<0>__OnLog = val; obj = (object)val; } Application.logMessageReceived += (LogCallback)obj; } private void OnDisable() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__OnLog; if (obj == null) { LogCallback val = OnLog; <>O.<0>__OnLog = val; obj = (object)val; } Application.logMessageReceived -= (LogCallback)obj; } private static void OnLog(string condition, string stackTrace, LogType type) { if (!string.IsNullOrEmpty(condition) && condition.IndexOf("Unlocking lobby", StringComparison.OrdinalIgnoreCase) >= 0) { IsBlocking = true; _autoClearAt = Time.time + 60f; Debug.Log((object)"[DuplicatePlayers] LobbyLogGate: blocking due to 'Unlocking lobby'."); } } private void Update() { LevelGenerator instance = LevelGenerator.Instance; if (IsBlocking && (Object)(object)instance != (Object)null && instance.Generated && SceneGuard.GeneratedTrueAt > 0f && Time.time - SceneGuard.GeneratedTrueAt >= CloneTiming.PostGenDelay) { IsBlocking = false; _autoClearAt = -1f; Debug.Log((object)"[DuplicatePlayers] LobbyLogGate: unblocked after level generation + delay."); } if (IsBlocking && _autoClearAt > 0f && Time.time >= _autoClearAt) { IsBlocking = false; _autoClearAt = -1f; Debug.LogWarning((object)"[DuplicatePlayers] LobbyLogGate: auto-cleared after timeout."); } } } public class SceneGuard : MonoBehaviour { private static SceneGuard _instance; private bool _lastGenerated; internal static float GeneratedTrueAt = -1f; public static void EnsureHooked() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (!((Object)(object)_instance != (Object)null)) { GameObject val = new GameObject("[DuplicatePlayers] SceneGuard"); Object.DontDestroyOnLoad((Object)(object)val); _instance = val.AddComponent<SceneGuard>(); } } private void OnEnable() { SceneManager.activeSceneChanged += OnSceneChanged; } private void OnDisable() { SceneManager.activeSceneChanged -= OnSceneChanged; } private void OnSceneChanged(Scene from, Scene to) { LocalCloneMarker[] array = Object.FindObjectsOfType<LocalCloneMarker>(true); for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null) { Object.Destroy((Object)(object)((Component)array[i]).gameObject); } } _lastGenerated = false; GeneratedTrueAt = -1f; if ((Object)(object)CloneManager.Instance != (Object)null) { CloneManager.Instance.RequestRescheduleSoon(); } } private void Update() { LevelGenerator instance = LevelGenerator.Instance; bool flag = (Object)(object)instance != (Object)null && instance.Generated; if (flag && !_lastGenerated) { GeneratedTrueAt = Time.time; Debug.Log((object)$"[DuplicatePlayers] LevelGenerator.Generated true at t={GeneratedTrueAt:F1}"); } _lastGenerated = flag; } } internal static class LocalKillUtil { public static void TryKillLocal() { try { ChatManager val = ChatManager.instance ?? Object.FindObjectOfType<ChatManager>(true); if ((Object)(object)val != (Object)null) { val.PossessSelfDestruction(); Debug.Log((object)"[DuplicatePlayers] Local kill triggered via PossessSelfDestruction()."); } else { Debug.LogWarning((object)"[DuplicatePlayers] ChatManager not found; cannot self-destruct locally."); } } catch (Exception arg) { Debug.LogWarning((object)$"[DuplicatePlayers] Local kill failed: {arg}"); } } } public class IndependentCloneBrain : MonoBehaviour { [CompilerGenerated] private sealed class <TraverseLink>d__57 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Vector3 end; public IndependentCloneBrain <>4__this; private Vector3 <dir>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <TraverseLink>d__57(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //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_0045: 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_0094: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } Vector3 val = new Vector3(end.x, ((Component)<>4__this).transform.position.y, end.z) - ((Component)<>4__this).transform.position; if (((Vector3)(ref val)).sqrMagnitude > 0.04f) { <dir>5__1 = end - ((Component)<>4__this).transform.position; <dir>5__1.y = 0f; if (((Vector3)(ref <dir>5__1)).sqrMagnitude > 1E-05f) { ((Vector3)(ref <dir>5__1)).Normalize(); <>4__this.ApplyMove(<dir>5__1 * <>4__this.chaseSpeed); <>2__current = null; <>1__state = 1; return true; } } if ((Object)(object)<>4__this._agent != (Object)null) { <>4__this._agent.CompleteOffMeshLink(); } <>4__this._traversingLink = false; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [Header("Leash / Roam")] public Transform leashCenter; public float leashRadius = 18f; public float roamSpeed = 1f; public float turnSpeed = 420f; public float idleTimeMin = 0.8f; public float idleTimeMax = 2.2f; public float waypointMin = 6f; public float waypointMax = 14f; [Header("Chase")] public float chaseRadius = 25f; public float giveUpRadius = 35f; public float chaseSpeed = 1f; public float repathInterval = 0.33f; [Header("Physics")] public float gravity = 22f; public float groundStick = 2f; public float slopeLimit = 50f; public float stepOffset = 0.25f; public float skinWidth = 0.02f; [Header("Kill on Touch")] public float killTouchRadius = 0.65f; public float killCooldown = 1f; private float _killReadyAt = 0f; private Animator _anim; private NavMeshAgent _agent; private CharacterController _cc; private Vector3 _currentTarget; private float _idleUntil; private bool _hasTarget; private Quaternion _lastRot; private float _verticalVel; private bool _grounded; private Transform _chaseTarget; private float _nextRepathAt; private static readonly int ID_Moving = Animator.StringToHash("Moving"); private static readonly int ID_Sprinting = Animator.StringToHash("Sprinting"); private static readonly int ID_Crouching = Animator.StringToHash("Crouching"); private static readonly int ID_Crawling = Animator.StringToHash("Crawling"); private static readonly int ID_Sliding = Animator.StringToHash("Sliding"); private static readonly int ID_Turning = Animator.StringToHash("Turning"); private static readonly int ID_Tumbling = Animator.StringToHash("Tumbling"); private Vector3 _lastWorldPos; private float _stuckTimer; private bool _traversingLink; private void Awake() { //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_00ce: 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) _anim = ((Component)this).GetComponentInChildren<Animator>(); if ((Object)(object)_anim != (Object)null) { _anim.applyRootMotion = false; _anim.updateMode = (AnimatorUpdateMode)0; _anim.cullingMode = (AnimatorCullingMode)0; } _cc = ((Component)this).GetComponent<CharacterController>() ?? ((Component)this).gameObject.AddComponent<CharacterController>(); AutoSizeCharacterController(_cc, ((Component)this).gameObject); _cc.slopeLimit = slopeLimit; _cc.stepOffset = stepOffset; _cc.skinWidth = skinWidth; _cc.detectCollisions = true; _lastRot = ((Component)this).transform.rotation; _lastWorldPos = ((Component)this).transform.position; PickIdle(); } private void Update() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_024c: 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_0227: Unknown result type (might be due to invalid IL or missing references) //IL_019f: 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_01f5: 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_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_069c: Unknown result type (might be due to invalid IL or missing references) //IL_06a7: Unknown result type (might be due to invalid IL or missing references) //IL_06ac: Unknown result type (might be due to invalid IL or missing references) //IL_06b1: Unknown result type (might be due to invalid IL or missing references) //IL_06b5: Unknown result type (might be due to invalid IL or missing references) //IL_06c1: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_058d: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_042c: 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_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_06f8: Unknown result type (might be due to invalid IL or missing references) //IL_0706: Unknown result type (might be due to invalid IL or missing references) //IL_070b: Unknown result type (might be due to invalid IL or missing references) //IL_070d: Unknown result type (might be due to invalid IL or missing references) //IL_0715: Unknown result type (might be due to invalid IL or missing references) //IL_071a: Unknown result type (might be due to invalid IL or missing references) //IL_071b: Unknown result type (might be due to invalid IL or missing references) //IL_071d: Unknown result type (might be due to invalid IL or missing references) //IL_0722: Unknown result type (might be due to invalid IL or missing references) //IL_0727: Unknown result type (might be due to invalid IL or missing references) //IL_0735: Unknown result type (might be due to invalid IL or missing references) //IL_073a: Unknown result type (might be due to invalid IL or missing references) //IL_0748: Unknown result type (might be due to invalid IL or missing references) //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_05c1: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05d2: Unknown result type (might be due to invalid IL or missing references) //IL_05e2: Unknown result type (might be due to invalid IL or missing references) //IL_05ef: Unknown result type (might be due to invalid IL or missing references) //IL_05a5: Unknown result type (might be due to invalid IL or missing references) //IL_05b0: Unknown result type (might be due to invalid IL or missing references) //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_048f: 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) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_0614: Unknown result type (might be due to invalid IL or missing references) //IL_0616: Unknown result type (might be due to invalid IL or missing references) //IL_061b: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_062e: Unknown result type (might be due to invalid IL or missing references) //IL_0633: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0348: 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_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0757: Unknown result type (might be due to invalid IL or missing references) //IL_0762: Unknown result type (might be due to invalid IL or missing references) //IL_0792: Unknown result type (might be due to invalid IL or missing references) //IL_07ad: Unknown result type (might be due to invalid IL or missing references) //IL_07b3: Unknown result type (might be due to invalid IL or missing references) //IL_07b8: Unknown result type (might be due to invalid IL or missing references) //IL_07bd: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_0926: Unknown result type (might be due to invalid IL or missing references) //IL_092b: Unknown result type (might be due to invalid IL or missing references) //IL_0937: Unknown result type (might be due to invalid IL or missing references) //IL_093c: Unknown result type (might be due to invalid IL or missing references) //IL_083c: Unknown result type (might be due to invalid IL or missing references) //IL_0866: Unknown result type (might be due to invalid IL or missing references) //IL_08a8: Unknown result type (might be due to invalid IL or missing references) //IL_08c8: Unknown result type (might be due to invalid IL or missing references) //IL_08e3: Unknown result type (might be due to invalid IL or missing references) //IL_0900: Unknown result type (might be due to invalid IL or missing references) Vector3 center = (((Object)(object)leashCenter != (Object)null) ? leashCenter.position : ((Component)this).transform.position); Vector3 pos; if ((Object)(object)_agent == (Object)null) { pos = ((Component)this).transform.position; if (IsNavMeshReadyNear(in pos, 3f)) { NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(((Component)this).transform.position, ref val, 3f, -1)) { ((Component)this).transform.position = ((NavMeshHit)(ref val)).position; } _agent = ((Component)this).gameObject.AddComponent<NavMeshAgent>(); _agent.speed = roamSpeed; _agent.angularSpeed = turnSpeed; _agent.acceleration = 12f; _agent.stoppingDistance = 0.15f; _agent.autoBraking = false; _agent.autoRepath = true; _agent.updateRotation = false; _agent.updatePosition = false; _agent.obstacleAvoidanceType = (ObstacleAvoidanceType)4; _agent.radius = Mathf.Max(0.3f, _cc.radius * 0.9f); _agent.height = Mathf.Max(1.5f, _cc.height * 0.95f); _agent.baseOffset = 0f; _agent.avoidancePriority = Random.Range(30, 70); NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(((Component)this).transform.position, ref val2, 3f, _agent.areaMask)) { _agent.Warp(((NavMeshHit)(ref val2)).position); ((Component)this).transform.position = ((NavMeshHit)(ref val2)).position; } _agent.nextPosition = ((Component)this).transform.position; } } if (Time.time < _idleUntil) { DriveAnimator(0f, 0f); ApplyMove(Vector3.zero); ProximityTouchKill(); SyncAgentToController(); return; } RefreshChaseTarget(); Vector3 horizontalVelocity = Vector3.zero; if ((Object)(object)_chaseTarget != (Object)null) { if ((Object)(object)_agent != (Object)null && _agent.isOnNavMesh) { _agent.speed = chaseSpeed; if (Time.time >= _nextRepathAt) { _nextRepathAt = Time.time + repathInterval; if (TryGetChaseDestination(_chaseTarget.position, out var dest)) { _agent.SetDestination(dest); } } if (!_agent.pathPending) { Vector3 desiredVelocity = _agent.desiredVelocity; if (((Vector3)(ref desiredVelocity)).sqrMagnitude > 0.0001f) { horizontalVelocity = ((Vector3)(ref desiredVelocity)).normalized * chaseSpeed; } Vector3 steeringTarget = _agent.steeringTarget; Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(steeringTarget.x - ((Component)this).transform.position.x, 0f, steeringTarget.z - ((Component)this).transform.position.z); if (((Vector3)(ref val3)).sqrMagnitude > 1E-05f) { Quaternion val4 = Quaternion.LookRotation(val3, Vector3.up); ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, val4, turnSpeed * Time.deltaTime); } } } else { Vector3 val5 = _chaseTarget.position - ((Component)this).transform.position; Vector3 val6 = default(Vector3); ((Vector3)(ref val6))..ctor(val5.x, 0f, val5.z); float magnitude = ((Vector3)(ref val6)).magnitude; if (magnitude > 0.1f) { Vector3 val7 = val6 / Mathf.Max(magnitude, 0.0001f); horizontalVelocity = val7 * chaseSpeed; Quaternion val8 = Quaternion.LookRotation(val7, Vector3.up); ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, val8, turnSpeed * Time.deltaTime); } } pos = _chaseTarget.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref pos)).sqrMagnitude; if (sqrMagnitude > giveUpRadius * giveUpRadius) { _chaseTarget = null; PickIdle(); } } else { if (!_hasTarget) { _currentTarget = PickRoamPoint(center, leashRadius, waypointMin, waypointMax); _hasTarget = true; if ((Object)(object)_agent != (Object)null && _agent.isOnNavMesh) { _agent.speed = roamSpeed; _agent.SetDestination(_currentTarget); } } if ((Object)(object)_agent != (Object)null && _agent.isOnNavMesh) { Vector3 desiredVelocity2 = _agent.desiredVelocity; if (((Vector3)(ref desiredVelocity2)).sqrMagnitude > 0.0001f) { horizontalVelocity = ((Vector3)(ref desiredVelocity2)).normalized * roamSpeed; } Vector3 steeringTarget2 = _agent.steeringTarget; Vector3 val9 = default(Vector3); ((Vector3)(ref val9))..ctor(steeringTarget2.x - ((Component)this).transform.position.x, 0f, steeringTarget2.z - ((Component)this).transform.position.z); if (((Vector3)(ref val9)).sqrMagnitude > 1E-05f) { Quaternion val10 = Quaternion.LookRotation(val9, Vector3.up); ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, val10, turnSpeed * Time.deltaTime); } if (!_agent.pathPending && _agent.remainingDistance <= _agent.stoppingDistance + 0.05f) { _hasTarget = false; PickIdle(); } } else { Vector3 val11 = _currentTarget - ((Component)this).transform.position; Vector3 val12 = default(Vector3); ((Vector3)(ref val12))..ctor(val11.x, 0f, val11.z); float magnitude2 = ((Vector3)(ref val12)).magnitude; if (magnitude2 < 0.1f) { _hasTarget = false; PickIdle(); } else { Vector3 val13 = val12 / Mathf.Max(magnitude2, 0.0001f); horizontalVelocity = val13 * roamSpeed; Quaternion val14 = Quaternion.LookRotation(val13, Vector3.up); ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, val14, turnSpeed * Time.deltaTime); } } } float angularSpeedPerSec = Mathf.Abs(AngularSpeed(_lastRot, ((Component)this).transform.rotation)) / Mathf.Max(Time.deltaTime, 1E-05f); DriveAnimator(((Vector3)(ref horizontalVelocity)).magnitude, angularSpeedPerSec); ApplyMove(horizontalVelocity); HandleOffMeshLink(); ProximityTouchKill(); pos = ((Component)this).transform.position - _lastWorldPos; float magnitude3 = ((Vector3)(ref pos)).magnitude; if (((Vector3)(ref horizontalVelocity)).sqrMagnitude > 0.01f && magnitude3 < 0.01f) { _stuckTimer += Time.deltaTime; } else { _stuckTimer = 0f; } if ((Object)(object)_agent != (Object)null) { if (!_agent.isOnNavMesh) { NavMeshHit val15 = default(NavMeshHit); if (NavMesh.SamplePosition(((Component)this).transform.position, ref val15, 2.5f, _agent.areaMask)) { _agent.Warp(((NavMeshHit)(ref val15)).position); } } else if (_stuckTimer > 0.75f && !_agent.pathPending) { _agent.Warp(((Component)this).transform.position); if ((Object)(object)_chaseTarget != (Object)null && TryGetChaseDestination(_chaseTarget.position, out var dest2)) { _agent.SetDestination(dest2); } else if (_hasTarget) { _agent.SetDestination(_currentTarget); } _stuckTimer = 0f; } } SyncAgentToController(); _lastRot = ((Component)this).transform.rotation; _lastWorldPos = ((Component)this).transform.position; } private void RefreshChaseTarget() { //IL_0081: 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_003f: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)CloneManager.Instance == (Object)null) { _chaseTarget = null; return; } Vector3 val; if ((Object)(object)_chaseTarget != (Object)null) { val = _chaseTarget.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude <= giveUpRadius * giveUpRadius) { return; } _chaseTarget = null; } PlayerAvatar val2 = CloneManager.Instance.FindNearest(((Component)this).transform.position, Settings.IncludeLocalForTesting); if ((Object)(object)val2 != (Object)null) { val = ((Component)val2).transform.position - ((Component)this).transform.position; float sqrMagnitude2 = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude2 <= chaseRadius * chaseRadius) { _chaseTarget = ((Component)val2).transform; } } } private void SyncAgentToController() { //IL_001f: 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_0040: 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_0069: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_agent == (Object)null)) { _agent.nextPosition = ((Component)this).transform.position; Vector3 val = ((Component)_agent).transform.position - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude > 0.25f) { _agent.Warp(((Component)this).transform.position); } } } private void ApplyMove(Vector3 horizontalVelocity) { //IL_006e: 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_0087: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) float deltaTime = Time.deltaTime; if (!(deltaTime <= 0f)) { _grounded = _cc.isGrounded; if (_grounded && _verticalVel < 0f) { _verticalVel = 0f - groundStick; } else { _verticalVel -= gravity * deltaTime; } Vector3 val = horizontalVelocity * deltaTime + new Vector3(0f, _verticalVel * deltaTime, 0f); CollisionFlags val2 = _cc.Move(val); if ((val2 & 2) != 0 && _verticalVel > 0f) { _verticalVel = 0f; } if ((val2 & 4) != 0 && _verticalVel < 0f - groundStick) { _verticalVel = 0f - groundStick; } } } private void PickIdle() { _idleUntil = Time.time + Random.Range(idleTimeMin, idleTimeMax); } private Vector3 PickRoamPoint(Vector3 center, float radius, float minStep, float maxStep) { //IL_0032: 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_0035: 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_003f: 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_0070: 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_0067: 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_0075: Unknown result type (might be due to invalid IL or missing references) float num = Random.Range(minStep, maxStep); float num2 = Random.Range(0f, MathF.PI * 2f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Mathf.Cos(num2), 0f, Mathf.Sin(num2)); Vector3 pos = center + val * num; NavMeshHit val2 = default(NavMeshHit); if (IsNavMeshReadyNear(in pos, 5f) && NavMesh.SamplePosition(pos, ref val2, 5f, -1)) { return ((NavMeshHit)(ref val2)).position; } return pos; } private void DriveAnimator(float linearSpeed, float angularSpeedPerSec) { if (!((Object)(object)_anim == (Object)null)) { bool flag = linearSpeed > 0.05f; bool flag2 = angularSpeedPerSec > 15f; _anim.SetBool(ID_Moving, flag); _anim.SetBool(ID_Turning, flag2); _anim.SetBool(ID_Sprinting, false); _anim.SetBool(ID_Crouching, false); _anim.SetBool(ID_Crawling, false); _anim.SetBool(ID_Sliding, false); _anim.SetBool(ID_Tumbling, false); } } private static float AngularSpeed(Quaternion a, Quaternion b) { //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_0003: 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_000d: Unknown result type (might be due to invalid IL or missing references) Quaternion val = b * Quaternion.Inverse(a); Vector3 val2 = default(Vector3); float num = default(float); ((Quaternion)(ref val)).ToAngleAxis(ref num, ref val2); num = Mathf.Repeat(num + 180f, 360f) - 180f; return Mathf.Abs(num); } public static bool IsNavMeshReadyNear(in Vector3 pos, float maxDistance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) NavMeshTriangulation val = NavMesh.CalculateTriangulation(); if (val.vertices == null || val.vertices.Length == 0) { return false; } NavMeshHit val2 = default(NavMeshHit); return NavMesh.SamplePosition(pos, ref val2, maxDistance, -1); } public static void AutoSizeCharacterController(CharacterController cc, GameObject root) { //IL_0011: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true); Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(root.transform.position, Vector3.one * 0.5f); bool flag = false; Renderer[] array = componentsInChildren; foreach (Renderer val in array) { if (val.enabled && (val is SkinnedMeshRenderer || val is MeshRenderer)) { if (!flag) { bounds = val.bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val.bounds); } } } float num = Mathf.Clamp(((Bounds)(ref bounds)).size.y, 1.4f, 2.4f); float radius = Mathf.Clamp(Mathf.Max(((Bounds)(ref bounds)).extents.x, ((Bounds)(ref bounds)).extents.z) * 0.6f, 0.25f, 0.6f); cc.center = new Vector3(0f, num * 0.5f, 0f); cc.height = num; cc.radius = radius; } private void TryTouchKill(PlayerAvatar victim) { if (!((Object)(object)victim == (Object)null) && !(Time.time < _killReadyAt) && !((Object)(object)((Component)victim).GetComponent<PlayerAvatarMenu>() != (Object)null) && Patch_PlayerAvatar_Start.IsLocalPlayer(victim)) { _killReadyAt = Time.time + killCooldown; LocalKillUtil.TryKillLocal(); } } private void ProximityTouchKill() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) if (Time.time < _killReadyAt || (Object)(object)CloneManager.Instance == (Object)null) { return; } foreach (PlayerAvatar item in CloneManager.Instance.LiveAvatars()) { if (!((Object)(object)item == (Object)null) && Patch_PlayerAvatar_Start.IsLocalPlayer(item) && !((Object)(object)((Component)item).GetComponent<PlayerAvatarMenu>() != (Object)null)) { Vector3 val = ((Component)item).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude <= killTouchRadius * killTouchRadius) { TryTouchKill(item); break; } } } } private void OnControllerColliderHit(ControllerColliderHit hit) { if (hit != null && !((Object)(object)hit.collider == (Object)null)) { PlayerAvatar componentInParent = ((Component)hit.collider).GetComponentInParent<PlayerAvatar>(); if (!((Object)(object)componentInParent == (Object)null)) { TryTouchKill(componentInParent); } } } private bool TryGetChaseDestination(Vector3 targetWorldPos, out Vector3 dest) { //IL_001e: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) int num = (((Object)(object)_agent != (Object)null) ? _agent.areaMask : (-1)); NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(targetWorldPos, ref val, 2f, num)) { dest = ((NavMeshHit)(ref val)).position; return true; } for (int i = 0; i < 6; i++) { float num2 = 3f + 1.5f * (float)i; Vector3 val2 = targetWorldPos + Random.insideUnitSphere * num2; val2.y = targetWorldPos.y; if (NavMesh.SamplePosition(val2, ref val, 1.75f, num)) { dest = ((NavMeshHit)(ref val)).position; return true; } } dest = default(Vector3); return false; } private void HandleOffMeshLink() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_agent == (Object)null) && _agent.isOnNavMesh && _agent.isOnOffMeshLink && !_traversingLink) { _traversingLink = true; OffMeshLinkData currentOffMeshLinkData = _agent.currentOffMeshLinkData; ((MonoBehaviour)this).StartCoroutine(TraverseLink(((OffMeshLinkData)(ref currentOffMeshLinkData)).endPos)); } } [IteratorStateMachine(typeof(<TraverseLink>d__57))] private IEnumerator TraverseLink(Vector3 end) { //IL_000e: 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) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <TraverseLink>d__57(0) { <>4__this = this, end = end }; } public static bool TrySnapToNavMesh(Transform t, float maxDist, int areaMask = -1) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(t.position, ref val, maxDist, areaMask)) { t.position = ((NavMeshHit)(ref val)).position; return true; } return false; } } public class CloneManager : MonoBehaviour { private struct LevelPoint { public Vector3 pos; public Quaternion rot; } [CompilerGenerated] private sealed class <LiveAvatars>d__30 : IEnumerable<PlayerAvatar>, IEnumerable, IEnumerator<PlayerAvatar>, IEnumerator, IDisposable { private int <>1__state; private PlayerAvatar <>2__current; private int <>l__initialThreadId; public CloneManager <>4__this; private int <i>5__1; private PlayerAvatar <a>5__2; PlayerAvatar IEnumerator<PlayerAvatar>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LiveAvatars>d__30(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <a>5__2 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; goto IL_0087; } <>1__state = -1; <>4__this.PruneAvatars(); <i>5__1 = 0; goto IL_009e; IL_0087: <a>5__2 = null; <i>5__1++; goto IL_009e; IL_009e: if (<i>5__1 < <>4__this._avatars.Count) { if (<>4__this._avatars[<i>5__1].TryGetTarget(out <a>5__2) && (Object)(object)<a>5__2 != (Object)null) { <>2__current = <a>5__2; <>1__state = 1; return true; } goto IL_0087; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<PlayerAvatar> IEnumerable<PlayerAvatar>.GetEnumerator() { <LiveAvatars>d__30 result; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; result = this; } else { result = new <LiveAvatars>d__30(0) { <>4__this = <>4__this }; } return result; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<PlayerAvatar>)this).GetEnumerator(); } } public static CloneManager Instance; private readonly List<WeakReference<PlayerAvatar>> _avatars = new List<WeakReference<PlayerAvatar>>(); private LocalCloneMarker _activeClone; private float _switchAt; private float _rescheduleAt; private CloneCollisionLocalizer _collisionLocalizer; private float _despawnAt = -1f; private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); ScheduleNext(); } public void RequestRescheduleSoon() { _rescheduleAt = Time.time + 0.5f; } private void Update() { if (!Patch_PlayerAvatar_Start.SceneLooksLikeGameplay()) { DestroyActive(); return; } if (_rescheduleAt > 0f && Time.time >= _rescheduleAt) { _rescheduleAt = 0f; ScheduleNext(); } PruneAvatars(); if (!GameplayReady()) { return; } if ((Object)(object)_activeClone != (Object)null) { if (_despawnAt > 0f && Time.time >= _despawnAt) { DestroyActive(); ScheduleNext(); } } else if (Time.time >= _switchAt) { TrySpawnNearCandidate(); } } private static bool GameplayReady() { if (SemiFunc.IsMainMenu()) { return false; } if (LobbyLogGate.IsBlocking) { return false; } LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance == (Object)null || !instance.Generated) { return false; } if (SceneGuard.GeneratedTrueAt < 0f) { return false; } if (Time.time - SceneGuard.GeneratedTrueAt < CloneTiming.PostGenDelay) { return false; } return true; } public static void Ensure() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (!((Object)(object)Instance != (Object)null)) { GameObject val = new GameObject("[DuplicatePlayers] CloneManager"); Object.DontDestroyOnLoad((Object)(object)val); val.AddComponent<CloneManager>(); } } public static void Register(PlayerAvatar a) { Ensure(); SceneGuard.EnsureHooked(); Instance._avatars.Add(new WeakReference<PlayerAvatar>(a)); Instance.RefreshCloneCollisionFilters(); } public static void Unregister(PlayerAvatar a) { if (!((Object)(object)Instance == (Object)null)) { Instance.PruneAvatars(); Instance.RefreshCloneCollisionFilters(); } } private void PruneAvatars() { for (int num = _avatars.Count - 1; num >= 0; num--) { if (!_avatars[num].TryGetTarget(out PlayerAvatar target) || (Object)(object)target == (Object)null) { _avatars.RemoveAt(num); } } } private void TrySpawnNearCandidate() { //IL_0021: 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_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) if (Settings.PreferLevelSpawnPoints && TryPickLevelPointSpawn(out Vector3 pos, out Quaternion rot, out PlayerAvatar leashAvatar)) { _activeClone = SpawnCloneFor(leashAvatar, pos, rot); if ((Object)(object)_activeClone != (Object)null) { _despawnAt = Time.time + Random.Range(CloneTiming.MinSeconds, CloneTiming.MaxSeconds); return; } } List<PlayerAvatar> candidates = GetCandidates(); if (candidates.Count == 0) { ScheduleNext(); return; } candidates.Sort(delegate(PlayerAvatar a, PlayerAvatar b) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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) int num; if ((Object)(object)a != (Object)null) { Vector3 pos3 = ((Component)a).transform.position; num = (IndependentCloneBrain.IsNavMeshReadyNear(in pos3, 6f) ? 1 : 0); } else { num = 0; } bool flag = (byte)num != 0; int num2; if ((Object)(object)b != (Object)null) { Vector3 pos3 = ((Component)b).transform.position; num2 = (IndependentCloneBrain.IsNavMeshReadyNear(in pos3, 6f) ? 1 : 0); } else { num2 = 0; } bool flag2 = (byte)num2 != 0; return (flag != flag2) ? ((!flag) ? 1 : (-1)) : 0; }); PlayerAvatar val = candidates[Random.Range(0, candidates.Count)]; if (!TryFindValidSpawnPose(val, out var pos2, out var rot2)) { _switchAt = Time.time + 2f; return; } _activeClone = SpawnCloneFor(val, pos2, rot2); if ((Object)(object)_activeClone != (Object)null) { _despawnAt = Time.time + Random.Range(CloneTiming.MinSeconds, CloneTiming.MaxSeconds); } else { _switchAt = Time.time + 2f; } } private void ScheduleNext() { _switchAt = Time.time + Random.Range(CloneTiming.MinSeconds, CloneTiming.MaxSeconds); } private List<PlayerAvatar> GetCandidates() { PruneAvatars(); List<PlayerAvatar> list = new List<PlayerAvatar>(); foreach (WeakReference<PlayerAvatar> avatar in _avatars) { if (avatar.TryGetTarget(out var target) && !((Object)(object)target == (Object)null) && !((Object)(object)((Component)target).GetComponent<PlayerAvatarMenu>() != (Object)null)) { bool flag = Patch_PlayerAvatar_Start.IsLocalPlayer(target); if (!(!Settings.IncludeLocalForTesting && flag) && LooksAliveAndRenderable(target)) { list.Add(target); } } } return list; } private void DestroyActive() { if ((Object)(object)_activeClone != (Object)null) { Object.Destroy((Object)(object)((Component)_activeClone).gameObject); } _activeClone = null; _collisionLocalizer = null; _despawnAt = -1f; } private LocalCloneMarker SpawnCloneFor(PlayerAvatar leashAvatar, Vector3 spawnPos, Quaternion spawnRot) { //IL_009a: 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_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Expected O, but got Unknown //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03de: 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) try { if ((Object)(object)leashAvatar == (Object)null) { return null; } PlayerAvatarVisuals val = leashAvatar.playerAvatarVisuals ?? ((Component)leashAvatar).GetComponentInChildren<PlayerAvatarVisuals>(true); if ((Object)(object)val == (Object)null) { return null; } GameObject gameObject = ((Component)val).gameObject; GameObject val2 = Object.Instantiate<GameObject>(gameObject); ((Object)val2).name = ((Object)gameObject).name + " (Omniscye Clone — FreeRoam)"; int num = ((Component)leashAvatar).gameObject.layer; if (num < 0) { num = LayerMask.NameToLayer("Default"); } val2.layer = num; LocalCloneMarker result = val2.AddComponent<LocalCloneMarker>(); val2.transform.SetPositionAndRotation(spawnPos, spawnRot); Patch_PlayerAvatar_Start.DecoupleFromOriginal(val2, leashAvatar); PlayerAvatarVisuals[] componentsInChildren = val2.GetComponentsInChildren<PlayerAvatarVisuals>(true); for (int i = 0; i < componentsInChildren.Length; i++) { try { ((Behaviour)componentsInChildren[i]).enabled = false; componentsInChildren[i].playerAvatar = null; componentsInChildren[i].isMenuAvatar = true; } catch { } try { Object.Destroy((Object)(object)componentsInChildren[i]); } catch { } } Animator[] componentsInChildren2 = val2.GetComponentsInChildren<Animator>(true); foreach (Animator val3 in componentsInChildren2) { if (!((Object)(object)val3 == (Object)null)) { ((Behaviour)val3).enabled = true; val3.keepAnimatorStateOnDisable = true; val3.applyRootMotion = false; val3.updateMode = (AnimatorUpdateMode)0; val3.cullingMode = (AnimatorCullingMode)0; if (val3.speed <= 0f) { val3.speed = 0.98f + Random.Range(-0.03f, 0.03f); } if ((Object)(object)((Component)val3).gameObject.GetComponent<CloneAnimationEventSink>() == (Object)null) { ((Component)val3).gameObject.AddComponent<CloneAnimationEventSink>(); } } } EnsureCloneRenderersReallyVisible(val2); CharacterController val4 = val2.GetComponent<CharacterController>() ?? val2.AddComponent<CharacterController>(); IndependentCloneBrain.AutoSizeCharacterController(val4, val2); val4.slopeLimit = 50f; val4.stepOffset = 0.25f; val4.skinWidth = 0.02f; val4.detectCollisions = true; _collisionLocalizer = val2.GetComponent<CloneCollisionLocalizer>() ?? val2.AddComponent<CloneCollisionLocalizer>(); ((Component)_collisionLocalizer).SendMessage("RefreshIgnores", (object)true, (SendMessageOptions)1); SnapToGround(val2); if (!IndependentCloneBrain.TrySnapToNavMesh(val2.transform, 4f)) { Object.Destroy((Object)(object)val2); return null; } val4.Move(Vector3.zero); IndependentCloneBrain independentCloneBrain = val2.AddComponent<IndependentCloneBrain>(); independentCloneBrain.leashCenter = ((Component)leashAvatar).transform; independentCloneBrain.leashRadius = 22f; independentCloneBrain.chaseRadius = 25f; independentCloneBrain.giveUpRadius = 35f; independentCloneBrain.chaseSpeed = 1f; independentCloneBrain.repathInterval = 0.33f; Collider[] componentsInChildren3 = val2.GetComponentsInChildren<Collider>(true); foreach (Collider val5 in componentsInChildren3) { if (!(val5 is CharacterController)) { val5.enabled = false; } } Rigidbody[] componentsInChildren4 = val2.GetComponentsInChildren<Rigidbody>(true); foreach (Rigidbody val6 in componentsInChildren4) { Object.Destroy((Object)(object)val6); } PlayerAvatar[] componentsInChildren5 = val2.GetComponentsInChildren<PlayerAvatar>(true); foreach (PlayerAvatar val7 in componentsInChildren5) { if ((Object)(object)val7 != (Object)(object)leashAvatar) { Object.Destroy((Object)(object)val7); } } FixAndAttachNameToHead(val2, "Omniscye"); Debug.Log((object)"[DuplicatePlayers] Spawned Omniscye clone."); GameObject val8 = new GameObject("DoorBumper"); val8.transform.SetParent(val2.transform, false); val8.transform.localPosition = Vector3.zero; val8.transform.localRotation = Quaternion.identity; val8.layer = val2.layer; CapsuleCollider val9 = val8.AddComponent<CapsuleCollider>(); val9.height = val4.height; val9.radius = val4.radius; val9.center = val4.center; ((Collider)val9).isTrigger = false; Rigidbody val10 = val8.AddComponent<Rigidbody>(); val10.isKinematic = true; val10.interpolation = (RigidbodyInterpolation)1; val10.collisionDetectionMode = (CollisionDetectionMode)3; val10.constraints = (RigidbodyConstraints)112; DoorBumperFollower doorBumperFollower = val8.AddComponent<DoorBumperFollower>(); doorBumperFollower.target = val2.transform; return result; } catch (Exception arg) { Debug.LogWarning((object)$"[DuplicatePlayers] SpawnCloneFor failed: {arg}"); return null; } } private void RefreshCloneCollisionFilters() { if ((Object)(object)_collisionLocalizer != (Object)null) { ((Component)_collisionLocalizer).SendMessage("RefreshIgnores", (object)true, (SendMessageOptions)1); } } private static void SnapToGround(GameObject go) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_00a3: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_008f: 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_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) CharacterController component = go.GetComponent<CharacterController>(); Vector3 val = go.transform.position + Vector3.up * 1.5f; RaycastHit val2 = default(RaycastHit); NavMeshHit val3 = default(NavMeshHit); if (Physics.Raycast(val, Vector3.down, ref val2, 11.5f, -1, (QueryTriggerInteraction)1)) { float num = (((Object)(object)component != (Object)null) ? (component.center.y - component.height * 0.5f) : 0f); go.transform.position = ((RaycastHit)(ref val2)).point - new Vector3(0f, num - 0.02f, 0f); } else if (NavMesh.SamplePosition(go.transform.position, ref val3, 6f, -1)) { float num2 = (((Object)(object)component != (Object)null) ? (component.center.y - component.height * 0.5f) : 0f); go.transform.position = ((NavMeshHit)(ref val3)).position - new Vector3(0f, num2 - 0.02f, 0f); } } private static void FixAndAttachNameToHead(GameObject root, string label) { //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) Component[] componentsInChildren = root.GetComponentsInChildren<Component>(true); foreach (Component val in componentsInChildren) { if ((Object)(object)val == (Object)null) { continue; } string name = ((object)val).GetType().Name; if (name.IndexOf("Name", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("Nameplate", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("WorldSpaceUIPlayerName", StringComparison.OrdinalIgnoreCase) < 0) { continue; } Behaviour val2 = (Behaviour)(object)((val is Behaviour) ? val : null); if (val2 != null) { val2.enabled = false; } if (!(val is Transform)) { try { Object.Destroy((Object)(object)val); } catch { } } } Transform val3 = null; Animator componentInChildren = root.GetComponentInChildren<Animator>(); if ((Object)(object)componentInChildren != (Object)null && componentInChildren.isHuman) { try { val3 = componentInChildren.GetBoneTransform((HumanBodyBones)10); } catch { } } if ((Object)(object)val3 == (Object)null) { val3 = ((IEnumerable<Transform>)root.GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => (Object)(object)t != (Object)null && ((Object)t).name.ToLowerInvariant().Contains("head"))); } if ((Object)(object)val3 == (Object)null) { val3 = root.transform; } Transform val4 = root.transform.Find("Omniscye_Label"); if ((Object)(object)val4 != (Object)null) { Object.Destroy((Object)(object)((Component)val4).gameObject); } GameObject val5 = new GameObject("Omniscye_Label"); val5.transform.SetParent(val3, false); val5.transform.localPosition = new Vector3(0f, 0.78f, 0f); val5.transform.localRotation = Quaternion.identity; val5.transform.localScale = Vector3.one; val5.AddComponent<SimpleBillboard>(); TextMesh val6 = val5.AddComponent<TextMesh>(); val6.text = label; val6.anchor = (TextAnchor)7; val6.characterSize = 0.04f; val6.fontSize = 48; val6.richText = false; val6.color = Color.red; } private bool TryPickLevelPointSpawn(out Vector3 pos, out Quaternion rot, out PlayerAvatar leashAvatar) { //IL_0005: 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_0011: 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_0053: 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_0062: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00a8: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: 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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) leashAvatar = null; pos = default(Vector3); rot = Quaternion.identity; List<Transform> list = FindAllLikelyLevelPoints(); if (list.Count == 0) { return false; } List<LevelPoint> list2 = new List<LevelPoint>(list.Count); NavMeshHit val = default(NavMeshHit); for (int i = 0; i < list.Count; i++) { Vector3 position = list[i].position; Quaternion rotation = list[i].rotation; if (NavMesh.SamplePosition(position, ref val, 3f, -1) && HasGroundSupport(((NavMeshHit)(ref val)).position, 4f)) { list2.Add(new LevelPoint { pos = ((NavMeshHit)(ref val)).position, rot = rotation }); } } if (list2.Count == 0) { return false; } List<PlayerAvatar> candidates = GetCandidates(); LevelPoint levelPoint = list2[Random.Range(0, list2.Count)]; float num = float.PositiveInfinity; PlayerAvatar val2 = null; for (int j = 0; j < candidates.Count; j++) { PlayerAvatar val3 = candidates[j]; if (!((Object)(object)val3 == (Object)null)) { Vector3 val4 = ((Component)val3).transform.position - levelPoint.pos; float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val2 = val3; } } } leashAvatar = val2 ?? candidates.FirstOrDefault(); pos = levelPoint.pos; rot = levelPoint.rot; return (Object)(object)leashAvatar != (Object)null; } private List<Transform> FindAllLikelyLevelPoints() { List<Transform> list = new List<Transform>(64); MonoBehaviour[] array = Object.FindObjectsOfType<MonoBehaviour>(true); foreach (MonoBehaviour val in array) { if ((Object)(object)val == (Object)null) { continue; } string text = ((object)val).GetType().Name.ToLowerInvariant(); if (text.Contains("levelpoint") || text.Contains("levelspawn") || text.Contains("enemyspawn") || text.Contains("spawnpoint") || text.Contains("aispawn") || text.Contains("respawnpoint") || text.Contains("wavespawn") || text.Contains("spawner")) { Transform transform = ((Component)val).transform; if ((Object)(object)transform != (Object)null && ((Component)transform).gameObject.activeInHierarchy) { list.Add(transform); } } } Transform[] array2 = Object.FindObjectsOfType<Transform>(true); foreach (Transform val2 in array2) { if (!((Object)(object)val2 == (Object)null)) { string text2 = ((Object)val2).name.ToLowerInvariant(); if ((text2.Contains("levelpoint") || text2.Contains("levelspawn") || text2.Contains("enemyspawn") || text2.Contains("spawnpoint") || text2.Contains("aispawn") || text2.Contains("respawn") || text2.Contains("wavespawn") || text2.Contains("spawner")) && ((Component)val2).gameObject.activeInHierarchy) { list.Add(val2); } } } return list.Distinct().ToList(); } private static bool LooksAliveAndRenderable(PlayerAvatar a) { if ((Object)(object)a == (Object)null || !((Component)a).gameObject.activeInHierarchy) { return false; } try { Type type = ((object)a).GetType(); FieldInfo field = type.GetField("isDead", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field.FieldType == typeof(bool) && (bool)field.GetValue(a)) { return false; } PropertyInfo property = type.GetProperty("IsDead", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.PropertyType == typeof(bool) && (bool)property.GetValue(a)) { return false; } } catch { } PlayerAvatarVisuals val = a.playerAvatarVisuals ?? ((Component)a).GetComponentInChildren<PlayerAvatarVisuals>(true); if ((Object)(object)val == (Object)null) { return false; } Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null && val2.enabled) { return true; } } return false; } private static void EnsureCloneRenderersReallyVisible(GameObject root) { //IL_00e7: 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_0111: Unknown result type (might be due to invalid IL or missing references) Transform[] componentsInChildren = root.GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Component)val).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(true); } } Renderer[] componentsInChildren2 = root.GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren2) { if ((Object)(object)val2 == (Object)null) { continue; } val2.enabled = true; val2.forceRenderingOff = false; try { Material[] array = ((val2 is SkinnedMeshRenderer || val2 is MeshRenderer) ? val2.materials : null); if (array != null) { foreach (Material val3 in array) { if (!((Object)(object)val3 == (Object)null) && val3.HasProperty("_Color")) { Color color = val3.color; if (color.a < 0.98f) { color.a = 1f; val3.color = color; } } } } } catch { } SkinnedMeshRenderer val4 = (SkinnedMeshRenderer)(object)((val2 is SkinnedMeshRenderer) ? val2 : null); if (val4 != null) { val4.updateWhenOffscreen = true; } } } private static bool TryFindValidSpawnPose(PlayerAvatar host, out Vector3 pos, out Quaternion rot) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_006f: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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) //IL_00ad: 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_00c3: 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_0104: 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_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_0119: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_0134: 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_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_0155: 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_016b: Unknown result type (might be due to invalid IL or missing references) pos = default(Vector3); rot = (((Object)(object)host != (Object)null) ? ((Component)host).transform.rotation : Quaternion.identity); if ((Object)(object)host == (Object)null) { return false; } Transform transform = ((Component)host).transform; float num = 9f; float num2 = 2.2f * ((Patch_PlayerAvatar_Start.GetStableSeed(host) % 2 == 0) ? 1f : (-1f)); Vector3 val = transform.position - transform.forward * num + transform.right * num2; NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(val, ref val2, 3f, -1)) { Vector3 position = ((NavMeshHit)(ref val2)).position; if (HasGroundSupport(position, 3.5f)) { pos = position; return true; } } for (int i = 0; i < 12; i++) { float num3 = 3f + 0.75f * (float)i; float num4 = 30f * (float)i; Vector3 val3 = Quaternion.Euler(0f, num4, 0f) * -transform.forward; Vector3 val4 = transform.position + ((Vector3)(ref val3)).normalized * num3; if (NavMesh.SamplePosition(val4, ref val2, 2.5f, -1)) { Vector3 position2 = ((NavMeshHit)(ref val2)).position; if (HasGroundSupport(position2, 3.5f)) { pos = position2; return true; } } } return false; } private static bool HasGroundSupport(Vector3 originOnMesh, float maxDown) { //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_000c: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) Vector3 val = originOnMesh + Vector3.up * 1.5f; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, Vector3.down, ref val2, 1.5f + maxDown, -1, (QueryTriggerInteraction)1)) { return true; } return false; } [IteratorStateMachine(typeof(<LiveAvatars>d__30))] internal IEnumerable<PlayerAvatar> LiveAvatars() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LiveAvatars>d__30(-2) { <>4__this = this }; } internal PlayerAvatar FindNearest(Vector3 pos, bool includeLocal) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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) PlayerAvatar result = null; float num = float.PositiveInfinity; foreach (PlayerAvatar item in LiveAvatars()) { if ((Object)(object)((Component)item).GetComponent<PlayerAvatarMenu>() != (Object)null) { continue; } bool flag = Patch_PlayerAvatar_Start.IsLocalPlayer(item); if (!(!includeLocal && flag)) { Vector3 val = ((Component)item).transform.position - pos; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = item; } } } return result; } } [HarmonyPatch(typeof(PlayerAvatar), "Start")] public static class Patch_PlayerAvatar_Start { private static void Postfix(PlayerAvatar __instance) { try { if (!SceneLooksLikeGameplay()) { Debug.Log((object)"[DuplicatePlayers] Skipped: not in gameplay (menu scene)."); return; } if ((Object)(object)((Component)__instance).GetComponent<PlayerAvatarMenu>() != (Object)null) { Debug.Log((object)"[DuplicatePlayers] Skipped menu avatar."); return; } CloneManager.Ensure(); SceneGuard.EnsureHooked(); CloneManager.Register(__instance); } catch (Exception arg) { Debug.LogWarning((object)$"[DuplicatePlayers] Register failed: {arg}"); } } public static bool SceneLooksLikeGameplay() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (Settings.ForceGameplayCheck) { return true; } if (SemiFunc.IsMainMenu()) { return false; } Scene activeScene = SceneManager.GetActiveScene(); string text = ((Scene)(ref activeScene)).name ?? string.Empty; if (text.IndexOf("Lobby", StringComparison.OrdinalIgnoreCase) >= 0) { return false; } if (text.IndexOf("Menu", StringComparison.OrdinalIgnoreCase) >= 0) { return false; } if (text.IndexOf("Title", StringComparison.OrdinalIgnoreCase) >= 0) { return false; } return true; } public static bool IsLocalPlayer(PlayerAvatar avatar) { Type type = ((object)avatar).GetType(); FieldInfo field = type.GetField("isLocal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field.FieldType == typeof(bool)) { try { if ((bool)field.GetValue(avatar)) { return true; } } catch { } } PropertyInfo property = type.GetProperty("IsLocal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.PropertyType == typeof(bool)) { try { if ((bool)property.GetValue(avatar)) { return true; } } catch { } } return false; } public static int GetStableSeed(PlayerAvatar avatar) { return ((Object)avatar).GetInstanceID(); } public static void SetLayerRecursively(GameObject go, int layer) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown go.layer = layer; foreach (Transform item in go.transform) { Transform val = item; SetLayerRecursively(((Component)val).gameObject, layer); } } public static void DecoupleFromOriginal(GameObject cloneGO, PlayerAvatar source) { try { MonoBehaviour[] componentsInChildren = cloneGO.GetComponentsInChildren<MonoBehaviour>(true); MonoBehaviour[] array = componentsInChildren; foreach (MonoBehaviour val in array) { if ((Object)(object)val == (Object)null) { continue; } Type type = ((object)val).GetType(); if (type == typeof(IndependentCloneBrain) || type == typeof(CloneAnimationEventSink) || type == typeof(CloneCollisionLocalizer)) { continue; } bool flag = false; FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); for (int j = 0; j < fields.Length; j++) { if (typeof(PlayerAvatar).IsAssignableFrom(fields[j].FieldType)) { flag = true; break; } } if (!flag) { string name = type.Name; if (name.Contains("Follow") || name.Contains("Copy") || name.Contains("Mirror") || name.Contains("Sync") || name.Contains("IK")) { flag = true; } } if (flag) { try { ((Behaviour)val).enabled = false; } catch { } } } ParentConstraint[] componentsInChildren2 = cloneGO.GetComponentsInChildren<ParentConstraint>(true); ParentConstraint[] array2 = componentsInChildren2; foreach (ParentConstraint val2 in array2) { Object.Destroy((Object)(object)val2); } PositionConstraint[] componentsInChildren3 = cloneGO.GetComponentsInChildren<PositionConstraint>(true); PositionConstraint[] array3 = componentsInChildren3; foreach (PositionConstraint val3 in array3) { Object.Destroy((Object)(object)val3); } RotationConstraint[] componentsInChildren4 = cloneGO.GetComponentsInChildren<RotationConstraint>(true); RotationConstraint[] array4 = componentsInChildren4; foreach (RotationConstraint val4 in array4) { Object.Destroy((Object)(object)val4); } AimConstraint[] componentsInChildren5 = cloneGO.GetComponentsInChildren<AimConstraint>(true); AimConstraint[] array5 = componentsInChildren5; foreach (AimConstraint val5 in array5) { Object.Destroy((Object)(object)val5); } } catch (Exception arg) { Debug.LogWarning((object)$"[DuplicatePlayers] Decouple failed: {arg}"); } } } public class SimpleBillboard : MonoBehaviour { private void LateUpdate() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //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) Camera main = Camera.main; if (!((Object)(object)main == (Object)null)) { ((Component)this).transform.rotation = Quaternion.LookRotation(((Component)this).transform.position - ((Component)main).transform.position); } } } public class DoorBumperFollower : MonoBehaviour { public Transform target; private Rigidbody _rb; private void Awake() { _rb = ((Component)this).GetComponent<Rigidbody>(); } private void FixedUpdate() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)target) && Object.op_Implicit((Object)(object)_rb)) { _rb.MovePosition(target.position); _rb.MoveRotation(target.rotation); } } } [HarmonyPatch(typeof(PlayerAvatar), "OnDestroy")] public static class Patch_PlayerAvatar_OnDestroy { private static void Prefix(PlayerAvatar __instance) { try { CloneManager.Unregister(__instance); LocalCloneMarker[] array = Object.FindObjectsOfType<LocalCloneMarker>(true); for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null && (Object)(object)((Component)array[i]).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)array[i]).gameObject); } } } catch (Exception arg) { Debug.LogWarning((object)$"[DuplicatePlayers] Cleanup failed: {arg}"); } } } } namespace Haunted { [BepInPlugin("Omniscye.Haunted", "Haunted", "1.0")] public class Haunted : BaseUnityPlugin { internal static Haunted Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { } } }