Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public VisualTask (ITask task, IGraphContainer parentContainer) {

AddBox(container);

if (task.Children != null) {
if (task.Children != null && task.Children.Count > 0) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice. Yeah I can see this was creating a graphical display bug

var childContainer = new GraphContainerHorizontal();
foreach (var child in task.Children) {
_children.Add(new VisualTask(child, childContainer));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using CleverCrow.Fluid.BTs.Decorators;
using CleverCrow.Fluid.BTs.TaskParents;
Expand Down Expand Up @@ -179,7 +179,9 @@ public BehaviorTreeBuilder AddNode (ITask node) {
}

public BehaviorTreeBuilder Splice (BehaviorTree tree) {
_tree.Splice(PointerCurrent, tree);
if (tree != null && tree.Root != null) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, I feel like this should technically fail if you're passing in an empty null tree as most people would probably want to fix the error in that case. Maybe throwing an intentional error here might be more appropriate? I might modify the PR to remove this but feel free to debate me on this one (seems like the best path forward to me). What specific edge case were you hitting with this?

_tree.Splice(PointerCurrent, tree);
}

return this;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace CleverCrow.Fluid.BTs.TaskParents.Composites {
namespace CleverCrow.Fluid.BTs.TaskParents.Composites {
public abstract class CompositeBase : TaskParentBase {
public int ChildIndex { get; protected set; }

Expand All @@ -13,5 +13,9 @@ public override void Reset () {

base.Reset();
}

protected void NotifyChildEnd(int childEnding) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the last child not getting an End call on it when the BT tree completes? If so I'll need to get a test in to verify this and that it fixes the created bug. And also do manual regression testing.

It looks like there is code in here to call End on tasks automatically instead of manually calling like this. So I'm wondering why this would be needed?

https://github.com/ashblue/fluid-behavior-tree/blob/develop/Assets/com.fluid.behavior-tree/Runtime/Tasks/TaskBase.cs

Curious what the logic here is to forcibly call end on all the composites. If it's just not being triggered at all that would make sense. But I'm pretty sure End is firing fine in my code base last I checked. Please share more on your specific use case.

Children[childEnding].End();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CleverCrow.Fluid.BTs.Tasks;
using CleverCrow.Fluid.BTs.Tasks;

namespace CleverCrow.Fluid.BTs.TaskParents.Composites {
public class Selector : CompositeBase {
Expand All @@ -10,9 +10,13 @@ protected override TaskStatus OnUpdate () {

switch (child.Update()) {
case TaskStatus.Success:
NotifyChildEnd(ChildIndex);
return TaskStatus.Success;
case TaskStatus.Continue:
return TaskStatus.Continue;
case TaskStatus.Failure:
NotifyChildEnd(ChildIndex);
break;
}

ChildIndex++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ protected override TaskStatus OnUpdate () {

switch (child.Update()) {
case TaskStatus.Success:
NotifyChildEnd(ChildIndex);
return TaskStatus.Success;
case TaskStatus.Continue:
return TaskStatus.Continue;
case TaskStatus.Failure:
NotifyChildEnd(ChildIndex);
break;
}

ChildIndex++;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CleverCrow.Fluid.BTs.Tasks;
using CleverCrow.Fluid.BTs.Tasks;

namespace CleverCrow.Fluid.BTs.TaskParents.Composites {
public class Sequence : CompositeBase {
Expand All @@ -9,8 +9,17 @@ protected override TaskStatus OnUpdate () {
var child = Children[ChildIndex];

var status = child.Update();
if (status != TaskStatus.Success) {
return status;
switch (status) {
case TaskStatus.Success:
NotifyChildEnd(ChildIndex);
break;
case TaskStatus.Failure:
NotifyChildEnd(ChildIndex);
return status;
case TaskStatus.Continue:
return status;
default:
break;
}

ChildIndex++;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CleverCrow.Fluid.BTs.Tasks;
using CleverCrow.Fluid.BTs.Tasks;

namespace CleverCrow.Fluid.BTs.TaskParents {
public class TaskRoot : TaskParentBase {
Expand All @@ -16,6 +16,8 @@ protected override TaskStatus OnUpdate () {
}

public override void End () {
var child = Children[0];
child.End();
}
}
}