diff --git a/ComponentBasic/BehaviorPerform.cpp b/ComponentBasic/BehaviorPerform.cpp index 2977f4e..6bf17e7 100644 --- a/ComponentBasic/BehaviorPerform.cpp +++ b/ComponentBasic/BehaviorPerform.cpp @@ -165,8 +165,8 @@ std::shared_ptr MapKernal::newDefault() const return nullptr; } -LogicalNode::LogicalNode(NodeKind t /*= NodeKind::ACTIONNODE*/) - :_node_type(t) { +LogicalNode::LogicalNode(NodeKind t, std::shared_ptr kernal) + :_node_type(t), _bind_kernal(kernal) { } void LogicalNode::_set_parent_node(std::weak_ptr pnode) @@ -220,7 +220,7 @@ std::weak_ptr LogicalNode::parent() const } BehaviorMapNode::BehaviorMapNode(std::shared_ptr core) - :LogicalNode(NodeKind::MAPNODE), _bind_kernal(core) { + :LogicalNode(NodeKind::MAPNODE, core), _bind_kernal(core) { } std::shared_ptr BehaviorMapNode::getKernal() const @@ -312,8 +312,9 @@ QHash> BehaviorMapNode::outputList() const return list; } -SequenceNode::SequenceNode() - : LogicalNode(NodeKind::SEQUENCENODE) { + +SequenceNode::SequenceNode(std::shared_ptr kernal) + : LogicalNode(NodeKind::SEQUENCENODE, kernal) { } QList> SequenceNode::getForwards() const @@ -393,7 +394,7 @@ bool SequenceNode::fallback(std::shared_ptr node, LogicalResult ste std::shared_ptr SequenceNode::newDefault() const { - return std::make_shared(); + return std::make_shared(this->bindMap()->getKernal()); } void SequenceNode::reset() @@ -412,7 +413,7 @@ void LogicalNode::insert(std::shared_ptr node, int index /*= -1*/) if (it->getID() == node->getID()) return; - if(node->parent().lock()) + if (node->parent().lock()) node->parent().lock()->remove(node); _child_list.insert(index, node); @@ -424,8 +425,8 @@ void LogicalNode::remove(std::shared_ptr node) _child_list.removeAll(node); } -SelectorNode::SelectorNode() - : LogicalNode(NodeKind::SEQUENCENODE) { +SelectorNode::SelectorNode(std::shared_ptr kernal) +: LogicalNode(NodeKind::SEQUENCENODE, kernal) { } QList> SelectorNode::getForwards() const @@ -543,8 +544,8 @@ std::shared_ptr ParallelNode::newDefault() const return std::make_shared(); } -ParallelNode::ParallelNode() - : LogicalNode(NodeKind::PARALLELNODE) { +ParallelNode::ParallelNode(std::shared_ptr kernal) +: LogicalNode(NodeKind::PARALLELNODE, kernal) { } QHash> ParallelNode::inputList() const @@ -615,7 +616,7 @@ std::shared_ptr CompareNode::newDefault() const } CompareNode::CompareNode(std::shared_ptr ins) - : LogicalNode(NodeKind::COMPARENODE), _bind_kernal(ins) { + : LogicalNode(NodeKind::COMPARENODE, ins), _bind_kernal(ins) { _data_map[u8"左值"] = std::make_shared(); _data_map[u8"右值"] = std::make_shared(); } diff --git a/ComponentBasic/BehaviorPerform.h b/ComponentBasic/BehaviorPerform.h index d4bc4ca..7182ea7 100644 --- a/ComponentBasic/BehaviorPerform.h +++ b/ComponentBasic/BehaviorPerform.h @@ -323,6 +323,7 @@ enum class NodeKind { PARALLELNODE, // 并行节点 COMPARENODE, // 比较节点 ACTIONNODE, // 动作节点 + MODIFYNODE, // 修饰节点 }; class BehaviorMapNode; /// @@ -332,6 +333,7 @@ class COMPONENTBASIC_EXPORT LogicalNode : virtual public Serializable, public st private: int _node_id = 0; NodeKind _node_type = NodeKind::ACTIONNODE; + std::shared_ptr _bind_kernal; std::weak_ptr _parent_bind; QList> _child_list; @@ -343,7 +345,7 @@ private: void _set_parent_node(std::weak_ptr pnode); public: - LogicalNode(NodeKind t); + LogicalNode(NodeKind t, std::shared_ptr kernal); virtual ~LogicalNode() = default; /// @@ -556,7 +558,7 @@ private: QHash _state_map; public: - SequenceNode(); + SequenceNode(std::shared_ptr kernal); QList> getForwards() const override; QString typeName() const override; @@ -581,7 +583,7 @@ private: QHash _state_map; public: - SelectorNode(); + SelectorNode(std::shared_ptr kernal); QList> getForwards() const override; QString typeName() const override; @@ -606,7 +608,7 @@ private: QHash _state_map; public: - ParallelNode(); + ParallelNode(std::shared_ptr kernal); QList> getForwards() const override; QString typeName() const override; @@ -687,6 +689,30 @@ public: void saveTo(QJsonObject& obj) const override; }; +/// +/// 修饰节点类型 +/// +enum class ModifyType { + NONE, + ALWAYS_SUCCESS, // 永远成功 + ALWAYS_FAILURE, // 永远失败 + RESULT_INVENTER, // 结果翻转 +}; +class COMPONENTBASIC_EXPORT ModifiedNode : public LogicalNode { +private: + std::shared_ptr _bind_kernal; + ModifyType _type_appoint = ModifyType::NONE; + +public: + ModifiedNode(std::shared_ptr kernal) + : _bind_kernal(kernal){} + + ModifyType modifyType() const; + void resetModify(ModifyType t); + + +}; + // 行为节点 ==================================================================== ///