File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Assets/FluidBehaviorTree/Scripts/Tasks/Actions Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 1
- using NUnit . Framework ;
1
+ using Adnc . FluidBT . Trees ;
2
+ using NUnit . Framework ;
2
3
3
4
namespace Adnc . FluidBT . Tasks . Actions . Testing {
4
5
public class WaitTest {
@@ -27,5 +28,15 @@ public void It_should_trigger_success_after_2_ticks () {
27
28
Assert . AreEqual ( TaskStatus . Continue , wait . Update ( ) ) ;
28
29
Assert . AreEqual ( TaskStatus . Success , wait . Update ( ) ) ;
29
30
}
31
+
32
+ [ Test ]
33
+ public void It_should_trigger_continue_after_tree_restarts ( ) {
34
+ var tree = new BehaviorTree ( null ) ;
35
+ tree . AddNode ( tree . Root , new Wait ( ) ) ;
36
+
37
+ Assert . AreEqual ( TaskStatus . Continue , tree . Tick ( ) ) ;
38
+ Assert . AreEqual ( TaskStatus . Success , tree . Tick ( ) ) ;
39
+ Assert . AreEqual ( TaskStatus . Continue , tree . Tick ( ) ) ;
40
+ }
30
41
}
31
42
}
Original file line number Diff line number Diff line change @@ -3,7 +3,11 @@ public class Wait : ActionBase {
3
3
public int turns = 1 ;
4
4
5
5
private int _ticks ;
6
-
6
+
7
+ protected override void OnStart ( ) {
8
+ _ticks = 0 ;
9
+ }
10
+
7
11
protected override TaskStatus OnUpdate ( ) {
8
12
if ( _ticks < turns ) {
9
13
_ticks ++ ;
You can’t perform that action at this time.
0 commit comments