Example #1
0
        private void Update()
        {
            for (int num = _interactiveObjects.Count - 1; num >= 0; num--)
            {
                InteractiveObject interactiveObject = _interactiveObjects[num];
                if (interactiveObject == null || !interactiveObject.isActiveAndEnabled)
                {
                    _interactiveObjects.RemoveAt(num);
                }
            }

            if (_interactiveObjects.Count == 0 || PlayerInput.blocked.value)
            {
                if (_objectToInteract != null)
                {
                    _objectToInteract.ClosePopup();
                }

                _objectToInteract = null;
                return;
            }

            _interactiveObjects.Sort((InteractiveObject i1, InteractiveObject i2) =>
                                     Mathf.Abs(base.transform.position.x - i1.transform.position.x)
                                     .CompareTo(Mathf.Abs(base.transform.position.x - i2.transform.position.x)));

            for (int j = 0; j < _interactiveObjects.Count; j++)
            {
                InteractiveObject interactiveObject2 = _interactiveObjects[j];
                if (!interactiveObject2.activated)
                {
                    continue;
                }

                if (interactiveObject2.autoInteract)
                {
                    interactiveObject2.InteractWith(_character);
                }

                if (_objectToInteract != interactiveObject2)
                {
                    if (_objectToInteract != null)
                    {
                        _objectToInteract.ClosePopup();
                    }

                    interactiveObject2.OpenPopupBy(_character);
                    _objectToInteract = interactiveObject2;
                }

                break;
            }
        }