File tree Expand file tree Collapse file tree 5 files changed +29
-6
lines changed
Assets/com.fluid.behavior-tree/Runtime/TaskParents Expand file tree Collapse file tree 5 files changed +29
-6
lines changed Original file line number Diff line number Diff line change 1- namespace CleverCrow . Fluid . BTs . TaskParents . Composites {
1+ namespace CleverCrow . Fluid . BTs . TaskParents . Composites {
22 public abstract class CompositeBase : TaskParentBase {
33 public int ChildIndex { get ; protected set ; }
44
@@ -13,5 +13,9 @@ public override void Reset () {
1313
1414 base . Reset ( ) ;
1515 }
16+
17+ protected void NotifyChildEnd ( int childEnding ) {
18+ Children [ childEnding ] . End ( ) ;
19+ }
1620 }
1721}
Original file line number Diff line number Diff line change 1- using CleverCrow . Fluid . BTs . Tasks ;
1+ using CleverCrow . Fluid . BTs . Tasks ;
22
33namespace CleverCrow . Fluid . BTs . TaskParents . Composites {
44 public class Selector : CompositeBase {
@@ -10,9 +10,13 @@ protected override TaskStatus OnUpdate () {
1010
1111 switch ( child . Update ( ) ) {
1212 case TaskStatus . Success :
13+ NotifyChildEnd ( ChildIndex ) ;
1314 return TaskStatus . Success ;
1415 case TaskStatus . Continue :
1516 return TaskStatus . Continue ;
17+ case TaskStatus . Failure :
18+ NotifyChildEnd ( ChildIndex ) ;
19+ break ;
1620 }
1721
1822 ChildIndex ++ ;
Original file line number Diff line number Diff line change @@ -21,9 +21,13 @@ protected override TaskStatus OnUpdate () {
2121
2222 switch ( child . Update ( ) ) {
2323 case TaskStatus . Success :
24+ NotifyChildEnd ( ChildIndex ) ;
2425 return TaskStatus . Success ;
2526 case TaskStatus . Continue :
2627 return TaskStatus . Continue ;
28+ case TaskStatus . Failure :
29+ NotifyChildEnd ( ChildIndex ) ;
30+ break ;
2731 }
2832
2933 ChildIndex ++ ;
Original file line number Diff line number Diff line change 1- using CleverCrow . Fluid . BTs . Tasks ;
1+ using CleverCrow . Fluid . BTs . Tasks ;
22
33namespace CleverCrow . Fluid . BTs . TaskParents . Composites {
44 public class Sequence : CompositeBase {
@@ -9,8 +9,17 @@ protected override TaskStatus OnUpdate () {
99 var child = Children [ ChildIndex ] ;
1010
1111 var status = child . Update ( ) ;
12- if ( status != TaskStatus . Success ) {
13- return status ;
12+ switch ( status ) {
13+ case TaskStatus . Success :
14+ NotifyChildEnd ( ChildIndex ) ;
15+ break ;
16+ case TaskStatus . Failure :
17+ NotifyChildEnd ( ChildIndex ) ;
18+ return status ;
19+ case TaskStatus . Continue :
20+ return status ;
21+ default :
22+ break ;
1423 }
1524
1625 ChildIndex ++ ;
Original file line number Diff line number Diff line change 1- using CleverCrow . Fluid . BTs . Tasks ;
1+ using CleverCrow . Fluid . BTs . Tasks ;
22
33namespace CleverCrow . Fluid . BTs . TaskParents {
44 public class TaskRoot : TaskParentBase {
@@ -16,6 +16,8 @@ protected override TaskStatus OnUpdate () {
1616 }
1717
1818 public override void End ( ) {
19+ var child = Children [ 0 ] ;
20+ child . End ( ) ;
1921 }
2022 }
2123}
You can’t perform that action at this time.
0 commit comments