Skip to content

Commit

Permalink
Merge pull request ashblue#25 from ashblue/develop
Browse files Browse the repository at this point in the history
Cut release
  • Loading branch information
ashblue committed Jun 4, 2020
2 parents f0512f7 + 0e330d7 commit ad7eb4f
Show file tree
Hide file tree
Showing 17 changed files with 280 additions and 105 deletions.
40 changes: 34 additions & 6 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
"imageSize": 100,
"commit": false,
"contributors": [
{
"login": "ashblue",
"name": "Ash Blue",
"avatar_url": "https://avatars2.githubusercontent.com/u/643307?v=4",
"profile": "http://blueashes.com",
"contributions": [
"code"
]
},
{
"login": "JesseTG",
"name": "Jesse Talavera-Greenberg",
Expand All @@ -15,18 +24,37 @@
]
},
{
"login": "ashblue",
"name": "Ash Blue",
"avatar_url": "https://avatars2.githubusercontent.com/u/643307?v=4",
"profile": "http://blueashes.com",
"login": "PureSaltProductions",
"name": "PureSaltProductions",
"avatar_url": "https://avatars1.githubusercontent.com/u/52610924?v=4",
"profile": "https://github.com/PureSaltProductions",
"contributions": [
"code"
"userTesting"
]
},
{
"login": "mduvergey",
"name": "Martin Duvergey",
"avatar_url": "https://avatars2.githubusercontent.com/u/18513379?v=4",
"profile": "https://github.com/mduvergey",
"contributions": [
"bug"
]
},
{
"login": "call-stack",
"name": "call-stack",
"avatar_url": "https://avatars1.githubusercontent.com/u/38575304?v=4",
"profile": "https://github.com/call-stack",
"contributions": [
"bug"
]
}
],
"contributorsPerLine": 7,
"projectName": "fluid-behavior-tree",
"projectOwner": "ashblue",
"repoType": "github",
"repoHost": "https://github.com"
"repoHost": "https://github.com",
"skipCi": true
}
4 changes: 1 addition & 3 deletions Assets/FluidBehaviorTree/Runtime/Decorators/RepeatForever.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using CleverCrow.Fluid.BTs.Trees;
using CleverCrow.Fluid.BTs.Decorators;
using CleverCrow.Fluid.BTs.Tasks;

namespace CleverCrow.Fluid.BTs.Decorators {
Expand All @@ -11,4 +9,4 @@ protected override TaskStatus OnUpdate () {
return TaskStatus.Continue;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using CleverCrow.Fluid.BTs.Trees;
using CleverCrow.Fluid.BTs.Decorators;
using CleverCrow.Fluid.BTs.Tasks;

namespace CleverCrow.Fluid.BTs.Decorators {
Expand All @@ -10,8 +8,8 @@ protected override TaskStatus OnUpdate () {
if (Child.Update() == TaskStatus.Failure) {
return TaskStatus.Failure;
}

return TaskStatus.Continue;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public override TaskStatus Update () {

var status = OnUpdate();
LastStatus = status;
if (status != TaskStatus.Continue) {
Reset();
}

return status;
}
Expand All @@ -33,7 +36,7 @@ private void UpdateTicks () {
if (ParentTree == null) {
return;
}

if (_lastTickCount != ParentTree.TickCount) {
Reset();
}
Expand All @@ -56,12 +59,12 @@ public virtual ITaskParent AddChild (ITask child) {
if (!child.Enabled) {
return this;
}

if (Children.Count < MaxChildren || MaxChildren < 0) {
Children.Add(child);
}

return this;
}
}
}
}
10 changes: 5 additions & 5 deletions Assets/FluidBehaviorTree/Runtime/Tasks/TaskBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override TaskStatus Update () {
Init();
_init = true;
}

if (!_start) {
Start();
_start = true;
Expand All @@ -51,7 +51,7 @@ private void UpdateTicks () {
if (ParentTree == null) {
return;
}

if (_lastTickCount != ParentTree.TickCount) {
Reset();
}
Expand Down Expand Up @@ -85,7 +85,7 @@ private void Init () {
/// </summary>
protected virtual void OnInit () {
}

private void Start () {
OnStart();
}
Expand All @@ -101,7 +101,7 @@ private void Exit () {
OnExit();
}

_exit = false;
Reset();
}

/// <summary>
Expand All @@ -110,4 +110,4 @@ private void Exit () {
protected virtual void OnExit () {
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,48 @@
namespace CleverCrow.Fluid.BTs.Testing {
public class RepeatForeverTest {
public class UpdateMethod {
private RepeatForever repeater;
private RepeatForever Setup (ITask child) {
var repeat = new RepeatForever();
repeat.AddChild(child);

[SetUp]
public void Setup_repeater () {
repeater = new RepeatForever();
return repeat;
}

[Test]
public void Returns_continue_on_child_failure () {
repeater.AddChild(A.TaskStub().WithUpdateStatus(TaskStatus.Failure).Build());
public class WhenChildReturnsFailure : UpdateMethod {
[Test]
public void It_should_return_continue () {
var stub = A.TaskStub().WithUpdateStatus(TaskStatus.Failure).Build();

Assert.AreEqual(TaskStatus.Continue, repeater.Update());
var repeater = Setup(stub);
var status = repeater.Update();

Assert.AreEqual(TaskStatus.Continue, status);
}
}

[Test]
public void Returns_continue_on_child_success () {
repeater.AddChild(A.TaskStub().WithUpdateStatus(TaskStatus.Success).Build());
public class WhenChildReturnsSuccess : UpdateMethod {
[Test]
public void It_should_return_continue () {
var stub = A.TaskStub().WithUpdateStatus(TaskStatus.Success).Build();

var repeater = Setup(stub);
var status = repeater.Update();

Assert.AreEqual(TaskStatus.Continue, repeater.Update());
Assert.AreEqual(TaskStatus.Continue, status);
}
}

[Test]
public void Returns_continue_on_child_continue () {
repeater.AddChild(A.TaskStub().WithUpdateStatus(TaskStatus.Continue).Build());
public class WhenChildReturnsContinue : UpdateMethod {
[Test]
public void It_should_return_continue () {
var stub = A.TaskStub().WithUpdateStatus(TaskStatus.Continue).Build();

var repeater = Setup(stub);
var status = repeater.Update();

Assert.AreEqual(TaskStatus.Continue, repeater.Update());
Assert.AreEqual(TaskStatus.Continue, status);
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,17 @@
"name": "Fluid.BehaviorTree.EditorTests",
"references": [
"Fluid.BehaviorTree",
"Fluid.BehaviorTree.Editor",
"UnityEngine.TestRunner",
"UnityEditor.TestRunner"
"Fluid.BehaviorTree.Editor"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll",
"NSubstitute.dll"
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false
}
"optionalUnityReferences": [
"TestAssemblies"
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using CleverCrow.Fluid.BTs.TaskParents.Composites;
using CleverCrow.Fluid.BTs.Tasks;
using CleverCrow.Fluid.BTs.TaskParents;
using NSubstitute;
using NSubstitute.ReturnsExtensions;
using NUnit.Framework;

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

[Test]
public void It_should_not_run_update_on_any_child_tasks_after_success () {
_sequence.Update();
_sequence.Update();

_sequence.Children.ForEach((c) => c.Received(1).Update());
}

[Test]
public void It_should_retick_a_continue_node_when_update_is_rerun () {
_childB.Update().Returns(TaskStatus.Continue);
Expand Down
Loading

0 comments on commit ad7eb4f

Please sign in to comment.