/// <summary>
        /// Add to Dictionary and return AirTarget ref of the adde missile
        /// </summary>
        /// <returns>Generated Target</returns>
        public ITarget CreateTarget4SAMMissile(MonoBehaviour missileScript)
        {
            //have to add scripts to missile's children to prevent bugs
            var mesh = missileScript.transform.Find("Mesh").gameObject;

            //Add AircraftScript to the missile
            var missileAircraftScript = (IAircraftScript)mesh.AddComponent(AircraftScript.type);

            ((MonoBehaviour)missileAircraftScript).enabled = false;

            //Create an Aircraft ref for missile
            var tempAircraft = NewAircraft;

            //Rename Aircraft
            tempAircraft.Name = "AA Missile";

            //Add PartScript to the missile, and use it as MainCockpit of the AircraftScript
            Component ckpt = mesh.AddComponent(PartScript.type);

            ((MonoBehaviour)ckpt).enabled = false;

            //Set AircraftScript values
            // missileAircraftScript.Aircraft = tempAircraft;
            // AircraftScript.InvokeMethod("set_MainCockpit", missileAircraftScript, new object[] { ckpt });
            AircraftScript.InvokeMethod("set_Aircraft", missileAircraftScript, new object[] { tempAircraft });
            missileAircraftScript.MainCockpit = (IPartScript)ckpt;

            //Create the target presenting missile
            var target = (ITarget)AirTarget.type.GetConstructor(new Type[] { AircraftScript.type }).Invoke(new object[] { missileAircraftScript });

            samLaunchedMissiles.Add(target, new SAMMissileInfo(missileAircraftScript, missileScript));
            return(target);
        }
 private void FixedUpdate()
 {
     for (int i = 0; i < aircraftLaunchedMissiles.Count; i++)
     {
         var       m         = aircraftLaunchedMissiles.ElementAt(i).Value;
         Rigidbody rigidbody = m.rigidbody;
         if (!rigidbody)
         {
             aircraftLaunchedMissiles.Remove(aircraftLaunchedMissiles.ElementAt(i--).Key);
             continue;
         }
         value[0] = rigidbody.velocity;
         AircraftScript.InvokeMethod("set_Velocity", m.missileAircraftScript, value);
     }
     for (int i = 0; i < samLaunchedMissiles.Count; i++)
     {
         var       m         = samLaunchedMissiles.ElementAt(i).Value;
         Rigidbody rigidbody = m.rigidbody;
         if (!rigidbody)
         {
             samLaunchedMissiles.Remove(samLaunchedMissiles.ElementAt(i--).Key);
             continue;
         }
         value[0] = rigidbody.velocity;
         AircraftScript.InvokeMethod("set_Velocity", m.missileAircraftScript, value);
     }
 }
        /// <summary>
        /// Add to Dictionary and return AirTarget ref of the adde missile
        /// </summary>
        /// <param name="missileScript"></param>
        /// <returns>Generated Target</returns>
        public ITarget CreateTarget4LaunchedMissile(IMissileScript missileScript)
        {
            //Register callback to handle missile explsion event
            missileScript.Exploded += OnMissleExploded;
            //Add AircraftScript to the missile
            var missileAircraftScript = (MonoBehaviour)((MonoBehaviour)missileScript).gameObject.AddComponent(AircraftScript.type);

            missileAircraftScript.enabled = false;
            IAircraft   tempAircraft = NewAircraft;
            IPartScript partScript   = (IPartScript)missileAircraftScript.GetComponent(PartScript.type);
            var         firedByName  = ((MonoBehaviour)partScript.Aircraft).name;

            //Rename Aircraft
            tempAircraft.Name = $"{missileAircraftScript.name} ({firedByName})";
            //Set AircraftScript values
            AircraftScript.InvokeMethod("set_Aircraft", missileAircraftScript, new object[] { tempAircraft });
            ((IAircraftScript)missileAircraftScript).MainCockpit = partScript;
            //Create the target presenting missile
            var target = (ITarget)AirTarget.type.GetConstructor(new Type[] { AircraftScript.type }).Invoke(new object[] { missileAircraftScript });

            aircraftLaunchedMissiles.Add(target, new MissileInfo((IAircraftScript)missileAircraftScript, (IMissileScript)missileScript));
            return(target);
        }