Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 4 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 = true; | |
| 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. |
| @@ -620,17 +621,18 @@ QUuid EntityScriptingInterface::addAction(const QString& actionTypeString, · 2 unmodified lines | ||
| 620 | 621 | // } |
| 621 | 622 | EntityActionType actionType = EntityActionInterface::actionTypeFromString(actionTypeString); |
| 622 | 623 | if (actionType == ACTION_TYPE_NONE) { |
| 624 | + success = false; | |
| 623 | 625 | return false; |
| 624 | 626 | } |
| 625 | 627 | EntityActionPointer action = actionFactory->factory(actionType, actionID, entity, arguments); |
| 626 | 628 | if (action) { |
| 627 | − entity->addAction(simulation, action); | |
| 629 | + success = entity->addAction(simulation, action); | |
| 628 | 630 | auto nodeList = DependencyManager::get<NodeList>(); |
| 629 | 631 | const QUuid myNodeID = nodeList->getSessionUUID(); |
| 630 | 632 | if (entity->getSimulatorID() != myNodeID) { |
| 631 | 633 | entity->flagForOwnership(); |
| 632 | 634 | } |
| 633 | − return true; | |
| 635 | + return false; // Physics will cause a packet to be sent, so don't send from here. | |
| 634 | 636 | } |
| 635 | 637 | return false; |
| 636 | 638 | }); |
| @@ -656,9 +658,12 @@ bool EntityScriptingInterface::updateAction(const QUuid& entityID, const QUuid& · 19 unmodified lines | ||
| 656 | 658 | } |
| 657 | 659 | |
| 658 | 660 | bool EntityScriptingInterface::deleteAction(const QUuid& entityID, const QUuid& actionID) { |
| 659 | − return actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) { | |
| 660 | − return entity->removeAction(simulation, actionID); | |
| 661 | + bool success = false; | |
| 662 | + actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) { | |
| 663 | + success = entity->removeAction(simulation, actionID); | |
| 664 | + return false; // Physics will cause a packet to be sent, so don't send from here. | |
| 661 | 665 | }); |
| 666 | + return success; | |
| 662 | 667 | } |
| 663 | 668 | |
| 664 | 669 | QVector<QUuid> EntityScriptingInterface::getActionIDs(const QUuid& entityID) { |