protected override void Awake()
 {
     base.Awake();
     _inputController           = GetComponent <InputController>();
     _rotorController           = GetComponentInChildren <HeliRotorController>();
     _engines                   = GetComponentsInChildren <HeliEngine>().ToList();
     _helicopterCharacteristics = GetComponent <HelicopterCharacteristics>();
 }
    public void CreateHelicoSimSystem()
    {
        if (heliSimDummy != null)
        {
            return;
        }
        heliSimDummy = new GameObject("helicoCtrl");
        // For debugging with a 3d cube that is visible in the game

        /*heliSimDummy = GameObject.CreatePrimitive(PrimitiveType.Cube);
         * BoxCollider bcoll = heliSimDummy.GetComponent<BoxCollider>();
         * if(bcoll != null)
         * {
         *  DebugMsg("Destroying cube BoxCollider");
         *  Destroy(bcoll);
         * }*/
        DebugMsg("Helico heliSimDummy = " + heliSimDummy.name + " | " + heliSimDummy.GetInstanceID().ToString());
        AudioSource[] audioSources = this.GetComponentsInChildren <AudioSource>();
        foreach (AudioSource audioSrc in audioSources)
        {
            if (audioSrc.clip.name.Contains("RideOffTheValkyries"))
            {
                helicoMusic = audioSrc;
                prefabRoot  = audioSrc.gameObject;
                DebugMsg("Found helico Music Audio Source");
            }
            if (audioSrc.clip.name.Contains("HelicopterRotor"))
            {
                helicoRotorSound = audioSrc;
                DebugMsg("Found helico rotor Audio Source");
            }
        }

        rigidBody                        = heliSimDummy.AddComponent <Rigidbody>();
        rigidBody.useGravity             = false;
        rigidBody.mass                   = 100;
        rigidBody.drag                   = 1;
        rigidBody.angularDrag            = 4;
        rigidBody.interpolation          = RigidbodyInterpolation.None;
        rigidBody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
        rigidBody.constraints            = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
        capColl           = heliSimDummy.AddComponent <CapsuleCollider>();
        capColl.center    = new Vector3(0, 0.125f, 0.3f);
        capColl.radius    = 0.125f;
        capColl.height    = 7f;
        capColl.direction = 2;

        boxcoll        = heliSimDummy.AddComponent <BoxCollider>();
        boxcoll.center = new Vector3(0, 0.125f, 0.3f);
        boxcoll.size   = new Vector3(2.5f, 0.25f, 7f);

        Vector3 newPos = this.transform.position;

        //newPos.y += 1;
        heliSimDummy.transform.position = newPos;
        heliSimDummy.transform.rotation = this.transform.rotation;
        //rigidBody.useGravity = true;

        helicoCtrl = heliSimDummy.AddComponent <HelicopterController>();
        helicoCtrl.HelicopterModel = rigidBody;
        if (helicoRotorSound != null)
        {
            Audio.Manager.AddPlayingAudioSource(helicoRotorSound);
        }
        ctrlPanel = heliSimDummy.AddComponent <HelicoControlPanel>();
        helicoCtrl.ControlPanel = ctrlPanel;
        if (helicoMusic != null)
        {
            Audio.Manager.AddPlayingAudioSource(helicoMusic);
        }

        HeliRotorController rotorCtrl = rotor_joint.gameObject.AddComponent <HeliRotorController>();

        rotorCtrl.RotateAxis           = HeliRotorController.Axis.Z;
        helicoCtrl.MainRotorController = rotorCtrl;

        rotorCtrl                     = back_rotor_joint.gameObject.AddComponent <HeliRotorController>();
        rotorCtrl.RotateAxis          = HeliRotorController.Axis.Z;
        helicoCtrl.SubRotorController = rotorCtrl;

        ctrlPanel.entity = this;
        ctrlPanel.Start();
        helicoCtrl.entity = this;
        helicoCtrl.Start();

        heliSimDummy.SetActive(false);
    }