give entity-script-server a simulation

This commit is contained in:
Andrew Meadows 2019-09-06 08:55:39 -07:00
parent 6e35c8b804
commit 0a8c640ab5
2 changed files with 12 additions and 2 deletions

View file

@ -301,10 +301,17 @@ void EntityScriptServer::run() {
entityScriptingInterface->setEntityTree(_entityViewer.getTree());
DependencyManager::set<AssignmentParentFinder>(_entityViewer.getTree());
auto treePtr = _entityViewer.getTree();
DependencyManager::set<AssignmentParentFinder>(treePtr);
if (!_entitySimulation) {
SimpleEntitySimulationPointer simpleSimulation { new SimpleEntitySimulation() };
simpleSimulation->setEntityTree(treePtr);
treePtr->setSimulation(simpleSimulation);
_entitySimulation = simpleSimulation;
}
auto tree = _entityViewer.getTree().get();
auto tree = treePtr.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);
@ -451,6 +458,7 @@ void EntityScriptServer::resetEntitiesScriptEngine() {
connect(newEngine.data(), &ScriptEngine::update, this, [this] {
_entityViewer.queryOctree();
_entityViewer.getTree()->preUpdate();
_entityViewer.getTree()->update();
});

View file

@ -21,6 +21,7 @@
#include <EntityEditPacketSender.h>
#include <plugins/CodecPlugin.h>
#include <ScriptEngine.h>
#include <SimpleEntitySimulation.h>
#include <ThreadedAssignment.h>
#include "../entities/EntityTreeHeadlessViewer.h"
@ -75,6 +76,7 @@ private:
static int _entitiesScriptEngineCount;
ScriptEnginePointer _entitiesScriptEngine;
SimpleEntitySimulationPointer _entitySimulation;
EntityEditPacketSender _entityEditSender;
EntityTreeHeadlessViewer _entityViewer;