private void TurnLockingSystemOff()
 {
     targetBeingLocked = null;
     lockCrosshair.enabled = false;
     lockArea.enabled = false;
     lockingSystemOn = false;
 }
        private void UpdateLockingSystem()
        {
            if (lockingSystemOn)
            {
                var screenCenter = ((RectTransform)lockCrosshair.canvas.transform).sizeDelta / 2f;
                var LockAreaLimitHelperPos = RectTransformUtility.WorldToScreenPoint(lockingSystemCamera, ((RectTransform)LockAreaLimitHelper.transform).position);
                var lockAreaRadius = Vector2.Distance(screenCenter, LockAreaLimitHelperPos);

                if (targetBeingLocked != null)
                {
                    if (Vector2.Distance(RectTransformUtility.WorldToScreenPoint(lockingSystemCamera, targetBeingLocked.transform.position), screenCenter) > lockAreaRadius)
                    {
                        targetBeingLocked = null;

                        leftGuidedMissileCannon.target = null;
                        rightGuidedMissileCannon.target = null;
                        lockCrosshair.enabled = false;
                    }
                    else if (Time.time - targetBeingLockedStartTime > timeToLockTarget)
                    {
                        lockCrosshair.color = lockCrosshairLockedColor;
                        leftGuidedMissileCannon.target = targetBeingLocked.transform;
                        rightGuidedMissileCannon.target = targetBeingLocked.transform;
                    }
                }

                if (targetBeingLocked == null)
                {
                    var allEnemies = GameObject.FindObjectsOfType<EnemyShipControllerV2>();
                    float selectedEnemySqrMagnitude = float.MaxValue;

                    foreach (var enemy in allEnemies)
                    {
                        var collider = enemy.GetComponent<Collider>();
                        if (collider == null) continue;

                        if (PhysicsExtensions.IsColliderInSight(targetDetectorOrigin.position, collider, ~targetDetectionLayersToIgnore))
                        {
                            var enemyScreenPoint = RectTransformUtility.WorldToScreenPoint(lockingSystemCamera, enemy.transform.position);
                            if (Vector2.Distance(enemyScreenPoint, screenCenter) > lockAreaRadius) continue;

                            var currSqrMagnitude = (targetDetectorOrigin.position - collider.transform.position).sqrMagnitude;
                            if (currSqrMagnitude < selectedEnemySqrMagnitude)
                            {
                                selectedEnemySqrMagnitude = currSqrMagnitude;
                                targetBeingLocked = enemy;

                                targetBeingLockedStartTime = Time.time;
                                lockCrosshair.enabled = true;
                                lockCrosshair.color = lockCrosshairUnlockedColor;

                                ((RectTransform)lockCrosshair.transform).localScale = new Vector3(.15f, .15f, .15f);
                                ((RectTransform)lockCrosshair.transform).DOScale(new Vector3(.04f, .04f, .04f), timeToLockTarget);

                                lockCrosshair.color = lockCrosshairUnlockedColor.Copy(0);
                                lockCrosshair.DOFade(1f, timeToLockTarget);
                            }
                        }
                    }
                }

                if (targetBeingLocked != null)
                {
                    Vector2 screenPoint = RectTransformUtility.WorldToScreenPoint(lockingSystemCamera, targetBeingLocked.transform.position);
                    ((RectTransform)lockCrosshair.transform).anchoredPosition = screenPoint - ((RectTransform)lockCrosshair.canvas.transform).sizeDelta / 2f;
                }
                else
                {
                    lockCrosshair.enabled = false;
                }
            }
        }