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 | const QVariantMap& arguments) { | 611 | const QVariantMap& arguments) { |
| 612 | QUuid actionID = QUuid::createUuid(); | 612 | QUuid actionID = QUuid::createUuid(); |
| 613 | auto actionFactory = DependencyManager::get<EntityActionFactoryInterface>(); | 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 | // create this action even if the entity doesn't have physics info. it will often be the | 616 | // create this action even if the entity doesn't have physics info. it will often be the |
| 616 | // case that a script adds an action immediately after an object is created, and the physicsInfo | 617 | // case that a script adds an action immediately after an object is created, and the physicsInfo |
| 617 | // is computed asynchronously. | 618 | // is computed asynchronously. |
| @@ -623,16 +624,16 @@ QUuid EntityScriptingInterface::addAction(const QString& actionTypeString, · 5 unmodified lines | |||
| 623 | return false; | 624 | return false; |
| 624 | } | 625 | } |
| 625 | EntityActionPointer action = actionFactory->factory(actionType, actionID, entity, arguments); | 626 | EntityActionPointer action = actionFactory->factory(actionType, actionID, entity, arguments); |
| 626 | if (action) { | 627 | if (!action) { |
| 627 | entity->addAction(simulation, action); | 628 | return false; |
| 628 | auto nodeList = DependencyManager::get<NodeList>(); | 629 | } |
| 629 | const QUuid myNodeID = nodeList->getSessionUUID(); | 630 | success = entity->addAction(simulation, action); |
| 630 | if (entity->getSimulatorID() != myNodeID) { | 631 | auto nodeList = DependencyManager::get<NodeList>(); |
| 631 | entity->flagForOwnership(); | 632 | const QUuid myNodeID = nodeList->getSessionUUID(); |
| 632 | } | 633 | if (entity->getSimulatorID() != myNodeID) { |
| 633 | return true; | 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 | if (success) { | 638 | if (success) { |
| 638 | return actionID; | 639 | return actionID; |
| @@ -656,9 +657,12 @@ bool EntityScriptingInterface::updateAction(const QUuid& entityID, const QUuid& · 17 unmodified lines | |||
| 656 | } | 657 | } |
| 657 | 658 | ||
| 658 | bool EntityScriptingInterface::deleteAction(const QUuid& entityID, const QUuid& actionID) { | 659 | bool EntityScriptingInterface::deleteAction(const QUuid& entityID, const QUuid& actionID) { |
| 659 | return actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) { | 660 | bool success = false; |
| 660 | return entity->removeAction(simulation, actionID); | 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 | QVector<QUuid> EntityScriptingInterface::getActionIDs(const QUuid& entityID) { | 668 | QVector<QUuid> EntityScriptingInterface::getActionIDs(const QUuid& entityID) { |