Esempio n. 1
0
    public void UserInput(InputState inputState, BasePlayer player)
    {
        float      x           = Mathf.Clamp(0f - inputState.current.mouseDelta.y, -1f, 1f) * rcTurnSensitivity;
        float      y           = Mathf.Clamp(inputState.current.mouseDelta.x, -1f, 1f) * rcTurnSensitivity;
        Quaternion quaternion  = Quaternion.LookRotation(aimDir, base.transform.up);
        Quaternion quaternion2 = Quaternion.Euler(x, y, 0f);
        Quaternion quaternion3 = quaternion * quaternion2;

        aimDir = quaternion3 * Vector3.forward;
        if (inputState.IsDown(BUTTON.RELOAD))
        {
            Reload();
        }
        bool flag = inputState.IsDown(BUTTON.FIRE_PRIMARY);

        EnsureReloaded();
        if (!(UnityEngine.Time.time >= nextShotTime && flag))
        {
            return;
        }
        BaseProjectile attachedWeapon = GetAttachedWeapon();

        if ((bool)attachedWeapon)
        {
            if (attachedWeapon.primaryMagazine.contents > 0)
            {
                FireAttachedGun(Vector3.zero, aimCone);
                float delay = (attachedWeapon.isSemiAuto ? (attachedWeapon.repeatDelay * 1.5f) : attachedWeapon.repeatDelay);
                delay        = attachedWeapon.ScaleRepeatDelay(delay);
                nextShotTime = UnityEngine.Time.time + delay;
            }
            else
            {
                nextShotTime = UnityEngine.Time.time + 5f;
            }
        }
        else if (HasGenericFireable())
        {
            AttachedWeapon.ServerUse();
            nextShotTime = UnityEngine.Time.time + 0.115f;
        }
        else
        {
            nextShotTime = UnityEngine.Time.time + 1f;
        }
    }