Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 325 files). Show all
Unified · Split
| @@ -611,7 +611,8 @@ QUuid EntityScriptingInterface::addAction(const QString& actionTypeString, · 610 unmodified lines | ||
| 611 | 611 | const QVariantMap& arguments) { |
| 612 | 612 | QUuid actionID = QUuid::createUuid(); |
| 613 | 613 | auto actionFactory = DependencyManager::get<EntityActionFactoryInterface>(); |
| 614 | − bool success = actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) { | |
| 614 | + bool success = false; | |
| 615 | + actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) { | |
| 615 | 616 | // create this action even if the entity doesn't have physics info. it will often be the |
| 616 | 617 | // case that a script adds an action immediately after an object is created, and the physicsInfo |
| 617 | 618 | // is computed asynchronously. |
| @@ -623,16 +624,16 @@ QUuid EntityScriptingInterface::addAction(const QString& actionTypeString, · 5 unmodified lines | ||
| 623 | 624 | return false; |
| 624 | 625 | } |
| 625 | 626 | EntityActionPointer action = actionFactory->factory(actionType, actionID, entity, arguments); |
| 626 | − if (action) { | |
| 627 | − entity->addAction(simulation, action); | |
| 628 | − auto nodeList = DependencyManager::get<NodeList>(); | |
| 629 | − const QUuid myNodeID = nodeList->getSessionUUID(); | |
| 630 | − if (entity->getSimulatorID() != myNodeID) { | |
| 631 | − entity->flagForOwnership(); | |
| 632 | − } | |
| 633 | − return true; | |
| 627 | + if (!action) { | |
| 628 | + return false; | |
| 629 | + } | |
| 630 | + success = entity->addAction(simulation, action); | |
| 631 | + auto nodeList = DependencyManager::get<NodeList>(); | |
| 632 | + const QUuid myNodeID = nodeList->getSessionUUID(); | |
| 633 | + if (entity->getSimulatorID() != myNodeID) { | |
| 634 | + entity->flagForOwnership(); | |
| 634 | 635 | } |
| 635 | − return false; | |
| 636 | + return false; // Physics will cause a packet to be sent, so don't send from here. | |
| 636 | 637 | }); |
| 637 | 638 | if (success) { |
| 638 | 639 | return actionID; |
| @@ -656,9 +657,12 @@ bool EntityScriptingInterface::updateAction(const QUuid& entityID, const QUuid& · 17 unmodified lines | ||
| 656 | 657 | } |
| 657 | 658 | |
| 658 | 659 | bool EntityScriptingInterface::deleteAction(const QUuid& entityID, const QUuid& actionID) { |
| 659 | − return actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) { | |
| 660 | − return entity->removeAction(simulation, actionID); | |
| 660 | + bool success = false; | |
| 661 | + actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) { | |
| 662 | + success = entity->removeAction(simulation, actionID); | |
| 663 | + return false; // Physics will cause a packet to be sent, so don't send from here. | |
| 661 | 664 | }); |
| 665 | + return success; | |
| 662 | 666 | } |
| 663 | 667 | |
| 664 | 668 | QVector<QUuid> EntityScriptingInterface::getActionIDs(const QUuid& entityID) { |