Example #1
0
        private void Update()
        {
            if (!initialized && constructable._constructed && transform.parent != null)
            {
                Initialize();
            }

            if (!initialized || !constructable._constructed)
            {
                return;
            }

            if (Player.main != null)
            {
                float distSq        = (Player.main.transform.position - transform.position).sqrMagnitude;
                bool  playerInRange = distSq <= (MaxDistance * MaxDistance);
                configureButton.enabled = playerInRange;

                if (picker != null && picker.isActiveAndEnabled && !playerInRange)
                {
                    picker.gameObject.SetActive(false);
                }
            }

            container.enabled = ShouldEnableContainer();

            if (SaveLoadManager.main != null && SaveLoadManager.main.isSaving && !Mod.IsSaving())
            {
                Mod.Save();
            }

            UpdateQuantityText();
        }