private void LoadResources() { CorePlugin corePlugin = new CorePlugin(); corePlugin.RegisterBlocks(BlockRegistry); corePlugin.RegisterItems(ItemRegistry); }
public async Task BeforeScenario() { var corePlugin = new CorePlugin(); PluginManager = new PluginManager(); await PluginManager.LoadCore(corePlugin); ApplicationViewModel = new ApplicationViewModel(PluginManager); this.CleanupFiles = new List <string>(); }
static void LoadInternalPlugins() { Games.CtfSetup ctf = new Games.CtfSetup(); ctf.Load(true); Plugin.all.Add(ctf); CorePlugin core = new CorePlugin(); core.Load(true); Plugin.all.Add(core); Plugin.core.Add(core); }
public void BeforeTest(TestDetails details) { Console.WriteLine("----- Beginning Duality environment setup -----"); // Set environment directory to Duality binary directory this.oldEnvDir = Environment.CurrentDirectory; string codeBaseURI = typeof(DualityApp).Assembly.CodeBase; string codeBasePath = codeBaseURI.StartsWith("file:") ? codeBaseURI.Remove(0, "file:".Length) : codeBaseURI; codeBasePath = codeBasePath.TrimStart('/'); Console.WriteLine("Testing Core Assembly: {0}", codeBasePath); Environment.CurrentDirectory = Path.GetDirectoryName(codeBasePath); // Add some Console logs manually for NUnit if (!Log.Core.Outputs.OfType <TextWriterLogOutput>().Any(o => o.Target == Console.Out)) { if (this.consoleLogOutput == null) { this.consoleLogOutput = new TextWriterLogOutput(Console.Out); } Log.AddGlobalOutput(this.consoleLogOutput); } // Initialize Duality DualityApp.Init( DualityApp.ExecutionEnvironment.Launcher, DualityApp.ExecutionContext.Game, new DefaultPluginLoader(), null); // Manually register pseudo-plugin for the Unit Testing Assembly this.unitTestPlugin = DualityApp.PluginManager.LoadPlugin( typeof(DualityTestsPlugin).Assembly, codeBasePath); // Create a dummy window, to get access to all the device contexts if (this.dummyWindow == null) { WindowOptions options = new WindowOptions { Width = 800, Height = 600 }; this.dummyWindow = DualityApp.OpenWindow(options); } // Load local testing memory TestHelper.LocalTestMemory = Serializer.TryReadObject <TestMemory>(TestHelper.LocalTestMemoryFilePath, typeof(XmlSerializer)); Console.WriteLine("----- Duality environment setup complete -----"); }
public void BeforeTest(TestDetails details) { Console.WriteLine("----- Beginning Duality environment setup -----"); // Set environment directory to Duality binary directory this.oldEnvDir = Environment.CurrentDirectory; string codeBaseURI = typeof(DualityApp).Assembly.CodeBase; string codeBasePath = codeBaseURI.StartsWith("file:") ? codeBaseURI.Remove(0, "file:".Length) : codeBaseURI; codeBasePath = codeBasePath.TrimStart('/'); Environment.CurrentDirectory = Path.GetDirectoryName(codeBasePath); // Add some Console logs manually for NUnit if (!Log.Game.Outputs.OfType <ConsoleLogOutput>().Any()) { if (this.consoleLogOutput == null) { this.consoleLogOutput = new ConsoleLogOutput(); } Log.Game.AddOutput(this.consoleLogOutput); Log.Core.AddOutput(this.consoleLogOutput); Log.Editor.AddOutput(this.consoleLogOutput); } // Initialize Duality DualityApp.Init(DualityApp.ExecutionEnvironment.Launcher, DualityApp.ExecutionContext.Game); // Manually register pseudo-plugin for the Unit Testing Assembly this.unitTestPlugin = DualityApp.LoadPlugin(typeof(DualityTestsPlugin).Assembly, codeBasePath); // Create a dummy window, to get access to all the device contexts if (this.dummyWindow == null) { this.dummyWindow = new GameWindow(800, 600); this.dummyWindow.Context.LoadAll(); this.dummyWindow.Visible = true; this.dummyWindow.Context.Update(this.dummyWindow.WindowInfo); this.dummyWindow.MakeCurrent(); this.dummyWindow.ProcessEvents(); DualityApp.TargetResolution = new Vector2(this.dummyWindow.Width, this.dummyWindow.Height); DualityApp.TargetMode = this.dummyWindow.Context.GraphicsMode; DualityApp.InitGraphics(); } // Load local testing memory TestHelper.LocalTestMemory = Formatter.TryReadObject <TestMemory>(TestHelper.LocalTestMemoryFilePath, FormattingMethod.Xml); Console.WriteLine("----- Duality environment setup complete -----"); }
private static void PerformRuntimeReload(WorkerInterface workInterface) { List <CorePlugin> initSchedule = new List <CorePlugin>(); Logs.Editor.Write("Reloading core plugins..."); Logs.Editor.PushIndent(); int count = workInterface.ReloadSchedule.Count; while (workInterface.ReloadSchedule.Count > 0) { string curPath = workInterface.ReloadSchedule[0]; Logs.Editor.Write("{0}...", curPath); Logs.Editor.PushIndent(); { CorePlugin plugin = workInterface.MainForm.Invoke((Func <string, CorePlugin>)DualityApp.PluginManager.ReloadPlugin, curPath) as CorePlugin; if (plugin != null) { initSchedule.Add(plugin); } workInterface.Progress += 0.10f / (float)count; } Logs.Editor.PopIndent(); Thread.Sleep(20); string xmlDocFile = curPath.Replace(".dll", ".xml"); if (File.Exists(xmlDocFile)) { workInterface.MainForm.Invoke((Action <string>)HelpSystem.LoadXmlCodeDoc, xmlDocFile); } workInterface.ReloadSchedule.RemoveAt(0); workInterface.ReloadDone.Add(curPath); workInterface.Progress += 0.05f / (float)count; } Logs.Editor.PopIndent(); Logs.Editor.Write("Initializing reloaded core plugins..."); Logs.Editor.PushIndent(); foreach (CorePlugin plugin in initSchedule) { Logs.Editor.Write("{0}...", plugin.AssemblyName); Logs.Editor.PushIndent(); workInterface.MainForm.Invoke((Action <CorePlugin>)DualityApp.PluginManager.InitPlugin, plugin); workInterface.Progress += 0.05f / (float)count; Logs.Editor.PopIndent(); } Logs.Editor.PopIndent(); }
private bool VerifyReloadSchedule() { for (int i = this.reloadSchedule.Count - 1; i >= 0; i--) { string fullPath = Path.GetFullPath(this.reloadSchedule[i]); CorePlugin plugin = DualityApp.PluginManager.LoadedPlugins.FirstOrDefault(p => Path.GetFullPath(p.FilePath) == fullPath); if (plugin == null) { continue; } int hash = DualityApp.PluginManager.AssemblyLoader.GetAssemblyHash(this.reloadSchedule[i]); if (plugin.FileHash == hash) { this.reloadSchedule.RemoveAt(i); } } return(this.reloadSchedule.Count > 0); }
public void BeforeTest(ITest details) { Console.WriteLine("----- Beginning Duality environment setup -----"); // Set environment directory to Duality binary directory this.oldEnvDir = Environment.CurrentDirectory; Console.WriteLine("Testing in working directory: {0}", TestContext.CurrentContext.TestDirectory); Environment.CurrentDirectory = TestContext.CurrentContext.TestDirectory; if (this.launcher == null) { this.launcher = new DualityLauncher(); } // Manually register pseudo-plugin for the Unit Testing Assembly this.unitTestPlugin = DualityApp.PluginManager.LoadPlugin( typeof(DualityTestsPlugin).Assembly, typeof(DualityTestsPlugin).Assembly.Location); Console.WriteLine("----- Duality environment setup complete -----"); }
public static void AnalyzeCorePlugin(CorePlugin plugin) { Logs.Editor.Write("Analyzing Core Plugin: {0}", plugin.AssemblyName); Logs.Editor.PushIndent(); // Query references to other Assemblies var asmRefQuery = from AssemblyName a in plugin.PluginAssembly.GetReferencedAssemblies() select a.GetShortAssemblyName(); string thisAsmName = typeof(CoheeEditorApp).Assembly.GetShortAssemblyName(); foreach (string asmName in asmRefQuery) { bool illegalRef = false; // Scan for illegally referenced Assemblies if (asmName == thisAsmName) { illegalRef = true; } else if (editorPluginManager.LoadedPlugins.Any(p => p.PluginAssembly.GetShortAssemblyName() == asmName)) { illegalRef = true; } // Warn about them if (illegalRef) { Logs.Editor.WriteWarning( "Found illegally referenced Assembly '{0}'. " + "CorePlugins should never reference or use DualityEditor or any of its EditorPlugins. Consider moving the critical code to an EditorPlugin.", asmName); } } // Try to retrieve all Types from the current Assembly Type[] exportedTypes; try { exportedTypes = plugin.PluginAssembly.GetExportedTypes(); } catch (Exception e) { Logs.Editor.WriteError( "Unable to analyze exported types because an error occured: {0}", LogFormat.Exception(e)); exportedTypes = null; } // Analyze exported types if (exportedTypes != null) { // Query Component types var cmpTypeQuery = from Type t in exportedTypes where typeof(Component).IsAssignableFrom(t) select t; foreach (var cmpType in cmpTypeQuery) { // Scan for public Fields FieldInfo[] fields = cmpType.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance); if (fields.Length > 0) { Logs.Editor.WriteWarning( "Found public fields in Component class '{0}': {1}. " + "The usage of public fields is strongly discouraged in Component classes. Consider using properties instead.", cmpType.GetTypeCSCodeName(true), fields.ToString(f => LogFormat.FieldInfo(f, false), ", ")); } } } Logs.Editor.PopIndent(); }