public void AttachWheel(WheelController wheel)
 {
     if (!wheel)
     {
         return;
     }
     wheel.transform.parent = transform;
     wheels.Add(wheel);
 }
        public void DetachWheel(int index)
        {
            if (index < 0 || index >= wheels.Count)
            {
                return;
            }
            WheelController wheel = wheels[index];

            if (!wheel)
            {
                return;
            }
            wheel.transform.parent = null;
            wheels.RemoveAt(index);
        }
        private void ExecutionHandler()
        {
            metersPerSecond = transform.InverseTransformDirection(rigidbody.velocity).z;
            InputHandler();
            GearboxHandler();
            rpm = minimumRpm;
            for (int a = 0, A = wheels.Count; a < A; a++)
            {
                WheelController wheel = wheels[a];
                if (!wheel)
                {
                    continue;
                }
                if (wheel.motor)
                {
                    rpm = rpm + Mathf.Abs(wheel.wheelCollider.rpm);
                }
                wheel.Handle(gear == -2 ? -motorTorque * fuelPedal * gearRatio[0] : (gear >= 1 ? motorTorque * fuelPedal * gearRatio[gear] : 0F), brakeTorque * brakePedal + handbrakeTorque * handbrakeStick, steerAngle * steeringWheel);
            }
            rpm = rpm + Random.Range(-10F, 10F);
            if (rpm > maximumRpm)
            {
                rpm = maximumRpm + Random.Range(-100F, 100F);
            }
            if (centerOfMass)
            {
                rigidbody.centerOfMass = transform.InverseTransformPoint(centerOfMass.position);
            }
            rigidbody.AddForce(downforce * Vector3.down);
            speed = Library.Convert(metersPerSecond, speedUnit);
            if (engine)
            {
                if (!engine.isPlaying)
                {
                    engine.Play();
                }
                engine.pitch = 1F + rpm / maximumRpm;
            }

            TEMPORARY();
        }