public void FixedUpdate()
    {
        int     num  = 0;
        float   num2 = 0f;
        float   num3 = 0f;
        Vector3 v    = referenceTransform.TransformDirection(referenceAxis);

        for (int i = 0; i < Human.all.Count; i++)
        {
            Human   human = Human.all[i];
            Vector3 v2    = Quaternion.Euler(0f, human.controls.targetYawAngle, 0f) * Vector3.forward;
            float   num4  = Math2d.SignedAngle(v.To2D(), v2.To2D());
            int     num5  = 0;
            num5 = ((-90f < num4 && num4 < 90f) ? 1 : (-1));
            if (human.ragdoll.partLeftHand.sensor.grabObject == grabTarget)
            {
                num2 += num4;
                num3 += (float)num5;
                num++;
            }
            if (human.ragdoll.partRightHand.sensor.grabObject == grabTarget)
            {
                num2 += num4;
                num3 += (float)num5;
                num++;
            }
        }
        if (steerMode == SteerMode.Steer)
        {
            if (num > 0)
            {
                num2 /= (float)num;
                if (num3 >= 0f)
                {
                    SetValue(num2 / (float)num);
                }
                else if (num2 < -90f)
                {
                    SetValue(-180f - num2);
                }
                else
                {
                    SetValue(180f - num2);
                }
            }
        }
        else
        {
            if (num3 < 2f)
            {
                num3 /= 4f;
            }
            SetValue(num3);
        }
    }
Exemplo n.º 2
0
        public override void ReadData()
        {
            if (autoWind)
            {
                if (showDebug)
                {
                    Debug.Log(base.name + " Auto Wind Compare vectors");
                }
                Vector3 referenceVector = base.transform.TransformDirection(new Vector3(1f, 0f, 0f));
                Vector3 normal          = base.transform.TransformDirection(new Vector3(0f, 0f, 1f));
                float   num;
                for (num = Math3d.SignedVectorAngle(referenceVector, initialWorldVectorX, normal); num - windAngle < -180f; num += 360f)
                {
                }
                while (num - windAngle > 180f)
                {
                    num -= 360f;
                }
                windAngle         = num;
                catapultWindCount = windAngle / 360f;
            }
            dataWindCount  = catapultWindCount;
            windRadius     = windCoreRadius + radius;
            localTargetPos = base.transform.InverseTransformPoint(target.position);
            Vector2 vector  = localTargetPos.SetZ(0f);
            float   num2    = Mathf.Acos(windRadius / vector.magnitude);
            Vector2 vector2 = vector.Rotate(0f - num2).normalized *windRadius;
            float   num3    = Math2d.NormalizeAnglePositive(Math2d.SignedAngle(new Vector2(0f, 1f), vector2) * ((float)Math.PI / 180f));
            float   num4    = num3 / ((float)Math.PI * 2f);
            int     num5    = Mathf.RoundToInt(catapultWindCount - num4);
            float   num6    = num4 + (float)num5 + 2f;

            exitWindPos = new Vector3(vector2.x, vector2.y, num6 * windThickness);
            if (autoWind)
            {
                if (showDebug)
                {
                    Debug.Log(base.name + " Auto Wind Calc Total Length");
                }
                straightT = 0.9f;
                float num7 = num6 * 2f * (float)Math.PI * windRadius / straightT;
                lengthChange = totalLen - num7;
                totalLen     = num7;
            }
            else
            {
                straightT = num6 * 2f * (float)Math.PI * windRadius / totalLen;
            }
            straightNormal   = vector2.normalized;
            straightBinormal = Vector3.Cross((vector - vector2).normalized, straightNormal);
        }
Exemplo n.º 3
0
 private void FixedUpdate()
 {
     for (int i = 0; i < Human.all.Count; i++)
     {
         Human human = Human.all[i];
         if (human.grabManager.IsGrabbed(paddle1.gameObject) && human.grabManager.IsGrabbed(paddle2.gameObject))
         {
             Vector3 vector  = base.transform.TransformDirection(alignAxis);
             Vector3 vector2 = Quaternion.Euler(0f, human.controls.targetYawAngle, 0f) * Vector3.forward;
             float   num     = Math2d.SignedAngle(vector2.To2D(), vector.To2D());
             num *= Vector3.Dot(vector.ZeroY(), vector2);
             Vector3 vector3 = paddle1.angularVelocity - boat.angularVelocity;
             float   num2    = Mathf.Abs(vector3.y);
             Vector3 vector4 = paddle2.angularVelocity - boat.angularVelocity;
             float   num3    = num2 + Mathf.Abs(vector4.y);
             boat.AddTorque(Vector3.up * Mathf.Clamp(num * strength * num3, 0f - maxTorque, maxTorque));
         }
     }
 }
Exemplo n.º 4
0
        protected override float ToOffset(Vector3 localPos)
        {
            float num = 90f - Math2d.SignedAngle(-belt.forward, new Vector2(Vector3.Dot(localPos, belt.forward), Vector3.Dot(localPos, belt.up)));

            return(num / 180f * belt.radialLength);
        }