/// <summary> /// Adds a type of <see cref="State"/> with a sub-state machine in it and its transition to the entry state /// </summary> /// <param name="stateName">The name of the state</param> /// <param name="subBehaviourEngine">The sub behaviour engine inside the state. It will enter in the entry state of the sub behaviour engine</param> public State CreateSubStateMachine(string stateName, BehaviourEngine subBehaviourEngine) { State stateTo = subBehaviourEngine.GetEntryState(); State state = new State(stateName, subBehaviourEngine.GetState("Entry_Machine"), stateTo, subBehaviourEngine, this); states.Add(state.Name, state); return(state); }
/// <summary> /// Adds a type of <see cref="LeafNode"/> with a sub-behaviour engine in it and its transition to the entry state /// </summary> /// <param name="stateName">The name of the state</param> /// <param name="subBehaviourTree">The sub-behaviour tree inside the </param> public LeafNode CreateSubBehaviour(string nodeName, BehaviourEngine subBehaviourEngine) { State stateTo = subBehaviourEngine.GetEntryState(); State state = new State(nodeName, subBehaviourEngine.GetState("Entry_Machine"), stateTo, subBehaviourEngine, this); LeafNode leafNode = new LeafNode("Node to return", state, this); subBehaviourEngine.NodeToReturn = leafNode; states.Add(leafNode.StateNode.Name, leafNode.StateNode); return(subBehaviourEngine.NodeToReturn); }
/// <summary> /// Adds a type of <see cref="UtilityAction"/> with a sub-behaviour engine in it and its transition to the entry state /// </summary> /// <param name="actionName">The name of the action</param> /// <param name="factor">The factor that gives the utility value to the action</param> /// <param name="subBehaviourEngine">The sub-behaviour tree inside the </param> public UtilityAction CreateSubBehaviour(string actionName, Factor factor, BehaviourEngine subBehaviourEngine) { if (!states.ContainsKey(actionName)) { State stateTo = subBehaviourEngine.GetEntryState(); State state = new State(actionName, subBehaviourEngine.GetState("Entry_Machine"), stateTo, subBehaviourEngine, this); UtilityAction utilAction = new UtilityAction(state, factor, this, subBehaviourEngine); states.Add(utilAction.utilityState.Name, utilAction.utilityState); actions.Add(utilAction); return(utilAction); } else { throw new DuplicateWaitObjectException(actionName, "The utility action already exists in the utility engine"); } }