// initialize the plugin void vHavok_cl::OnInitEnginePlugin() { Vision::Callbacks.OnEngineInit.RegisterCallback(&cbInit); Vision::Callbacks.OnEngineDeInit.RegisterCallback(&cbInit); IVScriptManager::OnRegisterScriptFunctions.RegisterCallback(&cbInit); IVScriptManager::OnScriptProxyCreation.RegisterCallback(&cbInit); Vision::RegisterModule(&g_vHavokModule); // register the Havok module with the vision engine action manager VActionManager *pManager = Vision::GetActionManager(); pManager->RegisterModule(&g_vHavokModule); FORCE_LINKDYNCLASS(vHavokRigidBody); FORCE_LINKDYNCLASS(vHavokRagdoll); FORCE_LINKDYNCLASS(vHavokCharacterController); FORCE_LINKDYNCLASS(vHavokBallAndSocketConstraint); FORCE_LINKDYNCLASS(vHavokHingeConstraint); FORCE_LINKDYNCLASS(vHavokRagdollConstraint); FORCE_LINKDYNCLASS(vHavokPrismaticConstraint); FORCE_LINKDYNCLASS(vHavokStiffSpringConstraint); FORCE_LINKDYNCLASS(vHavokGenericConstraint); FORCE_LINKDYNCLASS(vHavokPointToPathConstraint); FORCE_LINKDYNCLASS(vHavokPointToPlaneConstraint); FORCE_LINKDYNCLASS(vHavokPulleyConstraint); FORCE_LINKDYNCLASS(VThrowItemComponent); FORCE_LINKDYNCLASS(VLineFollowerComponent); FORCE_LINKDYNCLASS(VFpsCameraEntity); EnsureHavokScriptRegistration(); return; }
// Called before the plugin is unloaded void ProjectEchoWinEnginePlugin::OnDeInitEnginePlugin() { hkvLog::Info("ProjectEchoWinEnginePlugin:OnDeInitEnginePlugin()"); // Close our component managers here.... MyComponent_ComponentManager::GlobalManager().OneTimeDeInit(); MyGameManager::GlobalManager().OneTimeDeInit(); // [...] // de-register component from action manager VActionManager * pManager = Vision::GetActionManager (); pManager->UnregisterModule( &g_myComponentModule ); // de-register our module when the plugin is de-initialized Vision::UnregisterModule(&g_myComponentModule); }
//============================================================================================================ // Initialize our plugin. //============================================================================================================ // Called when the plugin is loaded // We add our component initialize data here void myPlugin_cl::OnInitEnginePlugin() { Vision::Error.SystemMessage("MyPlugin:OnInitEnginePlugin()"); Vision::RegisterModule(&g_myComponentModule); //In some cases the compiler optimizes away the full class from the plugin since it seems to be dead code. //One workaround to prevent this is to add the following helper macro into the plugin initialization code: FORCE_LINKDYNCLASS( MyComponent ); // [...] //Start our component managers and game manager here.... MyGameManager::GlobalManager().OneTimeInit(); MyComponent_ComponentManager::GlobalManager().OneTimeInit(); // [...] //--------------------------------------------------------------------------------------------------------- // register the action module with the vision engine action manager // only after that will the action become available in the console. //--------------------------------------------------------------------------------------------------------- VActionManager * pManager = Vision::GetActionManager (); pManager->RegisterModule ( &g_myComponentModule ); // Set to true to open the console at startup and print some data to the display Vision::GetConsoleManager()->Show( false ); pManager->Print( "Welcome to the console!" ); pManager->Print( "This module is called '%s'", g_myComponentModule.GetName() ); pManager->Print( "Type in 'help' for a list of all actions" ); pManager->Print( "Type in 'myAction' to test this projects demo action" ); }
// de-initialize the plugin void vHavok_cl::OnDeInitEnginePlugin() { // Unregister the physics module before the plugin is unloaded. // Necessary since the engine will otherwise reference garbage memory. IVisAppPtr spApp = Vision::GetApplication(); if (spApp->GetPhysicsModule() != NULL && spApp->GetPhysicsModule()->GetType() == IVisPhysicsModule_cl::HAVOK) { spApp->SetPhysicsModule(NULL); } Vision::Callbacks.OnEngineInit.DeregisterCallback(&cbInit); Vision::Callbacks.OnEngineDeInit.DeregisterCallback(&cbInit); IVScriptManager::OnRegisterScriptFunctions.DeregisterCallback(&cbInit); IVScriptManager::OnScriptProxyCreation.DeregisterCallback(&cbInit); // Unregister the Havok module with the vision engine action manager VActionManager *pManager = Vision::GetActionManager(); pManager->UnregisterModule(&g_vHavokModule); Vision::UnregisterModule(&g_vHavokModule); }
//============================================================================================================ // Initialize our plugin. //============================================================================================================ // Called when the plugin is loaded // We add our component initialize data here void ProjectEchoWinEnginePlugin::OnInitEnginePlugin() { hkvLog::Info("ProjectEchoWinEnginePlugin:OnInitEnginePlugin()"); Vision::RegisterModule(&g_myComponentModule); // load plugins if supported #if defined( HAVOK_PHYSICS_2012_KEYCODE ) VISION_PLUGIN_ENSURE_LOADED(vHavok); #endif #if defined( HAVOK_AI_KEYCODE ) VISION_PLUGIN_ENSURE_LOADED(vHavokAi); #endif #if defined( HAVOK_BEHAVIOR_KEYCODE ) VISION_PLUGIN_ENSURE_LOADED(vHavokBehavior); #endif VISION_PLUGIN_ENSURE_LOADED(vFmodEnginePlugin); // In some cases the compiler optimizes away the full class from the plugin since it seems to be dead code. // One workaround to prevent this is to add the following helper macro into the plugin initialization code: FORCE_LINKDYNCLASS( MyComponent ); // [...] // Start our component managers and game manager here.... MyGameManager::GlobalManager().OneTimeInit(); MyComponent_ComponentManager::GlobalManager().OneTimeInit(); // [...] //--------------------------------------------------------------------------------------------------------- // register the action module with the vision engine action manager // only after that will the action become available in the console. //--------------------------------------------------------------------------------------------------------- VActionManager * pManager = Vision::GetActionManager (); pManager->RegisterModule ( &g_myComponentModule ); // Set to true to open the console at startup and print some data to the display Vision::GetConsoleManager()->Show( false ); pManager->Print( "Welcome to the console!" ); pManager->Print( "This module is called '%s'", g_myComponentModule.GetName() ); pManager->Print( "Type in 'help' for a list of all actions" ); pManager->Print( "Type in 'myAction' to test this projects demo action" ); }