Skip to content

Commit cc113a9

Browse files
committed
Added logic for creating conditions
1 parent 1729dc5 commit cc113a9

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# fluid-behavior-tree
22

3-
@TODO Make sure copy / paste examples work correctly (custom node tutorial, quick start snippet).
3+
@TODO Make sure copy / paste examples work correctly (custom node tutorial, splicing, quick start snippet).
44

55
A pure code behavior tree micro-framework built for Unity3D projects.
66
Granting developers the power to dictate their GUI presentation.
@@ -382,6 +382,51 @@ public class TreeBuilderCustom : BehaviorTreeBuilderBase<TreeBuilderCustom> {
382382

383383
### Custom Conditions
384384

385+
Custom condition example template.
386+
387+
```C#
388+
using UnityEngine;
389+
using Adnc.FluidBT.Tasks;
390+
391+
public class CustomCondition : ConditionBase {
392+
// Triggers only the first time this node is run (great for caching data)
393+
protected override void OnInit () {
394+
}
395+
396+
// Triggers every time this node starts running. Does not trigger if TaskStatus.Continue was last returned by this node
397+
protected override void OnStart () {
398+
}
399+
400+
// Triggers every time `Tick()` is called on the tree and this node is run
401+
protected override bool OnUpdate () {
402+
// Points to the GameObject of whoever owns the Behavior Tree
403+
Debug.Log(Owner.name);
404+
return true;
405+
}
406+
407+
// Triggers whenever this node exits after running
408+
protected override void OnExit () {
409+
}
410+
}
411+
```
412+
413+
Code required to modify your tree builder.
414+
415+
```C#
416+
using Adnc.FluidBT.Trees;
417+
418+
public class TreeBuilderCustom : BehaviorTreeBuilderBase<TreeBuilderCustom> {
419+
...
420+
public TreeBuilderCustom CustomCondition (string name) {
421+
_tree.AddNode(Pointer, new CustomCondition {
422+
Name = name
423+
});
424+
425+
return this;
426+
}
427+
}
428+
```
429+
385430
### Custom Composites
386431

387432
### Custom Decorators

0 commit comments

Comments
 (0)