Beispiel #1
0
        /// <summary>
        /// Creates a new module in the temporary directory.
        /// Note that this module will not become permanent until a call to SaveModule() is made.
        /// </summary>
        /// <returns>True if successful, false if unsuccessful</returns>
        public bool CreateModule()
        {
            try
            {
                using (FileArchiveManager manager = new FileArchiveManager())
                {
                    TemporaryDirectoryPath = manager.CreateUniqueDirectory();
                }

                // Build a new database file and structure.
                using (DatabaseRepository repo = new DatabaseRepository())
                {
                    repo.CreateNewDatabase(TemporaryDirectoryPath, "WinterEngineDB", true);
                }

                EntityCreationScripts creationScripts = new EntityCreationScripts();
                creationScripts.Initialize();

                // Add the module details to the correct table.
                using (GameModuleRepository repo = new GameModuleRepository())
                {
                    GameObjectFactory factory = new GameObjectFactory();
                    GameModule module = factory.CreateObject(GameObjectTypeEnum.GameModule, ModuleName, ModuleTag, ModuleResref) as GameModule;

                    repo.Add(module);
                }

                LoadSystemContentPacks();

                return true;
            }
            catch(Exception ex)
            {
                throw new Exception("Error creating module.", ex);
            }
        }