Shutdown() public méthode

Shuts down the engine and unloads plugins.
public Shutdown ( ) : void
Résultat void
        protected bool Setup()
        {
            RepositoryClass.Instance.InitializeRepositoryPath();

            // get a reference to the engine singleton
            engine = new Root("", "trace.txt");

            // add event handlers for frame events
            engine.FrameStarted += new FrameEvent(OnFrameStarted);
            engine.FrameEnded += new FrameEvent(OnFrameEnded);

            // allow for setting up resource gathering
            if (!SetupResources())
                return false;

            //show the config dialog and collect options
            if (!ConfigureAxiom())
            {
                // shutting right back down
                engine.Shutdown();

                return false;
            }

            if (!CheckShaderCaps())
            {
                MessageBox.Show("Your graphics card does not support pixel shader 2.0 and vertex shader 2.0, which are required to run this tool.", "Graphics Card Not Supported", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                engine.Shutdown();
                return false;
            }

            ChooseSceneManager();
            CreateCamera();
            CreateViewports();

            // set default mipmap level
            TextureManager.Instance.DefaultNumMipMaps = 5;

            // call the overridden CreateScene method
            CreateScene();

            return true;
        }
        protected bool Setup()
        {
            if (repositoryDirectoryList.Count > 0)
                RepositoryClass.Instance.InitializeRepository(repositoryDirectoryList);
            else
                RepositoryClass.Instance.InitializeRepositoryPath();

            // get a reference to the engine singleton
            engine = new Root(null, null);
            // retrieve the max FPS, if it exists
            getMaxFPSFromRegistry();

            // add event handlers for frame events
            engine.FrameStarted += new FrameEvent(OnFrameStarted);
            engine.FrameEnded += new FrameEvent(OnFrameEnded);

            // make the collisionAPI object
            collisionManager = new CollisionAPI(false);

            // allow for setting up resource gathering
            if (!SetupResources())
                return false;

            //show the config dialog and collect options
            if (!ConfigureAxiom())
            {
                // shutting right back down
                engine.Shutdown();

                return false;
            }

            if (!CheckShaderCaps())
            {
                MessageBox.Show("Your graphics card does not support pixel shader 2.0 and vertex shader 2.0, which are required to run this tool.", "Graphics Card Not Supported", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                engine.Shutdown();
                return false;
            }

            ChooseSceneManager();
            CreateCamera();
            CreateViewports();

            // set default mipmap level
            TextureManager.Instance.DefaultNumMipMaps = 5;

            materialSchemeNames = MaterialManager.Instance.SchemeNames;
            if (materialSchemeNames.Count > 1)
                materialSchemeToolStripMenuItem.Enabled = true;

            // call the overridden CreateScene method
            CreateScene();

            InitializeAxiomControlCallbacks();

            return true;
        }
        /// <summary>
        ///		Overridden to switch to event based keyboard input.
        /// </summary>
        /// <returns></returns>
        protected bool Setup()
        {
            // get a reference to the engine singleton
            engine = new Root(null, null);

            engine.FixedFPS = fixedFPS;

            // If the user supplied the command-line arg, limit the
            // FPS.  In any case, limit the frame rate to 100 fps,
            // since this prevents the render loop spinning when
            // rendering isn't happening
            if (maxFPS > 0)
                engine.MaxFramesPerSecond = maxFPS;
            else
                engine.MaxFramesPerSecond = 100;

            // add event handlers for frame events
            engine.FrameStarted += new FrameEvent(OnFrameStarted);
            engine.FrameEnded += new FrameEvent(OnFrameEnded);

            // Set up our game specific logic
            // gameWorld = new BetaWorld(this);

            worldManager = new WorldManager();
            gameWorld.WorldManager = worldManager;

            //if (standalone) {
            //	networkHelper = new LoopbackNetworkHelper(worldManager);
            //} else
            networkHelper = new NetworkHelper(worldManager);
            if (standalone)
                this.LoopbackWorldServerEntry = networkHelper.GetWorldEntry("standalone");
            if (this.LoopbackWorldServerEntry != null)
            {
                string worldId = this.LoopbackWorldServerEntry.WorldName;
                // Bypass the login and connection to master server
                loginSettings.worldId = worldId;
                networkHelper.SetWorldEntry(worldId, this.LoopbackWorldServerEntry);
                networkHelper.MasterToken = this.LoopbackIdToken;
                networkHelper.OldToken = this.LoopbackOldToken;
            }
            else
            {
                // Show the login dialog.  If we successfully return from this
                // we have initialized the helper's world entry map with the
                // resolveresponse data.
                if (!ShowLoginDialog(networkHelper))
                    return false;
            }

            // Update our media tree (base this on the world to which we connect)
            WorldServerEntry entry = networkHelper.GetWorldEntry(loginSettings.worldId);
            // If they specify an alternate location for the media patcher,
            // use that.
            if (this.WorldPatcherUrl != null)
                entry.PatcherUrl = this.WorldPatcherUrl;
            if (this.WorldUpdateUrl != null)
                entry.UpdateUrl = this.WorldUpdateUrl;
            if (this.PatchMedia &&
                entry.PatcherUrl != null && entry.PatcherUrl != string.Empty &&
                entry.UpdateUrl != null && entry.UpdateUrl != string.Empty)
            {
                // Fetch the appropriate media (full scan)
                if (!UpdateWorldAssets(entry.WorldRepository, entry.PatcherUrl, entry.UpdateUrl, fullScan))
                    return false;
            }

            // exit the client after patching media if flag is set
            if (this.ExitAfterMediaPatch)
            {
                return false;
            }
            // If we aren't overriding the repository, and we could have
            // updated, use the world directory.  If we don't have an
            // update url for some reason, use the default repository.
            if (!useRepository && entry.UpdateUrl != null && entry.UpdateUrl != string.Empty)
                this.RepositoryPaths = entry.WorldRepositoryDirectories;

            // Tell the engine where to find media
            SetupResources(this.RepositoryPaths);

            // We need to load the Movie plugin here.
            PluginManager.Instance.LoadPlugins(".", "Multiverse.Movie.dll");

            // Set up the scripting system
            log.Debug("Client.Startup: Loading UiScripting");
            UiScripting.SetupInterpreter();
            UiScripting.LoadCallingAssembly();
            log.Debug("Client.Startup: Finished loading UiScripting");

            log.Debug("Client.Startup: Loading Assemblies");
            ArrayList assemblies = PluginManager.Instance.GetAssemblies();
            foreach (Assembly assembly in assemblies)
            {
                UiScripting.LoadAssembly(assembly);
            }
            log.Debug("Client.Startup: Finished loading Assemblies");

            // Run script that contains world-specific initializations
            // that must be performed before the display device is
            // created.  But for upward compatibility, if we can't
            // find the file, don't throw an error.
            UiScripting.RunFile("ClientInit.py");

            // Wait til now to set the networkHelper.UseTCP flag,
            // because the ClientInit.py may have overriden it.
            networkHelper.UseTCP = this.UseTCP;

            // Register our handlers.  We must do this before we call
            // MessageDispatcher.Instance.HandleMessageQueue, so that we will
            // get the callbacks for the incoming messages.
            SetupMessageHandlers();

            string initialLoadBitmap = "";
            if (File.Exists(MultiverseLoadScreen))
                initialLoadBitmap = MultiverseLoadScreen;

            // show the config dialog and collect options
            if (!Configurate())
            {
                log.Warn("Failed to configure system");
                // shutting right back down
                engine.Shutdown();
                throw new ClientException("Failed to configure system");
                // return false;
            }

            // setup the engine
            log.Debug("Client.Startup: Calling engine.Initialize()");
            window = engine.Initialize(true, "Multiverse World Browser", initialLoadBitmap);
            log.Debug("Client.Startup: Finished engine.Initialize()");
            try
            {
                System.Windows.Forms.Control control = window.GetCustomAttribute("HWND") as System.Windows.Forms.Control;
                System.Windows.Forms.Form f = control.FindForm();
                if (allowResize)
                {
                    if (!window.IsFullScreen)
                        f.MaximizeBox = true;
                    f.Resize += this.OnResize;
                    f.ResizeEnd += this.OnResizeEnd;
                }
                f.Closing += new System.ComponentModel.CancelEventHandler(this.OnClosing);
            }
            catch (Exception)
            {
                log.Warn("Unable to register closing event handler");
            }
            try
            {
                System.Windows.Forms.Control control = window.GetCustomAttribute("HWND") as System.Windows.Forms.Control;
                System.Windows.Forms.Form f = control.FindForm();
                System.Reflection.Assembly assembly = System.Reflection.Assembly.GetEntryAssembly();
                Stream iconStream = assembly.GetManifestResourceStream("MultiverseClient.MultiverseIcon.ico");
                control.FindForm().Icon = new System.Drawing.Icon(iconStream);
            }
            catch (Exception e)
            {
                LogUtil.ExceptionLog.Warn("Unable to load or apply MultiverseIcon.  Using default instead");
                LogUtil.ExceptionLog.InfoFormat("Exception Detail: {0}", e);
            }

            // Tell the MeterManager where it should write logs
            MeterManager.MeterEventsFile = MeterEventsFile;
            MeterManager.MeterLogFile = MeterLogFile;

            // This seems to need the window object to have been initialized
            TextureManager.Instance.DefaultNumMipMaps = 5;

            ChooseSceneManager();

            // Set up my timers so that I can see how much time is spent in
            // the various render queues.
            scene.QueueStarted += new RenderQueueEvent(scene_OnQueueStarted);
            scene.QueueEnded += new RenderQueueEvent(scene_OnQueueEnded);

            // XXXMLM - force a reference to the assembly for script reflection
            log.Debug("Client.Startup: Calling Multiverse.Web.Browser.RegisterForScripting()");
            Multiverse.Web.Browser.RegisterForScripting();
            log.Debug("Client.Startup: Finished Multiverse.Web.Browser.RegisterForScripting()");

            log.Debug("Client.Startup: Calling SetupGui()");
            SetupGui();

            // Tell Windows that the widget containing the DirectX
            // screen should now be visible.  This may not be the
            // right place to do this.
            window.PictureBoxVisible = true;

            // Set the scene manager
            worldManager.SceneManager = scene;

            // Set up a default ambient light for the scene manager
            scene.AmbientLight = ColorEx.Black;

            // Sets up the various things attached to the world manager,
            // as well as registering the various message handlers.
            // This also initializes the networkHelper.
            worldManager.Init(rootWindow, this);

            // At this point, I can have a camera
            CreateCamera();
            // #if !PERFHUD_BUILD
            inputHandler = new DefaultInputHandler(this);
            // inputHandler.InitViewpoint(worldManager.Player);
            // #endif
            CreateViewports();

            // call the overridden CreateScene method
            CreateScene();

            // Set up our game specific stuff (right now, just betaworld)
            gameWorld.Initialize();
            gameWorld.SetupMessageHandlers();

            needConnect = true;

            // retrieve and initialize the input system
            // input = PlatformManager.Instance.CreateInputReader();
            // input.Initialize(window, true, true, false, false);

            // Initialize the client API and load world specific scripts
            ClientAPI.InitAPI(gameWorld);

            Monitor.Enter(scene);

            log.InfoFormat("Client setup complete at {0}", DateTime.Now);
            // At this point, you can create timer events.
            return true;
        }
        protected bool Setup()
        {
            // get a reference to the engine singleton
            engine = new Root("", "trace.txt");
            // retrieve the max FPS, if it exists
            getMaxFPSFromRegistry();
            activeFps = Root.Instance.MaxFramesPerSecond;

            // add event handlers for frame events
            engine.FrameStarted += new FrameEvent(OnFrameStarted);
            engine.FrameEnded += new FrameEvent(OnFrameEnded);

            // allow for setting up resource gathering
            SetupResources();

            object ret = Registry.GetValue(Config.WorldEditorBaseRegistryKey, "Disable Video Playback", (object)false);
            if (ret == null || String.Equals(ret.ToString(), "False"))
            {
                ret = (object)false;
            }
            else
            {
                ret = (object)true;
            }
            disableVideoPlayback = (bool)ret;

            //show the config dialog and collect options
            if (!ConfigureAxiom())
            {
                // shutting right back down
                engine.Shutdown();

                return false;
            }

            if (!CheckShaderCaps())
            {
                MessageBox.Show("Your graphics card does not support pixel shader 2.0 and vertex shader 2.0, which are required to run this tool.", "Graphics Card Not Supported", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                engine.Shutdown();
                return false;
            }

            ChooseSceneManager();
            CreateCamera();
            CreateViewports();

            // set default mipmap level
            TextureManager.Instance.DefaultNumMipMaps = 5;

            // call the overridden CreateScene method
            CreateScene();

            // setup save timer
            saveTimer.Interval = (int)autoSaveTime;
            saveTimer.Tick += new EventHandler(saveTimerEvent);
            saveTimer.Start();

            InitializeAxiomControlCallbacks();

            return true;
        }
        protected bool Setup()
        {
            // get a reference to the engine singleton
            engine = new Root("EngineConfig.xml", null);

            // add event handlers for frame events
            engine.FrameStarted += new FrameEvent(OnFrameStarted);
            engine.FrameEnded += new FrameEvent(OnFrameEnded);

            // allow for setting up resource gathering
            SetupResources();

            //show the config dialog and collect options
            if (!ConfigureAxiom())
            {
                // shutting right back down
                engine.Shutdown();

                return false;
            }

            ChooseSceneManager();
            CreateCamera();
            CreateViewports();

            // set default mipmap level
            TextureManager.Instance.DefaultNumMipMaps = 5;

            // call the overridden CreateScene method
            CreateScene();

            return true;
        }
        protected virtual bool Setup()
        {
            // instantiate the Root singleton
            engine = new Root("EngineConfig.xml", "AxiomEngine.log");

            // add event handlers for frame events
            engine.FrameStarted += new FrameEvent(OnFrameStarted);
            engine.FrameEnded += new FrameEvent(OnFrameEnded);

            // allow for setting up resource gathering
            SetupResources();

            //show the config dialog and collect options
            if(!Configure()) {
                // shutting right back down
                engine.Shutdown();

                return false;
            }

            ChooseSceneManager();
            CreateCamera();
            CreateViewports();

            // set default mipmap level
            TextureManager.Instance.DefaultNumMipMaps = 5;

            // call the overridden CreateScene method
            CreateScene();

            // retreive and initialize the input system
            input = PlatformManager.Instance.CreateInputReader();
            input.Initialize(window, true, true, false, false, false);

            return true;
        }