Esempio n. 1
0
        private Node MakeDecoratorNode(DecoratorNodeType decorator, uint childNodeID, uint extra = 0)
        {
            Node newNode;

            if (!m_nodeDic.TryGetValue(childNodeID, out Node result))
            {
                return(null);   // failed to get childNodeID
            }
            switch (decorator)
            {
            case DecoratorNodeType.Inverter:
                newNode = new Inverter(result);
                break;

            case DecoratorNodeType.Repeater:
                newNode = new Repeater(result, extra);
                break;

            case DecoratorNodeType.RepeatTillFail:
                newNode = new RepeatTillFail(result);
                break;

            case DecoratorNodeType.Limiter:
                newNode = new Limiter(result);
                break;

            default:
                return(null);    // tried to create unknown decorator node
            }

            return(newNode);
        }
Esempio n. 2
0
        public uint CreateDecoratorNode(DecoratorNodeType decorator, uint childNodeID, uint extra = 0)
        {
            Node newNode = MakeDecoratorNode(decorator, childNodeID, extra);

            if (newNode == null)
            {
                return(0xfffffffe);  // failed to create new node
            }
            newNode.SetID(++m_nodeID);
            uint a = newNode.GetID();

            m_nodeDic.Add(a, newNode);
            return(a);
        }
Esempio n. 3
0
        private uint CreateDecoratorNodeWithID(DecoratorNodeType decorator, uint childNodeID, uint nodeID, uint extra = 0)
        {
            if (m_nodeDic.ContainsKey(nodeID))
            {
                return(0xffffffff);   // id already exists
            }
            Node newNode = MakeDecoratorNode(decorator, childNodeID, extra);

            if (newNode == null)
            {
                return(0xfffffffe);  // failed to create new node
            }
            newNode.SetID(nodeID);
            m_nodeDic.Add(nodeID, newNode);
            return(nodeID);
        }