diff --git a/CHANGES b/CHANGES index dfd920e3..a6dee715 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,6 @@ [1.8.3-SNAPSHOT] - Updated to libgdx 1.11.0 +- Start guarded task only if the guard succeeds [1.8.2] - Updated to libgdx 1.9.8 diff --git a/gdx-ai/src/com/badlogic/gdx/ai/btree/BehaviorTree.java b/gdx-ai/src/com/badlogic/gdx/ai/btree/BehaviorTree.java index aab24e7b..496d3f9e 100644 --- a/gdx-ai/src/com/badlogic/gdx/ai/btree/BehaviorTree.java +++ b/gdx-ai/src/com/badlogic/gdx/ai/btree/BehaviorTree.java @@ -119,11 +119,11 @@ public void step () { rootTask.run(); } else { rootTask.setControl(this); - rootTask.start(); - if (rootTask.checkGuard(this)) + if (rootTask.checkGuard(this)) { + rootTask.start(); rootTask.run(); - else - rootTask.fail(); + } else + childFail(null); // actually child has not failed but child guard has failed } } diff --git a/gdx-ai/src/com/badlogic/gdx/ai/btree/Decorator.java b/gdx-ai/src/com/badlogic/gdx/ai/btree/Decorator.java index f38b18c3..fcfb4ce1 100644 --- a/gdx-ai/src/com/badlogic/gdx/ai/btree/Decorator.java +++ b/gdx-ai/src/com/badlogic/gdx/ai/btree/Decorator.java @@ -66,11 +66,11 @@ public void run () { child.run(); } else { child.setControl(this); - child.start(); - if (child.checkGuard(this)) + if (child.checkGuard(this)) { + child.start(); child.run(); - else - child.fail(); + } else + childFail(null); // actually child has not failed but child guard has failed } } diff --git a/gdx-ai/src/com/badlogic/gdx/ai/btree/LoopDecorator.java b/gdx-ai/src/com/badlogic/gdx/ai/btree/LoopDecorator.java index 0e60a68e..f5fa7d92 100644 --- a/gdx-ai/src/com/badlogic/gdx/ai/btree/LoopDecorator.java +++ b/gdx-ai/src/com/badlogic/gdx/ai/btree/LoopDecorator.java @@ -51,11 +51,11 @@ public void run () { child.run(); } else { child.setControl(this); - child.start(); - if (child.checkGuard(this)) + if (child.checkGuard(this)) { + child.start(); child.run(); - else - child.fail(); + } else + childFail(null); // actually child has not failed but child guard has failed } } } diff --git a/gdx-ai/src/com/badlogic/gdx/ai/btree/SingleRunningChildBranch.java b/gdx-ai/src/com/badlogic/gdx/ai/btree/SingleRunningChildBranch.java index 0c4ce74b..30a75363 100644 --- a/gdx-ai/src/com/badlogic/gdx/ai/btree/SingleRunningChildBranch.java +++ b/gdx-ai/src/com/badlogic/gdx/ai/btree/SingleRunningChildBranch.java @@ -84,11 +84,12 @@ public void run () { runningChild = children.get(currentChildIndex); } runningChild.setControl(this); - runningChild.start(); if (!runningChild.checkGuard(this)) - runningChild.fail(); - else + childFail(null); // actually child has not failed but child guard has failed + else { + runningChild.start(); run(); + } } else { // Should never happen; this case must be handled by subclasses in childXXX methods } diff --git a/gdx-ai/src/com/badlogic/gdx/ai/btree/branch/Parallel.java b/gdx-ai/src/com/badlogic/gdx/ai/btree/branch/Parallel.java index 95a7f6ba..f030b29c 100644 --- a/gdx-ai/src/com/badlogic/gdx/ai/btree/branch/Parallel.java +++ b/gdx-ai/src/com/badlogic/gdx/ai/btree/branch/Parallel.java @@ -23,7 +23,7 @@ import com.badlogic.gdx.utils.Array; /** A {@code Parallel} is a special branch task that runs all children when stepped. - * Its actual behavior depends on its {@link orchestrator} and {@link policy}.
+ * Its actual behavior depends on its {@link #orchestrator} and {@link #policy}.
*
* The execution of the parallel task's children depends on its {@link #orchestrator}: *