Exemplo n.º 1
0
        public bool ConflictWith(StateTransition trans)
        {
            ST_Condition cond1 = _st_cond;
            ST_Condition cond2 = trans._st_cond;
            // 两个condition都不是fullpass,那么没有冲突的可能
            bool atleast_1_fullpass = (cond1 == ST_Condition.FullPass || cond2 == ST_Condition.FullPass);

            List <StateNodeBase> from_list_1 = GetFromNodes();
            List <StateNodeBase> from_list_2 = trans.GetFromNodes();

            StateNodeBase to_1 = GetToNode();
            StateNodeBase to_2 = trans.GetToNode();

            int action_1 = _action;
            int action_2 = trans._action;

            // 两层循环判断冲突
            foreach (var from_i in from_list_1)
            {
                foreach (var from_j in from_list_2)
                {
                    if (from_i == from_j)
                    {
                        // action一样,并且两个condition中至少有一个fullpass
                        if (action_1 == action_2 && atleast_1_fullpass)
                        {
                            LogManager.Warning("transition conflict, from[{0}] and action[{1}] to node[{2},{3}] duplicate!", from_i, action_1, to_1, to_2);
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        //from + action是【因】
        //to 是【果】
        public ST_Single(StateNodeBase from_node, StateNodeBase to_node, int action, ST_Condition st_cond = null)
        {
            LogManager.Assert(from_node != null, "from node is null");
            LogManager.Assert(to_node != null, "to node is null");
            LogManager.Assert(action > 0, "action <= 0");

            LogManager.Assert(!string.Equals(from_node._name, to_node._name), string.Format("same type of node: [{0}]", from_node._name));

            _from_node = from_node;
            _to_node   = to_node;
            _action    = action;

            _st_cond = st_cond ?? ST_Condition.FullPass;
        }