/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

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