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 ;
23
34namespace Adnc . FluidBT . Tasks . Actions . Testing {
45 public class WaitTest {
@@ -27,5 +28,15 @@ public void It_should_trigger_success_after_2_ticks () {
2728 Assert . AreEqual ( TaskStatus . Continue , wait . Update ( ) ) ;
2829 Assert . AreEqual ( TaskStatus . Success , wait . Update ( ) ) ;
2930 }
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+ }
3041 }
3142}
Original file line number Diff line number Diff line change @@ -3,7 +3,11 @@ public class Wait : ActionBase {
33 public int turns = 1 ;
44
55 private int _ticks ;
6-
6+
7+ protected override void OnStart ( ) {
8+ _ticks = 0 ;
9+ }
10+
711 protected override TaskStatus OnUpdate ( ) {
812 if ( _ticks < turns ) {
913 _ticks ++ ;
You can’t perform that action at this time.
0 commit comments