Пример #1
0
        private static float getJoyLeftStickXPatched()
        {
            if (VRControls.mainControlsActive)
            {
                return(0.0f);
            }

            return(ZInput.GetJoyLeftStickX());
        }
Пример #2
0
            static bool Prefix(PlayerController __instance, ZNetView ___m_nview)
            {
                if ((bool)___m_nview && !___m_nview.IsOwner())
                {
                    return(true);
                }
                if (!(bool)Traverse.Create(__instance).Method("TakeInput").GetValue())
                {
                    return(true);
                }
                if ((bool)Traverse.Create(__instance).Method("InInventoryEtc").GetValue())
                {
                    return(true);
                }
                if (ZInput.GetButton("Forward"))
                {
                    DetectTap(true, (float)(DateTime.Now - m_forwardLastTapCheck).TotalMilliseconds, DodgeTapHoldMax.Value, ref m_forwardPressTimer);
                    m_forwardLastTapCheck = DateTime.Now;
                }
                else
                {
                    var isTap = DetectTap(false, (float)(DateTime.Now - m_forwardLastTapCheck).TotalMilliseconds, DodgeTapHoldMax.Value, ref m_forwardPressTimer);
                    m_forwardLastTapCheck = DateTime.Now;
                    CheckForDoubleTapDodge(isTap, ref m_forwardLastTapRegistered, DodgeDirection.Forward);
                }
                if (ZInput.GetButton("Backward"))
                {
                    DetectTap(true, (float)(DateTime.Now - m_backwardLastTapCheck).TotalMilliseconds, DodgeTapHoldMax.Value, ref m_backwardPressTimer);
                    m_backwardLastTapCheck = DateTime.Now;
                }
                else
                {
                    bool isTap = DetectTap(false, (float)(DateTime.Now - m_backwardLastTapCheck).TotalMilliseconds, DodgeTapHoldMax.Value, ref m_backwardPressTimer);
                    m_backwardLastTapCheck = DateTime.Now;
                    CheckForDoubleTapDodge(isTap, ref m_backwardLastTapRegistered, DodgeDirection.Backward);
                }
                if (ZInput.GetButton("Left"))
                {
                    DetectTap(true, (float)(DateTime.Now - m_leftLastTapCheck).TotalMilliseconds, DodgeTapHoldMax.Value, ref m_leftPressTimer);
                    m_leftLastTapCheck = DateTime.Now;
                }
                else
                {
                    bool isTap = DetectTap(false, (float)(DateTime.Now - m_leftLastTapCheck).TotalMilliseconds, DodgeTapHoldMax.Value, ref m_leftPressTimer);
                    m_leftLastTapCheck = DateTime.Now;
                    CheckForDoubleTapDodge(isTap, ref m_leftLastTapRegistered, DodgeDirection.Left);
                }
                if (ZInput.GetButton("Right"))
                {
                    DetectTap(true, (float)(DateTime.Now - m_rightLastTapCheck).TotalMilliseconds, DodgeTapHoldMax.Value, ref m_rightPressTimer);
                    m_rightLastTapCheck = DateTime.Now;
                }
                else
                {
                    bool isTap = DetectTap(false, (float)(DateTime.Now - m_rightLastTapCheck).TotalMilliseconds, DodgeTapHoldMax.Value, ref m_rightPressTimer);
                    m_rightLastTapCheck = DateTime.Now;
                    CheckForDoubleTapDodge(isTap, ref m_rightLastTapRegistered, DodgeDirection.Right);
                }

                // Gamepad
                var v = new Vector3(ZInput.GetJoyLeftStickX(), 0, ZInput.GetJoyLeftStickY());

                if (v.magnitude > 0.9f)
                {
                    DetectTap(true, (float)(DateTime.Now - m_GamepadLastTapCheck).TotalMilliseconds, DodgeTapHoldMax.Value, ref m_GamepadPressTimer);
                    m_GamepadLastTapCheck = DateTime.Now;
                    var milliesSinceLastTap = (DateTime.Now - m_GamepadLastTapRegistered)?.TotalMilliseconds ?? DodgeDoubleTapDelay.Value;
                    if (milliesSinceLastTap < DodgeDoubleTapDelay.Value)
                    {
                        m_GamepadSecondDir = v;
                    }
                    else
                    {
                        m_GamepadFirstDir = v;
                    }
                }
                else
                {
                    bool isTap = DetectTap(false, (float)(DateTime.Now - m_GamepadLastTapCheck).TotalMilliseconds, DodgeTapHoldMax.Value, ref m_GamepadPressTimer);
                    m_GamepadLastTapCheck = DateTime.Now;
                    CheckForDoubleTapDodge(isTap, ref m_GamepadLastTapRegistered);
                }
                return(true);
            }
Пример #3
0
    // Token: 0x0600024A RID: 586 RVA: 0x00012870 File Offset: 0x00010A70
    private void FixedUpdate()
    {
        if (this.m_nview && !this.m_nview.IsOwner())
        {
            return;
        }
        if (!this.TakeInput())
        {
            this.m_character.SetControls(Vector3.zero, false, false, false, false, false, false, false, false, false);
            return;
        }
        bool    flag = this.InInventoryEtc();
        Vector3 zero = Vector3.zero;

        if (ZInput.GetButton("Forward"))
        {
            zero.z += 1f;
        }
        if (ZInput.GetButton("Backward"))
        {
            zero.z -= 1f;
        }
        if (ZInput.GetButton("Left"))
        {
            zero.x -= 1f;
        }
        if (ZInput.GetButton("Right"))
        {
            zero.x += 1f;
        }
        zero.x += ZInput.GetJoyLeftStickX();
        zero.z += -ZInput.GetJoyLeftStickY();
        if (zero.magnitude > 1f)
        {
            zero.Normalize();
        }
        bool flag2      = (ZInput.GetButton("Attack") || ZInput.GetButton("JoyAttack")) && !flag;
        bool attackHold = flag2;
        bool attack     = flag2 && !this.m_attackWasPressed;

        this.m_attackWasPressed = flag2;
        bool flag3           = (ZInput.GetButton("SecondAttack") || ZInput.GetButton("JoySecondAttack")) && !flag;
        bool secondaryAttack = flag3 && !this.m_secondAttackWasPressed;

        this.m_secondAttackWasPressed = flag3;
        bool flag4     = (ZInput.GetButton("Block") || ZInput.GetButton("JoyBlock")) && !flag;
        bool blockHold = flag4;
        bool block     = flag4 && !this.m_blockWasPressed;

        this.m_blockWasPressed = flag4;
        bool button = ZInput.GetButton("Jump");
        bool jump   = (button && !this.m_lastJump) || ZInput.GetButtonDown("JoyJump");

        this.m_lastJump = button;
        bool flag5  = InventoryGui.IsVisible();
        bool flag6  = (ZInput.GetButton("Crouch") || ZInput.GetButton("JoyCrouch")) && !flag5;
        bool crouch = flag6 && !this.m_lastCrouch;

        this.m_lastCrouch = flag6;
        bool run     = ZInput.GetButton("Run") || ZInput.GetButton("JoyRun");
        bool button2 = ZInput.GetButton("AutoRun");

        this.m_character.SetControls(zero, attack, attackHold, secondaryAttack, block, blockHold, jump, crouch, run, button2);
    }
Пример #4
0
    // Token: 0x06000AE9 RID: 2793 RVA: 0x0004E798 File Offset: 0x0004C998
    private void UpdateFreeFly(float dt)
    {
        if (global::Console.IsVisible())
        {
            return;
        }
        Vector2 zero = Vector2.zero;

        zero.x               = Input.GetAxis("Mouse X");
        zero.y               = Input.GetAxis("Mouse Y");
        zero.x              += ZInput.GetJoyRightStickX() * 110f * dt;
        zero.y              += -ZInput.GetJoyRightStickY() * 110f * dt;
        this.m_freeFlyYaw   += zero.x;
        this.m_freeFlyPitch -= zero.y;
        if (Input.GetAxis("Mouse ScrollWheel") < 0f)
        {
            this.m_freeFlySpeed *= 0.8f;
        }
        if (Input.GetAxis("Mouse ScrollWheel") > 0f)
        {
            this.m_freeFlySpeed *= 1.2f;
        }
        if (Input.GetAxis("Mouse ScrollWheel") > 0f)
        {
            this.m_freeFlySpeed *= 1.2f;
        }
        if (ZInput.GetButton("JoyTabLeft"))
        {
            this.m_camera.fieldOfView = Mathf.Max(this.m_freeFlyMinFov, this.m_camera.fieldOfView - dt * 20f);
        }
        if (ZInput.GetButton("JoyTabRight"))
        {
            this.m_camera.fieldOfView = Mathf.Min(this.m_freeFlyMaxFov, this.m_camera.fieldOfView + dt * 20f);
        }
        this.m_skyCamera.fieldOfView = this.m_camera.fieldOfView;
        if (ZInput.GetButton("JoyButtonY"))
        {
            this.m_freeFlySpeed += this.m_freeFlySpeed * 0.1f * dt * 10f;
        }
        if (ZInput.GetButton("JoyButtonX"))
        {
            this.m_freeFlySpeed -= this.m_freeFlySpeed * 0.1f * dt * 10f;
        }
        this.m_freeFlySpeed = Mathf.Clamp(this.m_freeFlySpeed, 1f, 1000f);
        if (ZInput.GetButtonDown("JoyLStick") || ZInput.GetButtonDown("SecondAttack"))
        {
            if (this.m_freeFlyLockon)
            {
                this.m_freeFlyLockon = null;
            }
            else
            {
                int mask = LayerMask.GetMask(new string[]
                {
                    "Default",
                    "static_solid",
                    "terrain",
                    "vehicle",
                    "character",
                    "piece",
                    "character_net",
                    "viewblock"
                });
                RaycastHit raycastHit;
                if (Physics.Raycast(base.transform.position, base.transform.forward, out raycastHit, 10000f, mask))
                {
                    this.m_freeFlyLockon       = raycastHit.collider.transform;
                    this.m_freeFlyLockonOffset = this.m_freeFlyLockon.InverseTransformPoint(base.transform.position);
                }
            }
        }
        Vector3 vector = Vector3.zero;

        if (ZInput.GetButton("Left"))
        {
            vector -= Vector3.right;
        }
        if (ZInput.GetButton("Right"))
        {
            vector += Vector3.right;
        }
        if (ZInput.GetButton("Forward"))
        {
            vector += Vector3.forward;
        }
        if (ZInput.GetButton("Backward"))
        {
            vector -= Vector3.forward;
        }
        if (ZInput.GetButton("Jump"))
        {
            vector += Vector3.up;
        }
        if (ZInput.GetButton("Crouch"))
        {
            vector -= Vector3.up;
        }
        vector += Vector3.up * ZInput.GetJoyRTrigger();
        vector -= Vector3.up * ZInput.GetJoyLTrigger();
        vector += Vector3.right * ZInput.GetJoyLeftStickX();
        vector += -Vector3.forward * ZInput.GetJoyLeftStickY();
        if (ZInput.GetButtonDown("JoyButtonB") || ZInput.GetButtonDown("Block"))
        {
            this.m_freeFlySavedVel = vector;
        }
        float magnitude = this.m_freeFlySavedVel.magnitude;

        if (magnitude > 0.001f)
        {
            vector += this.m_freeFlySavedVel;
            if (vector.magnitude > magnitude)
            {
                vector = vector.normalized * magnitude;
            }
        }
        if (vector.magnitude > 1f)
        {
            vector.Normalize();
        }
        vector  = base.transform.TransformVector(vector);
        vector *= this.m_freeFlySpeed;
        if (this.m_freeFlySmooth <= 0f)
        {
            this.m_freeFlyVel = vector;
        }
        else
        {
            this.m_freeFlyVel = Vector3.SmoothDamp(this.m_freeFlyVel, vector, ref this.m_freeFlyAcc, this.m_freeFlySmooth, 99f, dt);
        }
        if (this.m_freeFlyLockon)
        {
            this.m_freeFlyLockonOffset += this.m_freeFlyLockon.InverseTransformVector(this.m_freeFlyVel * dt);
            base.transform.position     = this.m_freeFlyLockon.TransformPoint(this.m_freeFlyLockonOffset);
        }
        else
        {
            base.transform.position = base.transform.position + this.m_freeFlyVel * dt;
        }
        Quaternion quaternion = Quaternion.Euler(0f, this.m_freeFlyYaw, 0f) * Quaternion.Euler(this.m_freeFlyPitch, 0f, 0f);

        if (this.m_freeFlyLockon)
        {
            quaternion = this.m_freeFlyLockon.rotation * quaternion;
        }
        if (ZInput.GetButtonDown("JoyRStick") || ZInput.GetButtonDown("Attack"))
        {
            if (this.m_freeFlyTarget)
            {
                this.m_freeFlyTarget = null;
            }
            else
            {
                int mask2 = LayerMask.GetMask(new string[]
                {
                    "Default",
                    "static_solid",
                    "terrain",
                    "vehicle",
                    "character",
                    "piece",
                    "character_net",
                    "viewblock"
                });
                RaycastHit raycastHit2;
                if (Physics.Raycast(base.transform.position, base.transform.forward, out raycastHit2, 10000f, mask2))
                {
                    this.m_freeFlyTarget       = raycastHit2.collider.transform;
                    this.m_freeFlyTargetOffset = this.m_freeFlyTarget.InverseTransformPoint(raycastHit2.point);
                }
            }
        }
        if (this.m_freeFlyTarget)
        {
            quaternion = Quaternion.LookRotation((this.m_freeFlyTarget.TransformPoint(this.m_freeFlyTargetOffset) - base.transform.position).normalized, Vector3.up);
        }
        if (this.m_freeFlySmooth <= 0f)
        {
            base.transform.rotation = quaternion;
            return;
        }
        Quaternion rotation = Utils.SmoothDamp(base.transform.rotation, quaternion, ref this.m_freeFlyRef, this.m_freeFlySmooth, 9999f, dt);

        base.transform.rotation = rotation;
    }