From 3667afc5a1a5e88664254333a82ac8433f006689 Mon Sep 17 00:00:00 2001 From: Calamari Date: Tue, 2 Jan 2018 10:21:37 +0100 Subject: [PATCH] Add Upgrading notes for upgrading to v2 --- UPGRADE_TO_V2.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 UPGRADE_TO_V2.md diff --git a/UPGRADE_TO_V2.md b/UPGRADE_TO_V2.md new file mode 100644 index 0000000..42f79e3 --- /dev/null +++ b/UPGRADE_TO_V2.md @@ -0,0 +1,20 @@ +# Upgrade Guide to v2.0 from v1.0 + +The most notable change is, the way how to import the behavior tree components. The components are not static parts of the BehaviorTree class anymore. And since we are using proper ES5 notation, the BehaviorTree is now the `default` export of the component. This should look like this now: + +```js +import BehaviorTree, { Selector, Task, SUCCESS } from 'behaviortree' +``` + +Additionally, to avoid the awkwardness of previous internal code, Tasks will now need to return a single value at the end, instead of calling one of the `this.running`, `this.success` or `this.fail` methods. Those methods do not exist anymore. Please return the provided constants to notify if the task was a success or failure or if it is still running and need to be called again. + +```js +import { Task, SUCCESS } from 'behaviortree' +const task = new Task({ + run () { + return SUCCESS + } +}) +``` + +The Priority Selector is now called simply `Selector` according to more common terminology.