diff --git a/SimsWorld/BehaviorEditor.cpp b/SimsWorld/BehaviorEditor.cpp index a723d0a..e2bde4a 100644 --- a/SimsWorld/BehaviorEditor.cpp +++ b/SimsWorld/BehaviorEditor.cpp @@ -50,18 +50,15 @@ AcceptType NodePresent::testAccept(const QPointF& local_pos, const QString& kind QList no_child{ NodeKind::ACTIONNODE, NodeKind::COMPARENODE }; auto pnode = this->_node_bind->parent().lock(); - decltype(pnode) new_type = nullptr; - if (this->_node_bind->bindMap()) - new_type = this->_node_bind->bindMap()->getKernal()->getNode(kind_str); - else - new_type = std::dynamic_pointer_cast(this->_node_bind)->getKernal()->getNode(kind_str); + decltype(pnode) new_type = this->_node_bind->getKernal()->getNode(kind_str); // 当前节点存在父节点且不属于Action和Compare if (left_rect.contains(local_pos) && pnode && !no_child.contains(new_type->nodeKind())) return AcceptType::PREV_LEVEL; + QList single_child{ NodeKind::MAPNODE, NodeKind::MODIFYNODE }; // 当前节点存在父节点且父节点可以存在多个节点 - if (pnode && pnode->nodeKind() != NodeKind::MAPNODE) { + if (pnode && !single_child.contains(pnode->nodeKind())) { if (top_rect.contains(local_pos)) return AcceptType::PREV_SIBLING; @@ -72,10 +69,14 @@ AcceptType NodePresent::testAccept(const QPointF& local_pos, const QString& kind // 分辨当前节点的是否可以插入新节点 if (right_rect.contains(local_pos)) switch (this->_node_bind->nodeKind()) { - case NodeKind::MAPNODE: // 根节点只能容纳一个节点 + case NodeKind::MAPNODE: // 根节点只能容纳一个子节点 if (!this->_node_bind->children().size() && !this->_node_bind->parent().lock()) return AcceptType::NEXT_LEVEL; break; + case NodeKind::MODIFYNODE: // 修饰节点只能容纳一个子节点 + if (!this->_node_bind->children().size()) + return AcceptType::NEXT_LEVEL; + break; case NodeKind::PARALLELNODE: case NodeKind::SELECTORNODE: case NodeKind::SEQUENCENODE: @@ -252,6 +253,7 @@ NodePresent* BehaviorsPresent::presentAllocate(std::shared_ptr ins) QList _children_set; switch (ins->nodeKind()) { case NodeKind::MAPNODE: + case NodeKind::MODIFYNODE: case NodeKind::PARALLELNODE: case NodeKind::SEQUENCENODE: case NodeKind::SELECTORNODE: @@ -340,6 +342,7 @@ QSizeF BehaviorsPresent::outlineMeasure(std::shared_ptr ins, QHash< switch (ins->nodeKind()) { case NodeKind::MAPNODE: + case NodeKind::MODIFYNODE: case NodeKind::PARALLELNODE: case NodeKind::SELECTORNODE: case NodeKind::SEQUENCENODE: