File tree Expand file tree Collapse file tree 4 files changed +30
-4
lines changed
Editor/Testing/ParentTasks Expand file tree Collapse file tree 4 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,28 @@ protected override TaskStatus OnUpdate () {
2525 }
2626 }
2727
28+ public class EnabledProperty : TaskParentTest {
29+ [ Test ]
30+ public void Returns_disabled_if_no_children ( ) {
31+ Assert . IsFalse ( taskParent . Enabled ) ;
32+ }
33+
34+ [ Test ]
35+ public void Returns_enabled_if_child ( ) {
36+ taskParent . AddChild ( A . TaskStub ( ) . Build ( ) ) ;
37+
38+ Assert . IsTrue ( taskParent . Enabled ) ;
39+ }
40+
41+ [ Test ]
42+ public void Returns_disabled_if_child_and_set_to_disabled ( ) {
43+ taskParent . AddChild ( A . TaskStub ( ) . Build ( ) ) ;
44+ taskParent . Enabled = false ;
45+
46+ Assert . IsFalse ( taskParent . Enabled ) ;
47+ }
48+ }
49+
2850 public class ResetMethod : TaskParentTest {
2951 [ Test ]
3052 public void Runs_reset_on_the_child_task ( ) {
Original file line number Diff line number Diff line change @@ -390,12 +390,12 @@ public void Triggers_lower_priority_when_valid () {
390390
391391 var sequenceSub = new Sequence ( ) ;
392392 sequenceSub . AbortType = AbortType . LowerPriority ;
393- sequence . AddChild ( sequenceSub ) ;
394393
395394 var condition = A . TaskStub ( )
396395 . WithAbortConditionSelf ( true )
397396 . Build ( ) ;
398397 sequenceSub . AddChild ( condition ) ;
398+ sequence . AddChild ( sequenceSub ) ;
399399
400400 var action = A . TaskStub ( )
401401 . WithUpdateStatus ( TaskStatus . Continue )
Original file line number Diff line number Diff line change 1- using System . Collections . Generic ;
2- using Adnc . FluidBT . Tasks ;
1+ using Adnc . FluidBT . Tasks ;
32
43namespace Adnc . FluidBT . TaskParents {
54 public class Sequence : CompositeBase {
Original file line number Diff line number Diff line change 33
44namespace Adnc . FluidBT . TaskParents {
55 public abstract class TaskParentBase : ITaskParent {
6+ private bool _enabled = true ;
7+
68 public AbortType AbortType { get ; set ; } = AbortType . None ;
79
8- public bool Enabled { get ; set ; } = true ;
10+ public bool Enabled {
11+ get { return children . Count != 0 && _enabled ; }
12+ set { _enabled = value ; }
13+ }
914
1015 public List < ITask > children { get ; } = new List < ITask > ( ) ;
1116
You can’t perform that action at this time.
0 commit comments