예제 #1
0
    // Token: 0x060008C1 RID: 2241 RVA: 0x00038580 File Offset: 0x00036980
    private void SetInternalPos(Vector2 pos)
    {
        this.pollPos = pos;
        if (this.disableX)
        {
            pos.x = 0f;
        }
        if (this.disableY)
        {
            pos.y = 0f;
        }
        float   num        = Mathf.Clamp01(pos.magnitude);
        Vector2 normalized = this.dirVec;
        float   num2       = this.safeAngle;

        if (num > 0.01f)
        {
            normalized = pos.normalized;
            num2       = Mathf.Atan2(normalized.x, normalized.y) * 57.29578f;
        }
        if (num > ((this.dir8way != TouchStick.StickDir.NEUTRAL) ? this.joy.stickDigitalLeaveThresh : this.joy.stickDigitalEnterThresh))
        {
            if (this.dir8wayLastNonNeutral == TouchStick.StickDir.NEUTRAL)
            {
                this.dir4way = TouchStick.GetDirCodeFromAngle(num2, false);
                this.dir8way = TouchStick.GetDirCodeFromAngle(num2, true);
            }
            else if (num > this.joy.stickDigitalEnterThresh)
            {
                float dirCodeAngle = TouchStick.GetDirCodeAngle(this.dir8wayLastNonNeutral);
                if (Mathf.Abs(Mathf.DeltaAngle(dirCodeAngle, num2)) > 22.5f + this.joy.stickMagnetAngleMargin)
                {
                    this.dir8way = TouchStick.GetDirCodeFromAngle(num2, true);
                }
                else
                {
                    this.dir8way = this.dir8wayLastNonNeutral;
                }
                float dirCodeAngle2 = TouchStick.GetDirCodeAngle(this.dir4wayLastNonNeutral);
                if (Mathf.Abs(Mathf.DeltaAngle(dirCodeAngle2, num2)) > 45f + this.joy.stickMagnetAngleMargin)
                {
                    this.dir4way = TouchStick.GetDirCodeFromAngle(num2, false);
                }
                else
                {
                    this.dir4way = this.dir4wayLastNonNeutral;
                }
            }
        }
        else
        {
            this.dir4way = TouchStick.StickDir.NEUTRAL;
            this.dir8way = TouchStick.StickDir.NEUTRAL;
        }
        if (this.dir4way != TouchStick.StickDir.NEUTRAL)
        {
            this.dir4wayLastNonNeutral = this.dir4way;
        }
        if (this.dir8way != TouchStick.StickDir.NEUTRAL)
        {
            this.dir8wayLastNonNeutral = this.dir8way;
        }
        this.tilt      = num;
        this.angle     = num2;
        this.safeAngle = num2;
        this.posRaw    = normalized * num;
        this.dirVec    = normalized;
    }