Skip to content

Commit ad7eb4f

Browse files
authored
Merge pull request #25 from ashblue/develop
Cut release
2 parents f0512f7 + 0e330d7 commit ad7eb4f

17 files changed

+280
-105
lines changed

.all-contributorsrc

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
"imageSize": 100,
66
"commit": false,
77
"contributors": [
8+
{
9+
"login": "ashblue",
10+
"name": "Ash Blue",
11+
"avatar_url": "https://avatars2.githubusercontent.com/u/643307?v=4",
12+
"profile": "http://blueashes.com",
13+
"contributions": [
14+
"code"
15+
]
16+
},
817
{
918
"login": "JesseTG",
1019
"name": "Jesse Talavera-Greenberg",
@@ -15,18 +24,37 @@
1524
]
1625
},
1726
{
18-
"login": "ashblue",
19-
"name": "Ash Blue",
20-
"avatar_url": "https://avatars2.githubusercontent.com/u/643307?v=4",
21-
"profile": "http://blueashes.com",
27+
"login": "PureSaltProductions",
28+
"name": "PureSaltProductions",
29+
"avatar_url": "https://avatars1.githubusercontent.com/u/52610924?v=4",
30+
"profile": "https://github.com/PureSaltProductions",
2231
"contributions": [
23-
"code"
32+
"userTesting"
33+
]
34+
},
35+
{
36+
"login": "mduvergey",
37+
"name": "Martin Duvergey",
38+
"avatar_url": "https://avatars2.githubusercontent.com/u/18513379?v=4",
39+
"profile": "https://github.com/mduvergey",
40+
"contributions": [
41+
"bug"
42+
]
43+
},
44+
{
45+
"login": "call-stack",
46+
"name": "call-stack",
47+
"avatar_url": "https://avatars1.githubusercontent.com/u/38575304?v=4",
48+
"profile": "https://github.com/call-stack",
49+
"contributions": [
50+
"bug"
2451
]
2552
}
2653
],
2754
"contributorsPerLine": 7,
2855
"projectName": "fluid-behavior-tree",
2956
"projectOwner": "ashblue",
3057
"repoType": "github",
31-
"repoHost": "https://github.com"
58+
"repoHost": "https://github.com",
59+
"skipCi": true
3260
}

Assets/FluidBehaviorTree/Runtime/Decorators/RepeatForever.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using CleverCrow.Fluid.BTs.Trees;
2-
using CleverCrow.Fluid.BTs.Decorators;
31
using CleverCrow.Fluid.BTs.Tasks;
42

53
namespace CleverCrow.Fluid.BTs.Decorators {
@@ -11,4 +9,4 @@ protected override TaskStatus OnUpdate () {
119
return TaskStatus.Continue;
1210
}
1311
}
14-
}
12+
}
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using CleverCrow.Fluid.BTs.Trees;
2-
using CleverCrow.Fluid.BTs.Decorators;
31
using CleverCrow.Fluid.BTs.Tasks;
42

53
namespace CleverCrow.Fluid.BTs.Decorators {
@@ -10,8 +8,8 @@ protected override TaskStatus OnUpdate () {
108
if (Child.Update() == TaskStatus.Failure) {
119
return TaskStatus.Failure;
1210
}
13-
11+
1412
return TaskStatus.Continue;
1513
}
1614
}
17-
}
15+
}

Assets/FluidBehaviorTree/Runtime/TaskParents/TaskParentBase.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public override TaskStatus Update () {
2525

2626
var status = OnUpdate();
2727
LastStatus = status;
28+
if (status != TaskStatus.Continue) {
29+
Reset();
30+
}
2831

2932
return status;
3033
}
@@ -33,7 +36,7 @@ private void UpdateTicks () {
3336
if (ParentTree == null) {
3437
return;
3538
}
36-
39+
3740
if (_lastTickCount != ParentTree.TickCount) {
3841
Reset();
3942
}
@@ -56,12 +59,12 @@ public virtual ITaskParent AddChild (ITask child) {
5659
if (!child.Enabled) {
5760
return this;
5861
}
59-
62+
6063
if (Children.Count < MaxChildren || MaxChildren < 0) {
6164
Children.Add(child);
6265
}
6366

6467
return this;
6568
}
6669
}
67-
}
70+
}

Assets/FluidBehaviorTree/Runtime/Tasks/TaskBase.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public override TaskStatus Update () {
2626
Init();
2727
_init = true;
2828
}
29-
29+
3030
if (!_start) {
3131
Start();
3232
_start = true;
@@ -51,7 +51,7 @@ private void UpdateTicks () {
5151
if (ParentTree == null) {
5252
return;
5353
}
54-
54+
5555
if (_lastTickCount != ParentTree.TickCount) {
5656
Reset();
5757
}
@@ -85,7 +85,7 @@ private void Init () {
8585
/// </summary>
8686
protected virtual void OnInit () {
8787
}
88-
88+
8989
private void Start () {
9090
OnStart();
9191
}
@@ -101,7 +101,7 @@ private void Exit () {
101101
OnExit();
102102
}
103103

104-
_exit = false;
104+
Reset();
105105
}
106106

107107
/// <summary>
@@ -110,4 +110,4 @@ private void Exit () {
110110
protected virtual void OnExit () {
111111
}
112112
}
113-
}
113+
}

Assets/FluidBehaviorTree/Tests/Editor/Decorators/RepeatForeverTest.cs

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,48 @@
55
namespace CleverCrow.Fluid.BTs.Testing {
66
public class RepeatForeverTest {
77
public class UpdateMethod {
8-
private RepeatForever repeater;
8+
private RepeatForever Setup (ITask child) {
9+
var repeat = new RepeatForever();
10+
repeat.AddChild(child);
911

10-
[SetUp]
11-
public void Setup_repeater () {
12-
repeater = new RepeatForever();
12+
return repeat;
1313
}
1414

15-
[Test]
16-
public void Returns_continue_on_child_failure () {
17-
repeater.AddChild(A.TaskStub().WithUpdateStatus(TaskStatus.Failure).Build());
15+
public class WhenChildReturnsFailure : UpdateMethod {
16+
[Test]
17+
public void It_should_return_continue () {
18+
var stub = A.TaskStub().WithUpdateStatus(TaskStatus.Failure).Build();
1819

19-
Assert.AreEqual(TaskStatus.Continue, repeater.Update());
20+
var repeater = Setup(stub);
21+
var status = repeater.Update();
22+
23+
Assert.AreEqual(TaskStatus.Continue, status);
24+
}
2025
}
2126

22-
[Test]
23-
public void Returns_continue_on_child_success () {
24-
repeater.AddChild(A.TaskStub().WithUpdateStatus(TaskStatus.Success).Build());
27+
public class WhenChildReturnsSuccess : UpdateMethod {
28+
[Test]
29+
public void It_should_return_continue () {
30+
var stub = A.TaskStub().WithUpdateStatus(TaskStatus.Success).Build();
31+
32+
var repeater = Setup(stub);
33+
var status = repeater.Update();
2534

26-
Assert.AreEqual(TaskStatus.Continue, repeater.Update());
35+
Assert.AreEqual(TaskStatus.Continue, status);
36+
}
2737
}
2838

29-
[Test]
30-
public void Returns_continue_on_child_continue () {
31-
repeater.AddChild(A.TaskStub().WithUpdateStatus(TaskStatus.Continue).Build());
39+
public class WhenChildReturnsContinue : UpdateMethod {
40+
[Test]
41+
public void It_should_return_continue () {
42+
var stub = A.TaskStub().WithUpdateStatus(TaskStatus.Continue).Build();
43+
44+
var repeater = Setup(stub);
45+
var status = repeater.Update();
3246

33-
Assert.AreEqual(TaskStatus.Continue, repeater.Update());
47+
Assert.AreEqual(TaskStatus.Continue, status);
48+
}
3449
}
3550
}
3651
}
37-
}
52+
}

Assets/FluidBehaviorTree/Tests/Editor/Fluid.BehaviorTree.EditorTests.asmdef

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,17 @@
22
"name": "Fluid.BehaviorTree.EditorTests",
33
"references": [
44
"Fluid.BehaviorTree",
5-
"Fluid.BehaviorTree.Editor",
6-
"UnityEngine.TestRunner",
7-
"UnityEditor.TestRunner"
5+
"Fluid.BehaviorTree.Editor"
86
],
97
"includePlatforms": [
108
"Editor"
119
],
1210
"excludePlatforms": [],
13-
"allowUnsafeCode": false,
14-
"overrideReferences": true,
1511
"precompiledReferences": [
1612
"nunit.framework.dll",
1713
"NSubstitute.dll"
1814
],
19-
"autoReferenced": false,
20-
"defineConstraints": [
21-
"UNITY_INCLUDE_TESTS"
22-
],
23-
"versionDefines": [],
24-
"noEngineReferences": false
25-
}
15+
"optionalUnityReferences": [
16+
"TestAssemblies"
17+
]
18+
}

Assets/FluidBehaviorTree/Tests/Editor/Fluid.BehaviorTree.EditorTests.asmdef.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/FluidBehaviorTree/Tests/Editor/TaskParents/Composites/TaskSequenceTest.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using CleverCrow.Fluid.BTs.TaskParents.Composites;
22
using CleverCrow.Fluid.BTs.Tasks;
3-
using CleverCrow.Fluid.BTs.TaskParents;
43
using NSubstitute;
5-
using NSubstitute.ReturnsExtensions;
64
using NUnit.Framework;
75

86
namespace CleverCrow.Fluid.BTs.Testing {
@@ -37,14 +35,6 @@ public void It_should_run_update_on_all_success_child_tasks () {
3735
_sequence.Children.ForEach((c) => c.Received(1).Update());
3836
}
3937

40-
[Test]
41-
public void It_should_not_run_update_on_any_child_tasks_after_success () {
42-
_sequence.Update();
43-
_sequence.Update();
44-
45-
_sequence.Children.ForEach((c) => c.Received(1).Update());
46-
}
47-
4838
[Test]
4939
public void It_should_retick_a_continue_node_when_update_is_rerun () {
5040
_childB.Update().Returns(TaskStatus.Continue);

0 commit comments

Comments
 (0)