Skip to content

Commit

Permalink
add dispose methods to behavior tree library and cloner
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsx-dev committed Jan 2, 2017
1 parent c74fa4e commit fa4e2ea
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gdx-ai/src/com/badlogic/gdx/ai/btree/TaskCloner.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ public interface TaskCloner {
* @return the cloned task */
public <T> Task<T> cloneTask (Task<T> task);

/**
* Free task previously created by this {@link TaskCloner}
* @param task task to free
*/
public <T> void freeTask(Task<T> task);

}
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,16 @@ public void registerArchetypeTree (String treeReference, BehaviorTree<?> archety
public boolean hasArchetypeTree (String treeReference) {
return repository.containsKey(treeReference);
}

/**
* Dispose behavior tree obtain by this library.
* @param treeReference the tree identifier.
* @param behaviorTree the tree to dispose.
*/
public void disposeBehaviorTree(String treeReference, BehaviorTree<?> behaviorTree){
if(Task.TASK_CLONER != null){
Task.TASK_CLONER.freeTask(behaviorTree);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,14 @@ public <T> BehaviorTree<T> createBehaviorTree (String treeReference) {
public <T> BehaviorTree<T> createBehaviorTree (String treeReference, T blackboard) {
return library.createBehaviorTree(treeReference, blackboard);
}

/**
* Dispose behavior tree obtain by this library manager.
* @param treeReference the tree identifier.
* @param behaviorTree the tree to dispose.
*/
public void disposeBehaviorTree(String treeReference, BehaviorTree<?> behaviorTree){
library.disposeBehaviorTree(treeReference, behaviorTree);
}

}

0 comments on commit fa4e2ea

Please sign in to comment.