Пример #1
0
        private void Update()
        {
            if (PlayerControl.LocalPlayer.Data == null || MeetingHud.Instance || ExileController.Instance || !HasButton())
            {
                setActive(false);
                return;
            }
            setActive(hudManager.UseButton.isActiveAndEnabled);

            actionButton.graphic.sprite = Sprite;
            if (showButtonText && buttonText != null)
            {
                actionButton.OverrideText(buttonText);
            }
            actionButton.buttonLabelText.enabled = showButtonText; // Only show the text if it's a kill button

            if (hudManager.UseButton != null)
            {
                Vector3 pos = hudManager.UseButton.transform.localPosition;
                if (mirror)
                {
                    pos = new Vector3(-pos.x, pos.y, pos.z);
                }
                actionButton.transform.localPosition = pos + PositionOffset;
                actionButton.transform.localScale    = LocalScale;
            }
            if (CouldUse())
            {
                actionButton.graphic.color = actionButton.buttonLabelText.color = Palette.EnabledColor;
                actionButton.graphic.material.SetFloat("_Desat", 0f);
            }
            else
            {
                actionButton.graphic.color = actionButton.buttonLabelText.color = Palette.DisabledClear;
                actionButton.graphic.material.SetFloat("_Desat", 1f);
            }

            if (Timer >= 0 && !stopCountdown)
            {
                bool always       = CustomOptionHolder.alwaysReduceCooldown.getBool();
                bool exceptInVent = CustomOptionHolder.exceptInVent.getBool();
                if (HasEffect && isEffectActive)
                {
                    Timer -= Time.deltaTime;
                }
                else if (always)
                {
                    if (!exceptInVent || !PlayerControl.LocalPlayer.inVent)
                    {
                        Timer -= Time.deltaTime;
                    }
                }
                else if (!PlayerControl.LocalPlayer.inVent && PlayerControl.LocalPlayer.moveable)
                {
                    Timer -= Time.deltaTime;
                }
            }

            if (Timer <= 0 && HasEffect && isEffectActive)
            {
                isEffectActive = false;
                actionButton.cooldownTimerText.color = Palette.EnabledColor;
                OnEffectEnds();
            }

            actionButton.SetCoolDown(Timer, (HasEffect && isEffectActive) ? EffectDuration : MaxTimer);

            // Trigger OnClickEvent if the hotkey is being pressed down
            if (hotkey.HasValue && Input.GetKeyDown(hotkey.Value))
            {
                onClickEvent();
            }
        }