Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 11 files). Show all
Unified · Split
| @@ -26,22 +26,32 @@ void EntityScriptingInterface::queueEntityMessage(PacketType packetType, · 25 unmodified lines | ||
| 26 | 26 | getEntityPacketSender()->queueEditEntityMessage(packetType, entityID, properties); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | + | |
| 30 | +bool EntityScriptingInterface::canEdit() { | |
| 31 | + auto nodeList = DependencyManager::get<NodeList>(); | |
| 32 | + return nodeList->getThisNodeCanEdit(); | |
| 33 | +} | |
| 34 | + | |
| 35 | + | |
| 29 | 36 | EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& properties) { |
| 30 | 37 | |
| 38 | + | |
| 31 | 39 | // The application will keep track of creatorTokenID |
| 32 | 40 | uint32_t creatorTokenID = EntityItemID::getNextCreatorTokenID(); |
| 33 | 41 | |
| 34 | 42 | EntityItemID id(NEW_ENTITY, creatorTokenID, false ); |
| 35 | 43 | |
| 36 | − // If we have a local entity tree set, then also update it. | |
| 37 | − if (_entityTree) { | |
| 38 | − _entityTree->lockForWrite(); | |
| 39 | − _entityTree->addEntity(id, properties); | |
| 40 | − _entityTree->unlock(); | |
| 41 | − } | |
| 44 | + if (canEdit()) { | |
| 45 | + // If we have a local entity tree set, then also update it. | |
| 46 | + if (_entityTree) { | |
| 47 | + _entityTree->lockForWrite(); | |
| 48 | + _entityTree->addEntity(id, properties); | |
| 49 | + _entityTree->unlock(); | |
| 50 | + } | |
| 42 | 51 | |
| 43 | − // queue the packet | |
| 44 | − queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties); | |
| 52 | + // queue the packet | |
| 53 | + queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties); | |
| 54 | + } | |
| 45 | 55 | |
| 46 | 56 | return id; |
| 47 | 57 | } |
| @@ -94,6 +104,11 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID · 46 unmodified lines | ||
| 94 | 104 | } |
| 95 | 105 | |
| 96 | 106 | EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const EntityItemProperties& properties) { |
| 107 | + | |
| 108 | + if (! canEdit()) { | |
| 109 | + return entityID; | |
| 110 | + } | |
| 111 | + | |
| 97 | 112 | EntityItemID actualID = entityID; |
| 98 | 113 | // if the entity is unknown, attempt to look it up |
| 99 | 114 | if (!entityID.isKnownID) { |