示例#1
0
        private IEnumerable <string> CheckInstallLocation()
        {
            UrlDir gameData = GameDatabase.Instance.root.children.First(dir => dir.type == UrlDir.DirectoryType.GameData);

            AssemblyLoader.LoadedAssembly loadedAssembly = AssemblyLoader.loadedAssemblies.GetByAssembly(Assembly.GetExecutingAssembly());

            if (loadedAssembly == null)
            {
                Debug.LogError("[Restock] Error checking install location - could not find loaded assembly");
                yield break;
            }

            UrlDir assemblyDir = GetDirectory(gameData, loadedAssembly.url);

            if (assemblyDir == null)
            {
                Debug.LogError("[Restock] Error checking install location - could not find assembly url directory: " + loadedAssembly.url);
                yield break;
            }

            string observedInstallPath = Path.GetFullPath(assemblyDir.parent.path);
            string expectedInstallPath = Path.GetFullPath(Path.Combine(KSPUtil.ApplicationRootPath, Path.Combine("GameData", "ReStock")));

            if (observedInstallPath != expectedInstallPath)
            {
                Debug.LogError($"[Restock] Install found at '{observedInstallPath}'");
                yield return($"Expected Restock to be installed at\n{expectedInstallPath}\nbut actually installed at\n{observedInstallPath}");
            }
        }
示例#2
0
        private static bool LoadTypeInfo()
        {
            AssemblyLoader.LoadedAssembly loadedAssembly = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.dllName == "Toolbar");
            if (loadedAssembly == null)
            {
                LogWarningS("Could not find Toolbar.dll.");
                return(false);
            }
            assembly = loadedAssembly.assembly;

            toolbarManagerType = assembly.GetExportedTypes().FirstOrDefault(t => t.FullName == "Toolbar.ToolbarManager");
            if (toolbarManagerType == null)
            {
                LogWarningS("Could not find the Toolbar.ToolbarManager type.");
                return(false);
            }

            instanceProperty = toolbarManagerType.GetProperty("Instance");
            if (instanceProperty == null)
            {
                LogWarningS("Could not find the ToolbarManager.Instance property.");
                return(false);
            }

            addMethod = toolbarManagerType.GetMethod("add");
            if (addMethod == null)
            {
                LogWarningS("Could not find the ToolbarManager.add method.");
                return(false);
            }

            typeInfoIsLoaded = true;
            return(true);
        }
示例#3
0
 internal AssemblyLog(AssemblyLoader.LoadedAssembly assembly)
 {
     name        = assembly.assembly.GetName().Name;
     version     = assembly.assembly.GetName().Version.ToString();
     infoVersion = FileVersionInfo.GetVersionInfo(assembly.assembly.Location).ProductVersion;
     location    = assembly.url.ToString();
 }
示例#4
0
        //////////////////////////////////////////
        ////////////// Edit here /////////////////
        //////////////////////////////////////////

        // return true to remove the mod
        // return false to skip
        // set WARNING to a message that warns the player about any glitches or incompatibilities that may arise
        public static bool Check(AssemblyLoader.LoadedAssembly assembly)
        {
            //only show warnings if the mod is enabled
            if (NewKerbolConfig.ModEnabled)
            {
                if (assembly.name == "Clouds")
                {
                    WARNING = "Enviromental Visual Enhancements is not comaptible with New Kerbol. It causes visual glitches with some planets, and may lead to an instable game. It would be best if you removed one. ";
                    return(true);
                }
                if (assembly.name == "PlanetFactory")
                {
                    WARNING = "Planet Factory is not compatible with New Kerbol. Together, they may cause bugs or crashes, and it would be best if you removed one.";
                    return(true);
                }
                if (assembly.name == "RealSolarSystem")
                {
                    WARNING = "Real Solar System is not compatible with New Kerbol. It may cause game-breaking issues, or even crashes. You should not run both mods at the same time. It would be best if you removed one.";
                    return(true);
                }
                if (assembly.name == "AlternisKerbol")
                {
                    WARNING = "Alternis Kerbol is not compatible with New Kerbol. They both seek to accomplish the same thing (change the stock system) and really should not be run together. It would be best if you removed one.";
                    return(true);
                }
            }
            return(false);
        }
示例#5
0
        public static bool Initialize()
        {
            if (!initialized)
            {
                KISasm = AssemblyLoader.loadedAssemblies.Where(a => a.assembly.GetName().Name.Equals("KIS", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
                if (KISasm == null)
                {
                    return(false);
                }
                KISAddonConfig_class = KISasm.assembly.GetTypes().Where(t => t.Name.Equals("KISAddonConfig")).FirstOrDefault();
                if (KISAddonConfig_class == null)
                {
                    return(false);
                }
                kis_AddPodInventories = KISAddonConfig_class.GetMethod("AddPodInventories", BindingFlags.Public | BindingFlags.Static);
                if (kis_AddPodInventories == null)
                {
                    return(false);
                }

                AddPodInventories = (AddPodInventoriesDelegate)Delegate.CreateDelegate(typeof(AddPodInventoriesDelegate), null, kis_AddPodInventories);
                initialized       = true;
            }
            return(AddPodInventories != null);
        }
 private void checkDependencies()
 {
     AssemblyLoader.LoadedAssembly assembly = AssemblyLoader.loadedAssemblies.Where(a => a.assembly.GetName().Name == "TweakScale").First();
     if (-1 == assembly.assembly.GetName().Version.CompareTo(new System.Version(2, 4, 4)))
     {
         GUI.UnmetRequirementsShowStopperAlertBox.Show("TweakScale v2.4.4 or superior");
     }
 }
示例#7
0
        // Called after Awake()
        public void Start()
        {
            ASPConsoleStuff.AAprint("Start()");
            aspTexture         = loadTexture("AutoAsparagus/asparagus");
            onionTexture       = loadTexture("AutoAsparagus/onion");
            nofuelTexture      = loadTexture("AutoAsparagus/nofuel");
            launchclampTexture = loadTexture("AutoAsparagus/launchclamp");
            parachuteTexture   = loadTexture("AutoAsparagus/parachute");
            sepratronTexture   = loadTexture("AutoAsparagus/sepratron");
            rainbowTexture     = loadTexture("AutoAsparagus/rainbow");

            AssemblyLoader.LoadedAssembly SmartStage = AssemblyLoader.loadedAssemblies.SingleOrDefault(a => a.dllName == "SmartStage");
            if (SmartStage != null)
            {
                ASPConsoleStuff.AAprint("found SmartStage");
                try
                {
                    computeStagesMethod = SmartStage.assembly.GetTypes().SingleOrDefault(t => t.Name == "SmartStage").GetMethod("computeStages");
                }
                catch (Exception e)
                {
                    UnityEngine.Debug.LogError("Error finding the method definition\n" + e.StackTrace);
                }
                smartstageTexture   = loadTexture("SmartStage/SmartStage38");
                SmartStageAvailable = true;
            }
            else
            {
                ASPConsoleStuff.AAprint("no SmartStage found");
                useSmartStage = false;
            }
            versionString = Assembly.GetCallingAssembly().GetName().Version.ToString();

            line               = lineObj.AddComponent <LineRenderer>();
            line.material      = Resources.Load <Material>("Telemetry/TelemetryMaterial");
            line.useWorldSpace = false;

            line.startColor    = Color.red;
            line.endColor      = Color.red;
            line.startWidth    = 0.2f;
            line.endWidth      = 0.2f;
            line.positionCount = 2;
            line.SetPosition(0, Vector3.zero);
            line.enabled = false;

            ASPConsoleStuff.AAprint("setting up toolbar");
            toolbarControl = gameObject.AddComponent <ToolbarControl>();
            toolbarControl.AddToAllToolbars(appOnTrue, appOnFalse,
                                            ApplicationLauncher.AppScenes.VAB | ApplicationLauncher.AppScenes.SPH,
                                            MODID,
                                            "AutoAsparagusButton",
                                            "AutoAsparagus/asparagus-app",
                                            "AutoAsparagus/asparagus",
                                            MODNAME
                                            );

            ASPConsoleStuff.AAprint("End of Start()");
        }
        public static Settings Load()
        {
            // Create a blank object of settings
            Settings settings       = new Settings();
            bool     defaultSuccess = false;

            AssemblyLoader.LoadedAssembly assemblyDLL = null;
            for (int i = 0; i <= AssemblyLoader.loadedAssemblies.Count; i++)
            {
                if (AssemblyLoader.loadedAssemblies[i].assembly.GetName().Name.Equals("CommNetConstellation"))
                {
                    assemblyDLL = AssemblyLoader.loadedAssemblies[i];
                    break;
                }
            }

            startingSettingCFGUrl = assemblyDLL.url.Replace("/Plugins", "") + "/cnc_settings/CommNetConstellationSettings";
            settings.MajorVersion = assemblyDLL.versionMajor;
            settings.MinorVersion = assemblyDLL.versionMinor;

            // Exploit KSP's GameDatabase to find our MM-patched cfg of default settings
            UrlDir.UrlConfig[] cfgs = GameDatabase.Instance.GetConfigs("CommNetConstellationSettings");
            for (var i = 0; i < cfgs.Length; i++)
            {
                if (cfgs[i].url.Equals(startingSettingCFGUrl))
                {
                    defaultSuccess = ConfigNode.LoadObjectFromConfig(settings, cfgs[i].config);

                    //Workaround due to LoadObjectFromConfig not auto-populating ground stations for unknown reason
                    settings.GroundStations = new List <CNCCommNetHome>();
                    ConfigNode[] stationNodes = cfgs[i].config.GetNode("GroundStations").GetNodes();
                    for (int j = 0; j < stationNodes.Length; j++)
                    {
                        CNCCommNetHome dummyGroundStation = new CNCCommNetHome();
                        ConfigNode.LoadObjectFromConfig(dummyGroundStation, stationNodes[j]);
                        settings.GroundStations.Add(dummyGroundStation);
                    }

                    CNCLog.Verbose("Load starting settings into object with {0}: LOADED {1}", cfgs[i].config, defaultSuccess ? "OK" : "FAIL");
                    break;
                }
            }

            if (!defaultSuccess) // disable itself and write explanation to KSP's log
            {
                CNCLog.Error("The CommNet Constellation setting file '{0}' is not found!", startingSettingCFGUrl);
                return(null);
                // the main impact of returning null is the endless loop of invoking Load() in the KSP's loading screen
            }

            settings.SettingsLoaded = true;
            settings.postprocess();
            return(settings);
        }
 public void Update()
 {
     if (GF == null)
     {
         GF = AssemblyLoader.loadedAssemblies.SingleOrDefault(a => a.dllName == "Gameframer");
         PublicInterfaceType     = GF.assembly.GetTypes().FirstOrDefault(t => t.Name == "GFPublicInterface");
         registerEventMethod     = PublicInterfaceType.GetMethod("RegisterEvent");
         deregisterEventMethod   = PublicInterfaceType.GetMethod("DeregisterEvent");
         captureEventMethod      = PublicInterfaceType.GetMethod("CaptureEvent");
         PublicInterfaceInstance = MonoBehaviour.FindObjectsOfType(PublicInterfaceType).FirstOrDefault();
     }
 }
示例#10
0
 private void findAssemblies(string[] assemblies)
 {
     foreach (string name in assemblies)
     {
         AssemblyLoader.LoadedAssembly assembly = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.assembly.GetName().Name == name);
         if (assembly != null)
         {
             DMUtils.Logging("Assembly: {0} Found; Reactivating Experiment Properties", assembly.assembly.GetName().Name);
             DMUtils.whiteListed = true;
         }
     }
 }
        void Awake()
        {
#if false
            AssemblyLoader.LoadedAssembly[] list = AssemblyLoader.loadedAssemblies.Where(a => a.name == "LoadingScreenManager").ToArray();
            TheChosenOne = list.FirstOrDefault(a => a.assembly.GetName().Version == list.Select(i => i.assembly.GetName().Version).Max());
            if (first && Assembly.GetExecutingAssembly() == TheChosenOne.assembly)
            {
                Version = TheChosenOne.assembly.GetName().Version.ToString();
                Log.Info(Version);
                first = false;
                DontDestroyOnLoad(this);
            }
            else
            {
                DestroyImmediate(this);
            }
#endif

            // Following makes sure only the newest version of the DLL is run, assuming there are more than one.
            // Copied from Module Manager
            Assembly currentAssembly = Assembly.GetExecutingAssembly();
            IEnumerable <AssemblyLoader.LoadedAssembly> eligible = from a in AssemblyLoader.loadedAssemblies
                                                                   let ass = a.assembly
                                                                             where ass.GetName().Name == currentAssembly.GetName().Name
                                                                             orderby ass.GetName().Version descending, a.path ascending
            select a;

            // Elect the newest loaded version of LSM to set up the screens.
            // If there is a newer version loaded then don't do anything
            // If there is a same version but earlier in the list, don't do anything either.
            if (eligible.First().assembly != currentAssembly)
            {
                Log.Info("version " + currentAssembly.GetName().Version + " at " + currentAssembly.Location +
                         " lost the election");
                DestroyImmediate(this);
                return;
            }
            string candidates = "";
            foreach (AssemblyLoader.LoadedAssembly a in eligible)
            {
                if (currentAssembly.Location != a.path)
                {
                    candidates += "Version " + a.assembly.GetName().Version + " " + a.path + " " + "\n";
                }
            }
            if (candidates.Length > 0)
            {
                Log.Info("version " + currentAssembly.GetName().Version + " at " + currentAssembly.Location +
                         " won the election against\n" + candidates);
            }

            Version = currentAssembly.GetName().Version.ToString();
        }
示例#12
0
 private static bool isAssemblyLoaded(String name)
 {
     for (int i = 0; i < AssemblyLoader.loadedAssemblies.Count; i++)
     {
         AssemblyLoader.LoadedAssembly assembly = AssemblyLoader.loadedAssemblies[i];
         if (assembly.name == name)
         {
             return(true);
         }
     }
     return(false);
 }
示例#13
0
        public virtual void Start()
        {
            Assembly currentAssembly = Assembly.GetExecutingAssembly();
            IEnumerable <AssemblyLoader.LoadedAssembly> partUpgradeAssemblies = from a in AssemblyLoader.loadedAssemblies
                                                                                where a.assembly.GetName().Name == currentAssembly.GetName().Name
                                                                                //orderby a.path ascending
                                                                                orderby System.Diagnostics.FileVersionInfo.GetVersionInfo(a.path).FileVersion descending, a.path ascending
            select a;

            //foreach (AssemblyLoader.LoadedAssembly assemblyContainer in eligible)
            //{
            //	Debug.Log("[PartUpgrade] Assembly loaded FileVersion: "
            //		+ System.Diagnostics.FileVersionInfo.GetVersionInfo(assemblyContainer.path).FileVersion);
            //	Debug.Log("[PartUpgrade] Assembly loaded Location: "
            //						+ assemblyContainer.assembly.Location);
            //	Debug.Log("[PartUpgrade] Assembly loaded dllName: " + assemblyContainer.dllName);
            //	Debug.Log("[PartUpgrade] Assembly loaded name: " + assemblyContainer.name);
            //	Debug.Log("[PartUpgrade] Assembly loaded path: " + assemblyContainer.path);
            //	Debug.Log("[PartUpgrade] Assembly loaded versionMM: " + assemblyContainer.versionMajor+" . "
            //		+ assemblyContainer.versionMinor);
            //}

            AssemblyLoader.LoadedAssembly first = partUpgradeAssemblies.First();

            //remove 0.3 (as it's with 1.0.1 FileVersion & Product version)
            //osef.
            //if (first.path.Contains("PartUpgrade_999799_beta_v0.3.dll"))
            //{
            //	first.
            //	var list = partUpgradeAssemblies.ToList();
            //	if (list.Count > 1)
            //	{
            //		first = list[1];
            //	}
            //}



            //if (System.Diagnostics.FileVersionInfo.GetVersionInfo(currentAssembly.Location).FileVersion
            //	!= System.Diagnostics.FileVersionInfo.GetVersionInfo(eligible.First().assembly.Location).FileVersion)
            if (currentAssembly.Location != first.path)
            {
                //Debug.LogError("[PartUpgrade] Warning: Wrong PartUprade is loaded : v "
                //	+ System.Diagnostics.FileVersionInfo.GetVersionInfo(currentAssembly.Location).FileVersion
                //	+ " instead of v " +
                //System.Diagnostics.FileVersionInfo.GetVersionInfo(first.path).FileVersion);
                Debug.LogError("[PartUpgrade] Warning: Wrong PartUprade is loaded : v"
                               + System.Diagnostics.FileVersionInfo.GetVersionInfo(currentAssembly.Location).ProductVersion
                               + " instead of v" +
                               System.Diagnostics.FileVersionInfo.GetVersionInfo(first.path).ProductVersion);
            }
        }
示例#14
0
 public static bool needLongWait()
 {
     AssemblyLoader.LoadedAssembyList _assemblies = AssemblyLoader.loadedAssemblies;
     for (int _i = _assemblies.Count - 1; _i >= 0; --_i)
     {
         AssemblyLoader.LoadedAssembly _assembly = _assemblies[_i];
         if (longWait.Contains(_assembly.name))
         {
             return(true);
         }
     }
     return(false);
 }
示例#15
0
        /// <summary>
        /// Selects whether the assembly should get executed
        /// </summary>
        /// <returns></returns>
        public bool SelectAssembly()
        {
            // Select all screamer assemblies
            Assembly thisAssembly = Assembly.GetCallingAssembly();

            AssemblyLoader.LoadedAssembly[] list = AssemblyLoader.loadedAssemblies
                                                   .Where(a => a.assembly.GetName().Name == thisAssembly.GetName().Name).ToArray();

            // Select the most recent one
            AssemblyLoader.LoadedAssembly assembly = list.OrderByDescending(a => BuiltTime(a.assembly)).First();

            return(Equals(thisAssembly, assembly.assembly));
        }
        public static bool Initialize()
        {
            if (!inited)
            {
                inited = true;                 // do this only once, assemblies won't change
                AssemblyLoader.LoadedAssembly KASAPIasm    = null;
                AssemblyLoader.LoadedAssembly KASasm       = null;
                AssemblyLoader.LoadedAssembly KASLegacyasm = null;

                foreach (var la in AssemblyLoader.loadedAssemblies)
                {
                    if (la.assembly.GetName().Name.Equals("KAS-API-v1", StringComparison.InvariantCultureIgnoreCase))
                    {
                        KASAPIasm = la;
                    }
                    else if (la.assembly.GetName().Name.Equals("KAS", StringComparison.InvariantCultureIgnoreCase))
                    {
                        if (KASLegacyasm == null)
                        {
                            KASLegacyasm = la;
                        }
                        else
                        {
                            KASasm = la;
                        }
                    }
                }
                haveKAS = false;
                if (KASAPIasm != null && KASasm != null)
                {
                    haveKAS = true;
                    ILinkPeer.Initialize(KASAPIasm.assembly);
                    ILinkSource.Initialize(KASAPIasm.assembly);
                    ILinkTarget.Initialize(KASAPIasm.assembly);
                    ILinkJoint.Initialize(KASAPIasm.assembly);
                    IKasLinkEvent.Initialize(KASAPIasm.assembly);
                    IKasEvents.Initialize(KASAPIasm.assembly);

                    KASJointCableBase.Initialize(KASasm.assembly);
                }
                if (KASLegacyasm != null)
                {
                    haveKAS = true;
                    KASModuleStrut.Initialize(KASLegacyasm.assembly);
                }
            }

            return(haveKAS);
        }
示例#17
0
 private void checkDependencies()
 {
     try
     {
         AssemblyLoader.LoadedAssembly assembly = AssemblyLoader.loadedAssemblies.Where(a => a.assembly.GetName().Name == "Scale").First();
         if (-1 == assembly.assembly.GetName().Version.CompareTo(new System.Version(2, 4, 4)))
         {
             GUI.UnmetRequirementsShowStopperAlertBox.Show("TweakScale v2.4.4 or superior");
         }
     }
     catch (Exception e) when(e is NullReferenceException || e is InvalidOperationException)
     {
         GUI.UnmetRequirementsShowStopperAlertBox.Show("TweakScale v2.4.4 or superior");
     }
 }
        public bool init()
        {
            if (!AssemblyLoader.loadedAssemblies.Any(a => a.assembly.GetName().Name == "FerramAerospaceResearch"))
            {
                return(false);
            }

            AssemblyLoader.LoadedAssembly far = AssemblyLoader.loadedAssemblies.First(a => a.assembly.GetName().Name == "FerramAerospaceResearch");

            /*
             * foreach(Type t in far.assembly.GetExportedTypes())
             * {
             *  Log.post("--exported Type from FAR--");
             *  Log.post("name: " + t.Name);
             *  Log.post("full name: " + t.FullName);
             *  Log.post("is Class: " + t.IsClass);
             *  Log.post("---------------------------");
             * }
             */

            aeroUtilType = far.assembly.GetExportedTypes().First(x => x.Name == "FARAeroUtil");

            if (aeroUtilType == null)
            {
                Log.post("could not find class FARAeroUtil");
                return(false);
            }

            // init delegates
            try
            {
                getAirDensityAlt = (getAirDensityAltFunc)Delegate.CreateDelegate(typeof(getAirDensityAltFunc), null,
                                                                                 aeroUtilType.GetMethod("GetCurrentDensity", new Type[] { typeof(CelestialBody), typeof(double), typeof(bool) }));

                getAirDensityPos = (getAirDensityPosFunc)Delegate.CreateDelegate(typeof(getAirDensityPosFunc), null,
                                                                                 aeroUtilType.GetMethod("GetCurrentDensity", new Type[] { typeof(CelestialBody), typeof(Vector3), typeof(bool) }));

                //updateCurrentActiveBody = (updateCurrentActivelBodyFunc)Delegate.CreateDelegate(typeof(updateCurrentActivelBodyFunc), null,
                //    aeroUtilType.GetMethod("UpdateCurrentActiveBody", new Type[] { typeof(CelestialBody)}));
            }
            catch (Exception e)
            {
                Log.postException("error initializing FAR athmosphere model", e);
                return(false);
            }

            return(true);
        }
示例#19
0
 private void findAssemblies(string[] assemblies)
 {
     assemblyList.Add(new AssemblyLog(AssemblyLoader.loadedAssemblies.GetByAssembly(Assembly.GetExecutingAssembly()))); //More reliable method for SCANsat.dll
     foreach (string name in assemblies)                                                                                //Search for the relevant plugins among the loaded assemblies
     {
         AssemblyLoader.LoadedAssembly assembly = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.assembly.GetName().Name == name);
         if (assembly != null)
         {
             assemblyList.Add(new AssemblyLog(assembly));
         }
     }
     if (assemblyList.Count > 0)
     {
         SCANsatVersion = assemblyList[0].infoVersion;
         SCANurl        = assemblyList[0].location;
         debugWriter();
     }
 }
示例#20
0
        private Athmosphere()
        {
            if (currentModel == null)
            {
                bool isFARLoaded  = AssemblyLoader.loadedAssemblies.Any(a => a.assembly.GetName().Name == "FerramAerospaceResearch");
                bool isNEARLoaded = AssemblyLoader.loadedAssemblies.Any(a => a.assembly.GetName().Name == "NEAR");

                //isFARLoaded = false;

                if (isFARLoaded)
                {
                    Log.post("FAR detected", LogLevel.LOG_INFORMATION);

                    AssemblyLoader.LoadedAssembly FAR = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.assembly.GetName().Name == "FerramAerospaceResearch");
                    Log.post("FAR Version: " + FAR.assembly.GetName().Version.ToString(), LogLevel.LOG_INFORMATION);

                    currentModel = new AthmosphereModelFAR();
                    if (!currentModel.init())
                    {
                        fallBackToStock();
                    }
                }
                else if (isNEARLoaded)
                {
                    Log.post("NEAR detected", LogLevel.LOG_INFORMATION);

                    AssemblyLoader.LoadedAssembly NEAR = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.assembly.GetName().Name == "NEAR");
                    Log.post("NEAR Version: " + NEAR.assembly.GetName().Version.ToString(), LogLevel.LOG_INFORMATION);

                    currentModel = new AthmosphereModelNEAR();
                    if (!currentModel.init())
                    {
                        fallBackToStock();
                    }
                }
                else
                {
                    Log.post("No FAR or NEAR detected...", LogLevel.LOG_INFORMATION);

                    fallBackToStock();
                }
            }
        }
示例#21
0
        void cleanMiniAVC()
        {
            AssemblyLoader.LoadedAssembyList _assemblies = AssemblyLoader.loadedAssemblies;
            for (int _i = _assemblies.Count - 1; _i >= 0; --_i)
            {
                AssemblyLoader.LoadedAssembly _assembly = _assemblies[_i];

                if (_assembly.name.ToLower() == "miniavc")
                {
                    _assembly.Unload();
                    AssemblyLoader.loadedAssemblies.RemoveAt(_i);
                    DoCleanup(_assembly.path);
                }
            }
            FindAllDLLs();
            if (duplicateDlls.Count > 0)
            {
                this.gameObject.AddComponent <IssueGui>();
            }
        }
示例#22
0
 /// <summary>
 /// Checks if Navutils is installed and sets the HomeDirectory Path
 /// </summary>
 /// <returns></returns>
 public static bool DetectNavUtils()
 {
     if (detected != null)
     {
         return((bool)detected);
     }
     detected = false;
     foreach (AssemblyLoader.LoadedAssembly asm in AssemblyLoader.loadedAssemblies)
     {
         Log.Normal("ILS: assembly: " + asm.name);
         if (asm.name.Equals(navUtilsAssmName))
         {
             navUtilAssm = asm;
             detected    = true;
             String     code = asm.assembly.CodeBase;
             UriBuilder uri  = new UriBuilder(code);
             NavUtilsHome = Path.GetDirectoryName(Uri.UnescapeDataString(uri.Path));
             break;
         }
     }
     return((bool)detected);
 }
        public static bool VerifyResearchBodiesAPI()
        {
            AssemblyLoader.LoadedAssembly ResearchBodies = AssemblyLoader.loadedAssemblies.SingleOrDefault(a => a.dllName == "ResearchBodies");

            if (ResearchBodies != null)
            {
                RBWrapper.InitRBWrapper();

                if (RBWrapper.APIRBReady)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
示例#24
0
        /// <summary>
        /// Search through loaded assemblies to find the specified Type that's
        /// in the specified assembly.
        /// </summary>
        /// <param name="assemblyName"></param>
        /// <param name="fullTypeName"></param>
        /// <returns></returns>
        internal static Type GetExportedType(string assemblyName, string fullTypeName)
        {
            int assyCount = AssemblyLoader.loadedAssemblies.Count;

            for (int assyIndex = 0; assyIndex < assyCount; ++assyIndex)
            {
                AssemblyLoader.LoadedAssembly assy = AssemblyLoader.loadedAssemblies[assyIndex];
                if (assy.name == assemblyName)
                {
                    Type[] exportedTypes = assy.assembly.GetExportedTypes();
                    int    typeCount     = exportedTypes.Length;
                    for (int typeIndex = 0; typeIndex < typeCount; ++typeIndex)
                    {
                        if (exportedTypes[typeIndex].FullName == fullTypeName)
                        {
                            return(exportedTypes[typeIndex]);
                        }
                    }
                }
            }

            return(null);
        }
示例#25
0
 public void Awake()
 {
     if (Object.op_Inequality((Object)ConfigManager.Instance, (Object)null))
     {
         Object.Destroy((Object)((Component)ConfigManager.Instance).get_gameObject());
     }
     ConfigManager.Instance = this;
     this.LoadSettings();
     using (IEnumerator <AssemblyLoader.LoadedAssembly> enumerator = ((AssemblyLoader.LoadedAssembyList)AssemblyLoader.loadedAssemblies).GetEnumerator())
     {
         while (((IEnumerator)enumerator).MoveNext())
         {
             AssemblyLoader.LoadedAssembly current = enumerator.Current;
             if (current.get_name() == "Toolbar")
             {
                 this.config.blizzyToolbarInstalled = true;
             }
             if (current.get_name() == "Kopernicus")
             {
                 this.config.kopernicusInstalled = true;
             }
         }
     }
 }
        internal AssemblyLog(AssemblyLoader.LoadedAssembly Assembly)
        {
            assemblyLoaded = Assembly.assembly;
            var ainfoV = Attribute.GetCustomAttribute(Assembly.assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;
            var afileV = Attribute.GetCustomAttribute(Assembly.assembly, typeof(AssemblyFileVersionAttribute)) as AssemblyFileVersionAttribute;

            switch (afileV == null)
            {
            case true: fileVersion = ""; break;

            default: fileVersion = afileV.Version; break;
            }

            switch (ainfoV == null)
            {
            case true: infoVersion = ""; break;

            default: infoVersion = ainfoV.InformationalVersion; break;
            }

            name     = Assembly.assembly.GetName().Name;
            version  = Assembly.assembly.GetName().Version.ToString();
            location = Assembly.url.ToString();
        }
示例#27
0
 void cleanMiniAVC()
 {
     AssemblyLoader.LoadedAssembyList _assemblies = AssemblyLoader.loadedAssemblies;
     for (int _i = _assemblies.Count - 1; _i >= 0; --_i)
     {
         AssemblyLoader.LoadedAssembly _assembly = _assemblies[_i];
         if (_assembly.name == "MiniAVC")
         {
             _assembly.Unload();
             AssemblyLoader.loadedAssemblies.RemoveAt(_i);
             string _mod       = mod(_assembly.path);
             string _prunePath = _assembly.path + pruneExt;
             if (File.Exists(_prunePath))
             {
                 File.Delete(_prunePath);
             }
             if (prune)
             {
                 File.Move(_assembly.path, _prunePath);
                 ConfigNode _cfgMod = config.AddNode("mod");
                 _cfgMod.AddValue("name", _mod);
                 _cfgMod.AddValue("pruned", _prunePath);
                 screenMsg("MiniAVC pruned for " + _mod);
             }
             else if (delete)
             {
                 File.Delete(_assembly.path);
                 screenMsg("MiniAVC deleted for " + _mod);
             }
             else
             {
                 screenMsg("MiniAVC disabled for " + _mod);
             }
         }
     }
 }
        public static bool Initialize()
        {
            if (!inited)
            {
                inited = true;                 // do this only once, assemblies won't change
                AssemblyLoader.LoadedAssembly KISasm = null;

                foreach (var la in AssemblyLoader.loadedAssemblies)
                {
                    if (la.assembly.GetName().Name.Equals("KIS", StringComparison.InvariantCultureIgnoreCase))
                    {
                        KISasm = la;
                    }
                }
                if (KISasm != null)
                {
                    Debug.Log($"[KISWrapper] found KIS {KISasm}");
                    ModuleKISInventory.Initialize(KISasm.assembly);
                    KIS_Item.Initialize(KISasm.assembly);
                    haveKIS = true;
                }
            }
            return(haveKIS);
        }
示例#29
0
 public static void StartAddon(AssemblyLoader.LoadedAssembly assembly, Type addonType, KSPAddon addon, KSPAddon.Startup startup)
 {
     Method__StartAddon.Invoke(AddonLoader.Instance, new object[] { assembly, addonType, addon, startup });
 }
示例#30
0
        public void Start()
        {
            if (Util.IsDllLoaded || (Util.FindTrajectoriesAssembly(Util.BinName) != null))
            {
                print("[TrajectoriesBootstrap] WARNING: TRAJECTORIES HAS ALREADY LOADED BEFORE US!");
            }

            string load_bin     = Path.Combine(AssemblyDirectory(), "Trajectories.bin");
            string our_bin      = Path.Combine(AssemblyDirectory(), Util.BinName + ".bin");
            string possible_dll = Path.Combine(AssemblyDirectory(), "Trajectories.dll");

            if (File.Exists(our_bin))
            {
                print("[TrajectoriesBootstrap] Found Trajectories bin file at '" + our_bin + "'");
                if (File.Exists(possible_dll))
                {
                    try
                    {
                        File.Delete(possible_dll);
                        print("[TrajectoriesBootstrap] Deleted non-bin DLL at '" + possible_dll + "'");
                    }
                    catch
                    {
                        print("[TrajectoriesBootstrap] Could not delete non-bin DLL at '" + possible_dll + "'");
                    }
                }
            }
            else
            {
                print("[TrajectoriesBootstrap] ERROR: COULD NOT FIND TRAJECTORIES BIN FILE (" + Util.BinName + ".bin" + ")! Ditching!");
                return;
            }

            if (Util.IsDllLoaded)
            {
                print("[TrajectoriesBootstrap] Trajectories non-bin DLL already loaded! Ditching!");
                return;
            }

            //copy version specific Trajectoriesxx.bin file to Trajectories.bin and load it if successful
            try
            {
                File.Copy(our_bin, load_bin, true);
                print("[TrajectoriesBootstrap] Copied version specific Trajectories bin file to '" + load_bin + "'");
            }
            catch
            {
                print("[TrajectoriesBootstrap] Could not copy bin file '" + our_bin + "'");
            }

            if (!File.Exists(load_bin))
            {
                print("[TrajectoriesBootstrap] Trajectories.bin not found! Ditching!");
                return;
            }

            AssemblyLoader.LoadPlugin(new FileInfo(load_bin), load_bin, null);
            AssemblyLoader.LoadedAssembly loadedAssembly = Util.FindTrajectoriesAssembly();
            if (loadedAssembly == null)
            {
                print("[TrajectoriesBootstrap] Trajectories failed to load! Ditching!");
                return;
            }
            else
            {
                print("[TrajectoriesBootstrap] Trajectories loaded!");
            }

            loadedAssembly.Load();

            foreach (Type type in loadedAssembly.assembly.GetTypes())
            {
                foreach (Type loadedType in AssemblyLoader.loadedTypes)
                {
                    if (loadedType.IsAssignableFrom(type))
                    {
                        loadedAssembly.types.Add(loadedType, type);
                        PropertyInfo temp = typeof(AssemblyLoader.LoadedAssembly).GetProperty("typesDictionary");
                        if (temp != null)
                        {
                            Dictionary <Type, Dictionary <String, Type> > dict = (Dictionary <Type, Dictionary <String, Type> >)temp.GetValue(loadedAssembly, null);
                            Util.AddToLoadedTypesDict(ref dict, loadedType, type);
                        }
                    }
                }

                if (type.IsSubclassOf(typeof(MonoBehaviour)))
                {
                    KSPAddon addonAttribute = (KSPAddon)type.GetCustomAttributes(typeof(KSPAddon), true).FirstOrDefault();
                    if (addonAttribute != null && addonAttribute.startup == KSPAddon.Startup.Instantly)
                    {
                        AddonLoaderWrapper.StartAddon(loadedAssembly, type, addonAttribute, KSPAddon.Startup.Instantly);
                    }
                }
            }
        }