Skip to content

Commit d4196bf

Browse files
author
Thomas Jonell
committed
gave behavior action a basic constructor option
fixed a minor issue in ParallelSelector causing a potential permanent eval of running
1 parent ce429d1 commit d4196bf

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

BehaviorLibrary/Components/Actions/BehaviorAction.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class BehaviorAction : BehaviorComponent
1010

1111
private Func<BehaviorReturnCode> ba_Action;
1212

13+
public BehaviorAction() { }
1314

1415
public BehaviorAction(Func<BehaviorReturnCode> action)
1516
{

BehaviorLibrary/Components/Composites/ParallelSelector.cs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace BehaviorLibrary.Components.Composites
77
{
8-
class ParallelSelector : BehaviorComponent
8+
public class ParallelSelector : BehaviorComponent
99
{
1010

1111
protected BehaviorComponent[] p_Behaviors;
@@ -34,6 +34,33 @@ public ParallelSelector(params BehaviorComponent[] behaviors)
3434
/// <returns>the behaviors return code</returns>
3535
public override BehaviorReturnCode Behave()
3636
{
37+
38+
for (int i = 0; i < p_SelLength; i++)
39+
{
40+
try
41+
{
42+
switch (p_Behaviors[i].Behave())
43+
{
44+
case BehaviorReturnCode.Failure:
45+
continue;
46+
case BehaviorReturnCode.Success:
47+
ReturnCode = BehaviorReturnCode.Success;
48+
return ReturnCode;
49+
case BehaviorReturnCode.Running:
50+
ReturnCode = BehaviorReturnCode.Running;
51+
return ReturnCode;
52+
default:
53+
continue;
54+
}
55+
}
56+
catch (Exception)
57+
{
58+
continue;
59+
}
60+
}
61+
62+
63+
/*
3764
while (p_Selections < p_SelLength)
3865
{
3966
try
@@ -60,7 +87,7 @@ public override BehaviorReturnCode Behave()
6087
p_Selections++;
6188
continue;
6289
}
63-
}
90+
}*/
6491

6592
p_Selections = 0;
6693
ReturnCode = BehaviorReturnCode.Failure;

0 commit comments

Comments
 (0)