/// <summary> /// Discovers all plugins /// </summary> private static void DiscoverAllPlugins() { if (AllPluginsVar == null) // Only do this search once per session { AllPluginsVar = new List <PluginInfo>(); // Engine plugins var EnginePluginsDirectory = Path.Combine(ProjectFileGenerator.EngineRelativePath, "Plugins"); Plugins.FindPluginsIn(EnginePluginsDirectory, PluginInfo.LoadedFromType.Engine, ref AllPluginsVar); // Game plugins foreach (var GameProjectFolder in RulesCompiler.AllGameFolders) { var GamePluginsDirectory = Path.Combine(GameProjectFolder, "Plugins"); Plugins.FindPluginsIn(GamePluginsDirectory, PluginInfo.LoadedFromType.GameProject, ref AllPluginsVar); } // Also keep track of which modules map to which plugins ModulesToPluginMapVar = new Dictionary <string, PluginInfo>(StringComparer.InvariantCultureIgnoreCase); foreach (var CurPluginInfo in AllPlugins) { foreach (var Module in CurPluginInfo.Modules) { // Make sure a different plugin doesn't already have a module with this name // @todo plugin: Collisions like this could happen because of third party plugins added to a project, which isn't really ideal. if (ModuleNameToPluginMap.ContainsKey(Module.Name)) { throw new BuildException("Found a plugin in '{0}' which describes a module '{1}', but a module with this name already exists in plugin '{2}'!", CurPluginInfo.Directory, Module.Name, ModuleNameToPluginMap[Module.Name].Directory); } ModulesToPluginMapVar.Add(Module.Name, CurPluginInfo); } } } }
/// <summary> /// Checks to see if this module is a plugin module, and if it is, returns the PluginInfo for that module, otherwise null. /// </summary> /// <param name="ModuleName">Name of the module to check</param> /// <returns>The PluginInfo for this module, if the module is a plugin module. Otherwise, returns null</returns> public static PluginInfo GetPluginInfoForModule(string ModuleName) { PluginInfo FoundPluginInfo; if (ModuleNameToPluginMap.TryGetValue(ModuleName, out FoundPluginInfo)) { return(FoundPluginInfo); } else { return(null); } }
/// <summary> /// Returns true if the specified module name is part of a plugin /// </summary> /// <param name="ModuleName">Name of the module to check</param> /// <returns>True if this is a plugin module</returns> public static bool IsPluginModule(string ModuleName) { return(ModuleNameToPluginMap.ContainsKey(ModuleName)); }