using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using UnityEngine; using UnityEngine.AI; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using Zorro.Settings; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("CapsulePath")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+6ad93e30786c314dd5e7a869f818ef9f5eed2e45")] [assembly: AssemblyProduct("CapsulePath")] [assembly: AssemblyTitle("CapsulePath")] [assembly: AssemblyMetadata("ContentWarning.VanillaCompatible", "true")] [assembly: AssemblyVersion("1.0.0.0")] namespace CapsulePath; [BepInPlugin("com.local.capsulepath", "Capsule Path", "0.3.0")] public class CapsulePathPlugin : BaseUnityPlugin { private const int SplineSteps = 10; private const float SplineStepLength = 0.25f; private const int ArrowCount = 8; private const float ArrowSpeedMps = 5f; private const float ArrowSize = 0.55f; private const float ArrowAngle = 38f; private const float MinAnimatedPathLength = 0.1f; private const float MinCornerSpacing = 0.05f; private const float DensifyStep = 0.75f; private const float SurfaceSnapRadius = 1.5f; private const float MaxLateralSnapSqr = 0.25f; private static readonly Color PathColor = new Color(0.15f, 1f, 0.25f, 0.45f); private static readonly Color ArrowColor = new Color(0.2f, 1f, 0.3f, 1f); private CapsulePathRecalculateKeySetting _recalculateKeySetting; private CapsulePathToggleKeySetting _toggleKeySetting; private CapsulePathHideFromCameraSetting _hideFromCameraSetting; private CapsulePathShowStatusSetting _showStatusSetting; private readonly NavMeshPath _navPath = new NavMeshPath(); private LineRenderer _line; private readonly List _arrows = new List(); private Vector3[] _smoothedPath; private float[] _segLengths; private float _totalLength; private float _arrowPhase; private bool _pathVisible = true; private Vector3? _capsulePos; private DivingBell _cachedBell; private readonly Dictionary _isRecordingCamera = new Dictionary(); private bool _hiddenForRecording; private const float StatusDuration = 3.2f; private const float StatusFade = 0.6f; private string _statusText; private float _statusShownAt = -100f; private GUIStyle _statusStyle; private Texture2D _statusTex; private KeyCode RecalculateKey => ResolveKey(ref _recalculateKeySetting, (KeyCode)107); private KeyCode ToggleViewKey => ResolveKey(ref _toggleKeySetting, (KeyCode)111); private bool HideFromCamera { get { if (_hideFromCameraSetting == null) { GameHandler instance = GameHandler.Instance; object hideFromCameraSetting; if (instance == null) { hideFromCameraSetting = null; } else { SettingsHandler settingsHandler = instance.SettingsHandler; hideFromCameraSetting = ((settingsHandler != null) ? settingsHandler.GetSetting() : null); } _hideFromCameraSetting = (CapsulePathHideFromCameraSetting)hideFromCameraSetting; } if (_hideFromCameraSetting != null) { return ((BoolSetting)_hideFromCameraSetting).Value; } return true; } } private bool ShowStatusHud { get { if (_showStatusSetting == null) { GameHandler instance = GameHandler.Instance; object showStatusSetting; if (instance == null) { showStatusSetting = null; } else { SettingsHandler settingsHandler = instance.SettingsHandler; showStatusSetting = ((settingsHandler != null) ? settingsHandler.GetSetting() : null); } _showStatusSetting = (CapsulePathShowStatusSetting)showStatusSetting; } if (_showStatusSetting != null) { return ((BoolSetting)_showStatusSetting).Value; } return true; } } private static KeyCode ResolveKey(ref T cached, KeyCode fallback) where T : KeyCodeSetting { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (cached == null) { GameHandler instance = GameHandler.Instance; object obj; if (instance == null) { obj = default(T); } else { SettingsHandler settingsHandler = instance.SettingsHandler; obj = ((settingsHandler != null) ? settingsHandler.GetSetting() : default(T)); } cached = (T)obj; } if (cached == null) { return fallback; } return ((KeyCodeSetting)cached/*cast due to .constrained prefix*/).Keycode(); } private void Awake() { EnsureLineRenderer(); EnsureArrows(); SceneManager.activeSceneChanged += OnActiveSceneChanged; RenderPipelineManager.beginCameraRendering += OnBeginCameraRendering; RenderPipelineManager.endCameraRendering += OnEndCameraRendering; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Capsule Path loaded. Defaults: K=calculate path, O=toggle path (rebindable in Settings -> MODS)."); } private void Update() { //IL_0011: 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_0069: Unknown result type (might be due to invalid IL or missing references) TrackCapsulePosition(); if (GameplayInputActive()) { if (Input.GetKeyDown(ToggleViewKey)) { _pathVisible = !_pathVisible; if ((Object)(object)_line != (Object)null) { ((Renderer)_line).enabled = _pathVisible; } SetArrowsVisible(_pathVisible); if (_smoothedPath == null) { ShowStatus($"CapsulePath: press [{RecalculateKey}] to find the capsule"); } else { ShowStatus(_pathVisible ? "CapsulePath: path shown" : "CapsulePath: path hidden"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("[CapsulePath] Visibility: " + (_pathVisible ? "ON" : "OFF"))); } if (Input.GetKeyDown(RecalculateKey)) { RecalculatePath(); } } if (_smoothedPath != null && _pathVisible && _totalLength > 0.1f) { AnimateArrows(); } } private static bool GameplayInputActive() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)Cursor.lockState == 1) { return GlobalInputHandler.CanTakeInput(); } return false; } private void OnDestroy() { SceneManager.activeSceneChanged -= OnActiveSceneChanged; RenderPipelineManager.beginCameraRendering -= OnBeginCameraRendering; RenderPipelineManager.endCameraRendering -= OnEndCameraRendering; foreach (LineRenderer arrow in _arrows) { if ((Object)(object)arrow != (Object)null) { Object.Destroy((Object)(object)((Component)arrow).gameObject); } } _arrows.Clear(); if ((Object)(object)_line != (Object)null) { Object.Destroy((Object)(object)((Component)_line).gameObject); } if ((Object)(object)_statusTex != (Object)null) { Object.Destroy((Object)(object)_statusTex); } } private void OnBeginCameraRendering(ScriptableRenderContext context, Camera cam) { if (_pathVisible && _smoothedPath != null && HideFromCamera && IsRecordingCamera(cam)) { _hiddenForRecording = true; if ((Object)(object)_line != (Object)null) { ((Renderer)_line).enabled = false; } HideArrows(); } } private void OnEndCameraRendering(ScriptableRenderContext context, Camera cam) { if (_hiddenForRecording && IsRecordingCamera(cam)) { _hiddenForRecording = false; if ((Object)(object)_line != (Object)null) { ((Renderer)_line).enabled = _pathVisible; } SetArrowsVisible(_pathVisible); } } private bool IsRecordingCamera(Camera cam) { if (!_isRecordingCamera.TryGetValue(cam, out var value)) { value = (Object)(object)((Component)cam).GetComponentInParent() != (Object)null; _isRecordingCamera[cam] = value; } return value; } private void OnActiveSceneChanged(Scene previous, Scene current) { _capsulePos = null; _cachedBell = null; _isRecordingCamera.Clear(); ClearPath(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[CapsulePath] Scene changed -> state reset (" + ((Scene)(ref current)).name + ")")); } private void TrackCapsulePosition() { //IL_0062: 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) if (!_capsulePos.HasValue && (BotHandler.instance?.bots?.Count).GetValueOrDefault() != 0) { Camera main = Camera.main; if (!((Object)(object)main == (Object)null)) { _capsulePos = ((Component)main).transform.position; ((BaseUnityPlugin)this).Logger.LogInfo((object)$"[CapsulePath] Capsule anchor recorded: {_capsulePos.Value}"); } } } private void RecalculatePath() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Invalid comparison between Unknown and I4 //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Invalid comparison between Unknown and I4 if (!TryGetCapsuleTarget(out var target, out var source)) { ShowStatus("CapsulePath: capsule not found yet (start the dive)"); ((BaseUnityPlugin)this).Logger.LogWarning((object)"[CapsulePath] Capsule target unknown (no diving bell, no anchor)."); return; } Player localPlayer = Player.localPlayer; if ((Object)(object)localPlayer == (Object)null) { ShowStatus("CapsulePath: player not ready"); ((BaseUnityPlugin)this).Logger.LogWarning((object)"[CapsulePath] Local player not found."); return; } if (!TryGetLocalAvatarPosition(localPlayer, out var position, out var source2)) { ShowStatus("CapsulePath: player position unknown"); ((BaseUnityPlugin)this).Logger.LogWarning((object)"[CapsulePath] Could not resolve dynamic local avatar position."); return; } Vector3 position2 = position; Vector3 position3 = target; if (!TrySampleToNavMesh(ref position2) || !TrySampleToNavMesh(ref position3)) { ClearPath(); ApplyPath((Vector3[])(object)new Vector3[2] { position + Vector3.up * 0.2f, target + Vector3.up * 0.2f }); ShowStatus(WithVisibilityHint("CapsulePath: direct line (off NavMesh)")); ((BaseUnityPlugin)this).Logger.LogWarning((object)"[CapsulePath] Could not sample start/end to NavMesh. Using direct fallback."); return; } if (!NavMesh.CalculatePath(position2, position3, -1, _navPath) || _navPath.corners == null || _navPath.corners.Length < 2 || (int)_navPath.status == 2) { ClearPath(); ApplyPath((Vector3[])(object)new Vector3[2] { position + Vector3.up * 0.2f, target + Vector3.up * 0.2f }); ShowStatus(WithVisibilityHint("CapsulePath: no route - direct line")); ((BaseUnityPlugin)this).Logger.LogWarning((object)"[CapsulePath] Path not found/invalid. Using direct fallback."); return; } float num = 0f; for (int i = 1; i < _navPath.corners.Length; i++) { num += Vector3.Distance(_navPath.corners[i - 1], _navPath.corners[i]); } Vector3[] array = CatmullRom(LiftCorners(DensifyOnNavMesh(DropCoincidentCorners(_navPath.corners, 0.05f)), 0.12f), 10); ApplyPath(array); bool flag = (int)_navPath.status == 1; ShowStatus(WithVisibilityHint(flag ? $"CapsulePath: partial route ~{num:F0} m (capsule may be blocked)" : $"CapsulePath: {num:F0} m to capsule")); if (flag) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[CapsulePath] Path is partial - it stops at the closest reachable point, not at the capsule."); } ((BaseUnityPlugin)this).Logger.LogInfo((object)$"[CapsulePath] Path OK. Corners={_navPath.corners.Length}, pts={array.Length}, len={num:F1}m, src={source2}, tgt={source}"); } private string WithVisibilityHint(string msg) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!_pathVisible) { return msg + $" (hidden - [{ToggleViewKey}] to show)"; } return msg; } private bool TryGetCapsuleTarget(out Vector3 target, out string source) { //IL_0012: 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_004d: 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) DivingBell val = ResolveDivingBell(); if ((Object)(object)val != (Object)null) { target = DivingBellAnchor(val); source = "DivingBell"; return true; } if (_capsulePos.HasValue) { target = _capsulePos.Value; source = "camera-anchor"; return true; } target = default(Vector3); source = "none"; return false; } private DivingBell ResolveDivingBell() { if ((Object)(object)_cachedBell != (Object)null) { return _cachedBell; } DivingBell[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (DivingBell val in array) { if ((Object)(object)val != (Object)null && !val.onSurface) { _cachedBell = val; break; } } return _cachedBell; } private static Vector3 DivingBellAnchor(DivingBell bell) { //IL_0075: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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) Transform[] array = (((Object)(object)bell.playerDetector != (Object)null) ? bell.playerDetector.m_detectors : null); if (array != null && array.Length != 0) { Vector3 val = Vector3.zero; int num = 0; Transform[] array2 = array; foreach (Transform val2 in array2) { if ((Object)(object)val2 != (Object)null) { val += val2.position; num++; } } if (num > 0) { return val / (float)num; } } return ((Component)bell).transform.position; } private static Vector3[] LiftCorners(Vector3[] corners, float up) { //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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[corners.Length]; for (int i = 0; i < corners.Length; i++) { array[i] = corners[i] + Vector3.up * up; } return array; } private static Vector3[] DropCoincidentCorners(Vector3[] corners, float minDist) { //IL_0013: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (corners.Length < 3) { return corners; } List list = new List(corners.Length) { corners[0] }; for (int i = 1; i < corners.Length - 1; i++) { if (Vector3.Distance(list[list.Count - 1], corners[i]) >= minDist) { list.Add(corners[i]); } } list.Add(corners[^1]); return list.ToArray(); } private static Vector3[] DensifyOnNavMesh(Vector3[] corners) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_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) List list = new List(corners.Length * 4) { corners[0] }; NavMeshHit val4 = default(NavMeshHit); for (int i = 1; i < corners.Length; i++) { Vector3 val = corners[i - 1]; Vector3 val2 = corners[i]; int num = Mathf.FloorToInt(Vector3.Distance(val, val2) / 0.75f); for (int j = 1; j <= num; j++) { Vector3 val3 = Vector3.Lerp(val, val2, (float)j / (float)(num + 1)); if (NavMesh.SamplePosition(val3, ref val4, 1.5f, -1)) { Vector3 val5 = ((NavMeshHit)(ref val4)).position - val3; val5.y = 0f; if (((Vector3)(ref val5)).sqrMagnitude <= 0.25f) { val3 = ((NavMeshHit)(ref val4)).position; } } list.Add(val3); } list.Add(val2); } return list.ToArray(); } private static Vector3[] CatmullRom(Vector3[] pts, int maxSteps) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if (pts.Length < 2) { return pts; } Vector3[] array = (Vector3[])(object)new Vector3[pts.Length + 2]; array[0] = pts[0]; for (int i = 0; i < pts.Length; i++) { array[i + 1] = pts[i]; } array[^1] = pts[^1]; List list = new List(pts.Length * 4); for (int j = 1; j < array.Length - 2; j++) { int num = Mathf.Clamp(Mathf.CeilToInt(Vector3.Distance(array[j], array[j + 1]) / 0.25f), 2, maxSteps); for (int k = 0; k < num; k++) { float t = (float)k / (float)num; list.Add(CatmullRomPoint(array[j - 1], array[j], array[j + 1], array[j + 2], t)); } } list.Add(pts[^1]); return list.ToArray(); } private static Vector3 CatmullRomPoint(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0064: 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_0072: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) float num = 0f; float num2 = num + Mathf.Max(Mathf.Sqrt(Vector3.Distance(p0, p1)), 0.2f); float num3 = num2 + Mathf.Max(Mathf.Sqrt(Vector3.Distance(p1, p2)), 0.2f); float num4 = num3 + Mathf.Max(Mathf.Sqrt(Vector3.Distance(p2, p3)), 0.2f); float num5 = Mathf.Lerp(num2, num3, t); Vector3 val = (num2 - num5) / (num2 - num) * p0 + (num5 - num) / (num2 - num) * p1; Vector3 val2 = (num3 - num5) / (num3 - num2) * p1 + (num5 - num2) / (num3 - num2) * p2; Vector3 val3 = (num4 - num5) / (num4 - num3) * p2 + (num5 - num3) / (num4 - num3) * p3; Vector3 val4 = (num3 - num5) / (num3 - num) * val + (num5 - num) / (num3 - num) * val2; Vector3 val5 = (num4 - num5) / (num4 - num2) * val2 + (num5 - num2) / (num4 - num2) * val3; return (num3 - num5) / (num3 - num2) * val4 + (num5 - num2) / (num3 - num2) * val5; } private void ApplyPath(Vector3[] pts) { _smoothedPath = pts; PrecomputeLengths(); EnsureLineRenderer(); _line.positionCount = pts.Length; _line.SetPositions(pts); ((Renderer)_line).enabled = _pathVisible; _arrowPhase = 0f; SetArrowsVisible(_pathVisible); } private void PrecomputeLengths() { //IL_0058: 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) if (_smoothedPath == null || _smoothedPath.Length < 2) { _segLengths = null; _totalLength = 0f; return; } _segLengths = new float[_smoothedPath.Length - 1]; _totalLength = 0f; for (int i = 0; i < _segLengths.Length; i++) { _segLengths[i] = Vector3.Distance(_smoothedPath[i], _smoothedPath[i + 1]); _totalLength += _segLengths[i]; } } private void AnimateArrows() { //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) float num = 5f / _totalLength; _arrowPhase = (_arrowPhase + Time.deltaTime * num) % 1f; for (int i = 0; i < 8; i++) { float t = (_arrowPhase + (float)i / 8f) % 1f; SamplePolyline(t, out var pos, out var tangent); DrawChevron(_arrows[i], pos, tangent); } } private void SamplePolyline(float t, out Vector3 pos, out Vector3 tangent) { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0085: 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_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) float num = t * _totalLength; float num2 = 0f; for (int i = 0; i < _segLengths.Length; i++) { float num3 = _segLengths[i]; if (num2 + num3 >= num || i == _segLengths.Length - 1) { float num4 = Mathf.Clamp01((num - num2) / Mathf.Max(num3, 0.001f)); pos = Vector3.Lerp(_smoothedPath[i], _smoothedPath[i + 1], num4); Vector3 val = _smoothedPath[i + 1] - _smoothedPath[i]; tangent = ((Vector3)(ref val)).normalized; return; } num2 += num3; } pos = _smoothedPath[_smoothedPath.Length - 1]; tangent = Vector3.forward; } private void DrawChevron(LineRenderer lr, Vector3 tip, Vector3 forward) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_000b: 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_003b: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0085: 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_0095: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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) Vector3 val = Vector3.Cross(Vector3.up, forward); Vector3 val2 = ((Vector3)(ref val)).normalized; if (((Vector3)(ref val2)).sqrMagnitude < 0.001f) { val2 = Vector3.right; } float num = Mathf.Cos((float)Math.PI * 19f / 90f); float num2 = Mathf.Sin((float)Math.PI * 19f / 90f); Vector3 val3 = -forward; Vector3 val4 = tip + (val3 * num + val2 * num2) * 0.55f; Vector3 val5 = tip + (val3 * num - val2 * num2) * 0.55f; lr.positionCount = 3; lr.SetPosition(0, val4); lr.SetPosition(1, tip); lr.SetPosition(2, val5); } private void ClearPath() { _smoothedPath = null; _segLengths = null; _totalLength = 0f; if ((Object)(object)_line != (Object)null) { _line.positionCount = 0; } HideArrows(); } private void EnsureLineRenderer() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_line != (Object)null)) { GameObject val = new GameObject("CapsulePathRenderer"); Object.DontDestroyOnLoad((Object)(object)val); _line = val.AddComponent(); _line.useWorldSpace = true; _line.loop = false; _line.widthMultiplier = 0.09f; _line.positionCount = 0; _line.numCapVertices = 4; _line.numCornerVertices = 8; ((Renderer)_line).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)_line).receiveShadows = false; ((Renderer)_line).material = BuildLineMaterial(PathColor); _line.startColor = PathColor; _line.endColor = PathColor; _line.textureMode = (LineTextureMode)0; _line.alignment = (LineAlignment)0; ((Renderer)_line).enabled = _pathVisible; } } private void EnsureArrows() { //IL_0010: 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_0047: Expected O, but got Unknown //IL_008a: 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) if (_arrows.Count < 8) { Material sharedMaterial = BuildLineMaterial(ArrowColor); for (int i = _arrows.Count; i < 8; i++) { GameObject val = new GameObject($"CapsuleArrow_{i}"); Object.DontDestroyOnLoad((Object)val); LineRenderer val2 = val.AddComponent(); val2.useWorldSpace = true; val2.positionCount = 3; val2.widthMultiplier = 0.22f; val2.numCapVertices = 2; val2.numCornerVertices = 4; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = false; ((Renderer)val2).sharedMaterial = sharedMaterial; val2.startColor = ArrowColor; val2.endColor = ArrowColor; val2.alignment = (LineAlignment)0; ((Renderer)val2).enabled = false; _arrows.Add(val2); } } } private void SetArrowsVisible(bool visible) { bool enabled = visible && _smoothedPath != null && _totalLength > 0.1f; foreach (LineRenderer arrow in _arrows) { if ((Object)(object)arrow != (Object)null) { ((Renderer)arrow).enabled = enabled; } } } private void HideArrows() { foreach (LineRenderer arrow in _arrows) { if ((Object)(object)arrow != (Object)null) { ((Renderer)arrow).enabled = false; } } } private Material BuildLineMaterial(Color color) { //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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Universal Render Pipeline/Unlit"); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"[CapsulePath] No usable shader found; path will not render."); return null; } return new Material(val) { color = color }; } private void ShowStatus(string text) { _statusText = text; _statusShownAt = Time.unscaledTime; } private void OnGUI() { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: 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_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(_statusText) && ShowStatusHud) { float num = Time.unscaledTime - _statusShownAt; if (!(num < 0f) && !(num > 3.2f)) { float num2 = ((num > 2.6f) ? Mathf.Clamp01((3.2f - num) / 0.6f) : 1f); EnsureStatusStyle(); float num3 = Mathf.Round((float)Screen.height * 0.012f); float num4 = _statusStyle.fontSize; Vector2 val = _statusStyle.CalcSize(new GUIContent(_statusText)); float num5 = val.x + num4 + num3 * 3f; float num6 = Mathf.Max(val.y, num4) + num3 * 2f; float num7 = Mathf.Round((float)Screen.width * 0.03f); float num8 = Mathf.Round((float)Screen.height * 0.5f - num6 * 0.5f); Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.66f * num2); GUI.DrawTexture(new Rect(num7, num8, num5, num6), (Texture)(object)_statusTex); GUI.color = ((_smoothedPath != null && _pathVisible) ? new Color(0.2f, 1f, 0.3f, num2) : new Color(0.6f, 0.6f, 0.6f, num2)); GUI.DrawTexture(new Rect(num7 + num3, num8 + (num6 - num4) * 0.5f, num4, num4), (Texture)(object)_statusTex); GUI.color = new Color(1f, 1f, 1f, num2); GUI.Label(new Rect(num7 + num3 * 2f + num4, num8, val.x + num3, num6), _statusText, _statusStyle); GUI.color = color; } } } private void EnsureStatusStyle() { //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_0023: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_statusTex == (Object)null) { _statusTex = new Texture2D(1, 1) { hideFlags = (HideFlags)61 }; _statusTex.SetPixel(0, 0, Color.white); _statusTex.Apply(); } if (_statusStyle == null) { _statusStyle = new GUIStyle { alignment = (TextAnchor)3, fontStyle = (FontStyle)1, richText = false }; _statusStyle.normal.textColor = Color.white; } _statusStyle.fontSize = Mathf.Clamp(Mathf.RoundToInt((float)Screen.height * 0.022f), 12, 40); } private static bool TryGetLocalAvatarPosition(Player local, out Vector3 position, out string source) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_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_003a: 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) //IL_0081: 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) try { Vector3 val = local.HeadPosition(); RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, Vector3.down, ref val2, 3f, -5, (QueryTriggerInteraction)1)) { position = ((RaycastHit)(ref val2)).point + Vector3.up * 0.1f; source = "HeadPosition+groundRay"; } else { position = val + Vector3.down * 1.5f; source = "HeadPosition-1.5m"; } return true; } catch { } if ((Object)(object)local != (Object)null) { position = ((Component)local).transform.position; source = "transform.position"; return true; } position = default(Vector3); source = "none"; return false; } private static bool TrySampleToNavMesh(ref Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(position, ref val, 4f, -1)) { return false; } position = ((NavMeshHit)(ref val)).position; return true; } } internal static class PluginInfo { public const string GUID = "com.local.capsulepath"; public const string Name = "Capsule Path"; public const string Version = "0.3.0"; } [ContentWarningSetting] public class CapsulePathRecalculateKeySetting : KeyCodeSetting, IExposedSetting { protected override KeyCode GetDefaultKey() { return (KeyCode)107; } public SettingCategory GetSettingCategory() { return (SettingCategory)4; } public string GetDisplayName() { return "[CapsulePath] Recalculate path key"; } } [ContentWarningSetting] public class CapsulePathToggleKeySetting : KeyCodeSetting, IExposedSetting { protected override KeyCode GetDefaultKey() { return (KeyCode)111; } public SettingCategory GetSettingCategory() { return (SettingCategory)4; } public string GetDisplayName() { return "[CapsulePath] Toggle path key"; } } [ContentWarningSetting] public class CapsulePathHideFromCameraSetting : BoolSetting, IExposedSetting { protected override bool GetDefaultValue() { return true; } public override void ApplyValue() { } public SettingCategory GetSettingCategory() { return (SettingCategory)4; } public string GetDisplayName() { return "[CapsulePath] Hide path in camera footage"; } } [ContentWarningSetting] public class CapsulePathShowStatusSetting : BoolSetting, IExposedSetting { protected override bool GetDefaultValue() { return true; } public override void ApplyValue() { } public SettingCategory GetSettingCategory() { return (SettingCategory)4; } public string GetDisplayName() { return "[CapsulePath] Show on-screen status"; } }