Пример #1
0
        void LoadComputerModules()
        {
            if (moduleRegistry == null)
            {
                moduleRegistry = (from ass in AppDomain.CurrentDomain.GetAssemblies() from t in ass.GetTypes() where t.IsSubclassOf(typeof(ComputerModule)) select t).ToList();
            }

            Version v = Assembly.GetAssembly(typeof(MechJebCore)).GetName().Version;

            version = v.Major.ToString() + "." + v.Minor.ToString() + "." + v.Build.ToString();

            foreach (Type t in moduleRegistry)
            {
                if ((t != typeof(ComputerModule)) && (t != typeof(DisplayModule) && (t != typeof(MechJebModuleCustomInfoWindow))) &&
                    !blacklist.Contains(t.Name) && (GetComputerModule(t.Name) == null))
                {
                    AddComputerModule((ComputerModule)(t.GetConstructor(new Type[] { typeof(MechJebCore) }).Invoke(new object[] { this })));
                }
            }

            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>();
        }
Пример #2
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.GetAssembly(typeof(MechJebCore));
            FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);

            if (fileVersionInfo.FilePrivatePart == 0)
            {
                version = fileVersionInfo.FileMajorPart + "." + fileVersionInfo.FileMinorPart + "." + fileVersionInfo.FileBuildPart;
            }
            else
            {
                version = "Dev #" + fileVersionInfo.FilePrivatePart;
            }

            try
            {
                foreach (Type t in moduleRegistry)
                {
                    if ((t != typeof(ComputerModule)) && (t != typeof(DisplayModule) && (t != typeof(MechJebModuleCustomInfoWindow))) &&
                        !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>();
        }
Пример #3
0
        void LoadComputerModules()
        {
            if (moduleRegistry == null)
            {
                moduleRegistry = new List <Type>();
                foreach (var ass in AppDomain.CurrentDomain.GetAssemblies())
                {
                    try
                    {
                        moduleRegistry.AddRange((from t in ass.GetTypes() where t.IsSubclassOf(typeof(ComputerModule)) select t).ToList());
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("MechJeb moduleRegistry creation threw an exception in LoadComputerModules loading " + ass.FullName + ": " + e);
                    }
                }
            }

            System.Version v = Assembly.GetAssembly(typeof(MechJebCore)).GetName().Version;
            version = v.Major.ToString() + "." + v.Minor.ToString() + "." + v.Build.ToString();

            try
            {
                foreach (Type t in moduleRegistry)
                {
                    if ((t != typeof(ComputerModule)) && (t != typeof(DisplayModule) && (t != typeof(MechJebModuleCustomInfoWindow))) &&
                        !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>();
        }
Пример #4
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>();
        }
Пример #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)) && !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>();
        }