public override void OnStart(PartModule.StartState state)
        {
            predictor = core.GetComputerModule <MechJebModuleLandingPredictions>();
            autopilot = core.GetComputerModule <MechJebModuleLandingAutopilot>();

            if (landingSites == null)
            {
                InitLandingSitesList();
            }
        }
        public ParachutePlan(MechJebModuleLandingAutopilot _autopliot)
        {
            // Create the linear regression for storing previous prediction results
            this.regression = new LinearRegression(dataSetSize); // Store the previous however many predictions

            // Take a reference to the landing autopilot module that we are working for.
            this.autoPilot = _autopliot;

            // Take a note of which body this parachute plan is for. If we go to a different body, we will need a new plan!
            this.body = _autopliot.vessel.orbit.referenceBody;
        }
        public MechJebModuleJoke(MechJebCore core)
            : base(core)
        {
            hidden  = true;
            enabled = true;

            sorry = core.part.gameObject.AddComponent <AudioSource>();
            WWW www = new WWW("file://" + KSPUtil.ApplicationRootPath.Replace("\\", "/") + "Parts/mumech_MechJebPod/snd1.wav");

            if ((sorry != null) && (www != null))
            {
                sorry.clip   = www.GetAudioClip(false);
                sorry.volume = 0;
                sorry.Stop();
            }

            glitch      = core.part.gameObject.AddComponent <AudioSource>();
            glitchClips = new AudioClip[NUM_GLITCH_SOUNDS];
            for (int i = 0; i < NUM_GLITCH_SOUNDS; i++)
            {
                www = new WWW("file://" + KSPUtil.ApplicationRootPath.Replace("\\", "/") + "Parts/mumech_MechJebPod/glitch" + i + ".wav");
                if (www != null)
                {
                    glitchClips[i] = www.GetAudioClip(false);
                }
            }

            foreach (ComputerModule module in core.modules)
            {
                if (module is MechJebModuleAscentAutopilot)
                {
                    ascent = (MechJebModuleAscentAutopilot)module;
                }
                if (module is MechJebModuleLandingAutopilot)
                {
                    landing = (MechJebModuleLandingAutopilot)module;
                }
                if (module is MechJebModuleTranslatron)
                {
                    translatron = (MechJebModuleTranslatron)module;
                }
            }
        }
Esempio n. 4
0
        public MechJebModuleJoke(MechJebCore core)
            : base(core)
        {
            hidden = true;
            enabled = true;

            sorry = core.part.gameObject.AddComponent<AudioSource>();
            WWW www = new WWW("file://" + KSPUtil.ApplicationRootPath.Replace("\\", "/") + "Parts/mumech_MechJebPod/snd1.wav");
            if ((sorry != null) && (www != null))
            {
                sorry.clip = www.GetAudioClip(false);
                sorry.volume = 0;
                sorry.Stop();
            }

            glitch = core.part.gameObject.AddComponent<AudioSource>();
            glitchClips = new AudioClip[NUM_GLITCH_SOUNDS];
            for (int i = 0; i < NUM_GLITCH_SOUNDS; i++)
            {
                www = new WWW("file://" + KSPUtil.ApplicationRootPath.Replace("\\", "/") + "Parts/mumech_MechJebPod/glitch" + i + ".wav");
                if (www != null)
                {
                    glitchClips[i] = www.GetAudioClip(false);
                }
            }

            foreach (ComputerModule module in core.modules)
            {
                if (module is MechJebModuleAscentAutopilot)
                {
                    ascent = (MechJebModuleAscentAutopilot)module;
                }
                if (module is MechJebModuleLandingAutopilot)
                {
                    landing = (MechJebModuleLandingAutopilot)module;
                }
                if (module is MechJebModuleTranslatron)
                {
                    translatron = (MechJebModuleTranslatron)module;
                }
            }
        }
Esempio n. 5
0
        void LoadComputerModules()
        {
            if (moduleRegistry == null)
            {
                moduleRegistry = new List <Type>();
                foreach (var ass in AppDomain.CurrentDomain.GetAssemblies())
                {
                    try
                    {
                        foreach (var module in (from t in ass.GetTypes() where t.IsSubclassOf(typeof(ComputerModule)) select t).ToList())
                        {
                            moduleRegistry.Add(module);
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("MechJeb moduleRegistry creation threw an exception in LoadComputerModules loading " + ass.FullName + ": " + e);
                    }
                }
            }

            Assembly        assembly        = Assembly.GetExecutingAssembly();
            FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);

            // Mono compiler is stupid and use AssemblyVersion for the AssemblyFileVersion
            // So we use an other field to store the dev build number ...
            Attribute[] attributes  = Attribute.GetCustomAttributes(assembly, typeof(AssemblyInformationalVersionAttribute));
            string      dev_version = "";

            if (attributes != null && attributes.Length != 0)
            {
                dev_version = ((AssemblyInformationalVersionAttribute)(attributes[0])).InformationalVersion;
            }

            if (dev_version == "")
            {
                version = fileVersionInfo.FileMajorPart + "." + fileVersionInfo.FileMinorPart + "." + fileVersionInfo.FileBuildPart;
            }
            else
            {
                version = dev_version;
            }

            try
            {
                foreach (Type t in moduleRegistry)
                {
                    if ((t != typeof(ComputerModule)) && (t != typeof(DisplayModule) && (t != typeof(MechJebModuleCustomInfoWindow))) &&
                        (t != typeof(AutopilotModule)) &&
                        !blacklist.Contains(t.Name) && (GetComputerModule(t.Name) == null))
                    {
                        AddComputerModule((ComputerModule)(t.GetConstructor(new Type[] { typeof(MechJebCore) }).Invoke(new object[] { this })));
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogError("MechJeb moduleRegistry loading threw an exception in LoadComputerModules: " + e);
            }

            attitude   = GetComputerModule <MechJebModuleAttitudeController>();
            staging    = GetComputerModule <MechJebModuleStagingController>();
            thrust     = GetComputerModule <MechJebModuleThrustController>();
            target     = GetComputerModule <MechJebModuleTargetController>();
            warp       = GetComputerModule <MechJebModuleWarpController>();
            rcs        = GetComputerModule <MechJebModuleRCSController>();
            rcsbal     = GetComputerModule <MechJebModuleRCSBalancer>();
            rover      = GetComputerModule <MechJebModuleRoverController>();
            node       = GetComputerModule <MechJebModuleNodeExecutor>();
            solarpanel = GetComputerModule <MechJebModuleSolarPanelController>();
            landing    = GetComputerModule <MechJebModuleLandingAutopilot>();
        }
 public override void OnStart(PartModule.StartState state)
 {
     predictor = core.GetComputerModule<MechJebModuleLandingPredictions>();
     autopilot = core.GetComputerModule<MechJebModuleLandingAutopilot>();
 }
        public ParachutePlan(MechJebModuleLandingAutopilot _autopliot)
        {
            // Create the linear regression for storing previous prediction results
            this.regression = new LinearRegression(dataSetSize); // Store the previous however many predictions

            // Take a reference to the landing autopilot module that we are working for.
            this.autoPilot = _autopliot;

            // Take a note of which body this parachute plan is for. If we go to a different body, we will need a new plan!
            this.body = _autopliot.vessel.orbit.referenceBody;
        }
Esempio n. 8
0
        void LoadComputerModules()
        {
            if (moduleRegistry == null)
            {
                moduleRegistry = new List <Type>();
                foreach (var ass in AppDomain.CurrentDomain.GetAssemblies())
                {
                    try
                    {
                        foreach (var module in (from t in ass.GetTypes() where t.IsSubclassOf(typeof(ComputerModule)) && !t.IsAbstract select t).ToList())
                        {
                            moduleRegistry.Add(module);
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("MechJeb moduleRegistry creation threw an exception in LoadComputerModules loading " + ass.FullName + ": " + e);
                    }
                }
            }

            Assembly        assembly        = Assembly.GetExecutingAssembly();
            FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);

            // Mono compiler is stupid and use AssemblyVersion for the AssemblyFileVersion
            // So we use an other field to store the dev build number ...
            Attribute[] attributes  = Attribute.GetCustomAttributes(assembly, typeof(AssemblyInformationalVersionAttribute));
            string      dev_version = "";

            if (attributes.Length > 0)
            {
                dev_version = ((AssemblyInformationalVersionAttribute)attributes[0]).InformationalVersion;
            }

            if (dev_version == "")
            {
                version = string.Format("{0}.{1}.{2}", fileVersionInfo.FileMajorPart, fileVersionInfo.FileMinorPart, fileVersionInfo.FileBuildPart);
            }
            else
            {
                version = dev_version;
            }

            if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight)
            {
                print("Loading Mechjeb " + version);
            }

            try
            {
                foreach (Type t in moduleRegistry)
                {
                    if ((t != typeof(ComputerModule)) && (t != typeof(DisplayModule) && (t != typeof(MechJebModuleCustomInfoWindow))) &&
                        (t != typeof(AutopilotModule)) &&
                        !blacklist.Contains(t.Name) && (GetComputerModule(t.Name) == null))
                    {
                        ConstructorInfo constructorInfo = t.GetConstructor(new[] { typeof(MechJebCore) });
                        if (constructorInfo != null)
                        {
                            AddComputerModule((ComputerModule)(constructorInfo.Invoke(new object[] { this })));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogError("MechJeb moduleRegistry loading threw an exception in LoadComputerModules: " + e);
            }

            attitude       = GetComputerModule <MechJebModuleAttitudeController>();
            staging        = GetComputerModule <MechJebModuleStagingController>();
            thrust         = GetComputerModule <MechJebModuleThrustController>();
            target         = GetComputerModule <MechJebModuleTargetController>();
            warp           = GetComputerModule <MechJebModuleWarpController>();
            rcs            = GetComputerModule <MechJebModuleRCSController>();
            rcsbal         = GetComputerModule <MechJebModuleRCSBalancer>();
            rover          = GetComputerModule <MechJebModuleRoverController>();
            node           = GetComputerModule <MechJebModuleNodeExecutor>();
            solarpanel     = GetComputerModule <MechJebModuleSolarPanelController>();
            antennaControl = GetComputerModule <MechJebModuleDeployableAntennaController>();
            landing        = GetComputerModule <MechJebModuleLandingAutopilot>();
            settings       = GetComputerModule <MechJebModuleSettings>();
            airplane       = GetComputerModule <MechJebModuleAirplaneAutopilot>();
            guidance       = GetComputerModule <MechJebModuleGuidanceController>();
            stageStats     = GetComputerModule <MechJebModuleStageStats>();
            stageTracking  = GetComputerModule <MechJebModuleLogicalStageTracking>();
        }
 public override void OnStart(PartModule.StartState state)
 {
     predictor = core.GetComputerModule <MechJebModuleLandingPredictions>();
     autopilot = core.GetComputerModule <MechJebModuleLandingAutopilot>();
 }
 public MechJebModuleScriptActionLanding(MechJebModuleScript scriptModule, MechJebCore core, MechJebModuleScriptActionsList actionsList) : base(scriptModule, core, actionsList, NAME)
 {
     module           = core.GetComputerModule <MechJebModuleLandingGuidance>();
     module_autopilot = core.GetComputerModule <MechJebModuleLandingAutopilot>();
     this.readModuleConfiguration();
 }