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); }
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); }
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); }