PageRenderTime 24ms CodeModel.GetById 17ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Code/src/com/game/AI/LeafTask.java

https://bitbucket.org/DeveloperUX/behaviortree
Java | 58 lines | 24 code | 5 blank | 29 comment | 0 complexity | 3b8b7888ff99d5b4c68614d800335871 MD5 | raw file
 1package com.game.AI;
 2
 3/**
 4 * Leaf task (or node) in the behavior tree.
 5 *  
 6 * Specifies a TaskControler, by composition, 
 7 * to take care of all the control logic, 
 8 * without burdening the Task class with 
 9 * complications.
10 * 
11 * @author Ying
12 *
13 */
14public abstract class LeafTask extends Task 
15{
16	/**
17	 * Task controler to keep track of the Task state.
18	 */
19	protected TaskController control;
20
21	/**
22	 * Creates a new instance of the LeafTask class
23	 * @param blackboard Reference to the AI Blackboard data
24	 */
25	public LeafTask(Blackboard blackboard) 
26	{
27		super(blackboard);
28		CreateController();
29	}
30	
31	/**
32	 * Creates a new instance of the LeafTask class
33	 * @param blackboard Reference to the AI Blackboard data
34	 * @param name Name of the class for debugging
35	 */
36	public LeafTask(Blackboard blackboard, String name) 
37	{
38		super(blackboard, name);
39		CreateController();
40	}
41	
42	/**
43	 * Creates the controller for the class
44	 */
45	private void CreateController()
46	{
47		this.control = new TaskController(this);
48	}
49	
50	/**
51	 * Gets the controller reference.
52	 */
53	@Override
54	public TaskController GetControl()
55	{
56		return this.control;
57	}
58}