void EntityScriptServer::run() { DependencyManager::set<ScriptEngines>(ScriptEngine::ENTITY_SERVER_SCRIPT); DependencyManager::set<EntityScriptServerServices>(); // make sure we request our script once the agent connects to the domain auto nodeList = DependencyManager::get<NodeList>(); ThreadedAssignment::commonInit(ENTITY_SCRIPT_SERVER_LOGGING_NAME, NodeType::EntityScriptServer); // Setup MessagesClient auto messagesClient = DependencyManager::set<MessagesClient>(); messagesClient->startThread(); DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler(); connect(&domainHandler, &DomainHandler::settingsReceived, this, &EntityScriptServer::handleSettings); // make sure we hear about connected nodes so we can grab an ATP script if a request is pending connect(nodeList.data(), &LimitedNodeList::nodeActivated, this, &EntityScriptServer::nodeActivated); connect(nodeList.data(), &LimitedNodeList::nodeKilled, this, &EntityScriptServer::nodeKilled); nodeList->addSetOfNodeTypesToNodeInterestSet({ NodeType::Agent, NodeType::AudioMixer, NodeType::AvatarMixer, NodeType::EntityServer, NodeType::MessagesMixer, NodeType::AssetServer }); // Setup Script Engine resetEntitiesScriptEngine(); auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); entityScriptingInterface->init(); _entityViewer.init(); // setup the JSON filter that asks for entities with a non-default serverScripts property QJsonObject queryJSONParameters; queryJSONParameters[EntityJSONQueryProperties::SERVER_SCRIPTS_PROPERTY] = EntityQueryFilterSymbol::NonDefault; QJsonObject queryFlags; queryFlags[EntityJSONQueryProperties::INCLUDE_ANCESTORS_PROPERTY] = true; queryFlags[EntityJSONQueryProperties::INCLUDE_DESCENDANTS_PROPERTY] = true; queryJSONParameters[EntityJSONQueryProperties::FLAGS_PROPERTY] = queryFlags; // setup the JSON parameters so that OctreeQuery does not use a frustum and uses our JSON filter _entityViewer.getOctreeQuery().setJSONParameters(queryJSONParameters); entityScriptingInterface->setEntityTree(_entityViewer.getTree()); DependencyManager::set<AssignmentParentFinder>(_entityViewer.getTree()); auto tree = _entityViewer.getTree().get(); connect(tree, &EntityTree::deletingEntity, this, &EntityScriptServer::deletingEntity, Qt::QueuedConnection); connect(tree, &EntityTree::addingEntity, this, &EntityScriptServer::addingEntity, Qt::QueuedConnection); connect(tree, &EntityTree::entityServerScriptChanging, this, &EntityScriptServer::entityServerScriptChanging, Qt::QueuedConnection); }
void EntityScriptServer::clear() { // unload and stop the engine if (_entitiesScriptEngine) { // do this here (instead of in deleter) to avoid marshalling unload signals back to this thread _entitiesScriptEngine->unloadAllEntityScripts(); _entitiesScriptEngine->stop(); _entitiesScriptEngine->waitTillDoneRunning(); } _entityViewer.clear(); // reset the engine if (!_shuttingDown) { resetEntitiesScriptEngine(); } }
void EntityTreeRenderer::clear() { leaveAllEntities(); if (_entitiesScriptEngine) { // Unload and stop the engine here (instead of in its deleter) to // avoid marshalling unload signals back to this thread _entitiesScriptEngine->unloadAllEntityScripts(); _entitiesScriptEngine->stop(); } if (_wantScripts && !_shuttingDown) { resetEntitiesScriptEngine(); } auto scene = _viewState->getMain3DScene(); render::PendingChanges pendingChanges; foreach(auto entity, _entitiesInScene) { entity->removeFromScene(entity, scene, pendingChanges); }
void EntityTreeRenderer::clear() { leaveAllEntities(); // unload and stop the engine if (_entitiesScriptEngine) { // do this here (instead of in deleter) to avoid marshalling unload signals back to this thread _entitiesScriptEngine->unloadAllEntityScripts(); _entitiesScriptEngine->stop(); } // reset the engine if (_wantScripts && !_shuttingDown) { resetEntitiesScriptEngine(); } // remove all entities from the scene auto scene = _viewState->getMain3DScene(); if (scene) { render::PendingChanges pendingChanges; foreach(auto entity, _entitiesInScene) { entity->removeFromScene(entity, scene, pendingChanges); } scene->enqueuePendingChanges(pendingChanges); } else {