diff --git a/README.md b/README.md index ff3d37a..c37be32 100644 --- a/README.md +++ b/README.md @@ -29,19 +29,19 @@ With **UnitaskFBT**, you can use async/await syntax to handle long-running actio ## Example of Usage ```csharp - await npcBoard.Sequencer(c, //Sequencer node - static async (b, c) => await b.FindTarget(), //Action node realized as a delegate Func> - static async (b, c) => await b.Selector(c, //Selector node - static async (b, c) => await b.If(c, //Conditional node - static b => b.TargetDistance < 1f, //Condition - static async (b, c) => await b.MeleeAttack()), - static async (b, c) => await b.If(c, + await npcBoard.Sequencer( //Sequencer node + static b => b.FindTarget(), //Action node realized as a delegate Func> + static b => b.Selector( //Selector node + static b => b.If( //Conditional node + static b => b.TargetDistance < 1f, //Condition + static b => b.MeleeAttack()), //Action + static b => b.If( static b => b.TargetDistance < 3f, - static async (b, c) => await b.RangeAttack()), //RangeAttack() is the only continuous function in this BT allowing be in the running state - static async (b, c) => await b.If(c, + static b => b.RangeAttack()), //The only continuous function here that can be "running" + static b => b.If( static b => b.TargetDistance < 8f, - static async (b, c) => await b.Move()), - static async (b, c) => await b.Idle())); + static b => b.Move()), + static b => b.Idle())); ``` Notes: @@ -50,8 +50,8 @@ Notes: - The construction static async (b, c) => await … in each line may look verbose, but it’s a small price to pay for the huge advantages of an asynchronous behavior tree. - If a node needs to continue execution in the next cycle, it does not return Running. Instead, it suspends itself (e.g., using await UniTask.Yield()). In the example above, this happens inside RangeAttack(). - Since there is no Running state, nodes simply return a boolean (bool) rather than a Status, which simplifies the logic. -- All nodes accept a CancellationToken for operation cancellation. - No closures are used; only static delegates are employed, which avoids additional memory allocations. +- If CancellationToken required it can be added to Blackboard object For a detailed comparison between UnitaskFBT and a classical FBT, see this repository [FbtExample](https://github.com/dmitrybaltin/FbtExample) diff --git a/Runtime/UnitaskFbtNodes.cs b/Runtime/MainNodes.cs similarity index 99% rename from Runtime/UnitaskFbtNodes.cs rename to Runtime/MainNodes.cs index 0edf00d..87be520 100644 --- a/Runtime/UnitaskFbtNodes.cs +++ b/Runtime/MainNodes.cs @@ -13,7 +13,7 @@ namespace Baltin.UFBT /// 3. Extremely fast, because here inside there are only the simplest conditions, loops and procedure calls /// /// Type of 'blackboard' that represents the controlled object. - public static class UnitaskFbtNodes + public static class MainNodes { /// /// Execute the given func delegate if the given condition is true diff --git a/Runtime/UnitaskFbtNodes.cs.meta b/Runtime/MainNodes.cs.meta similarity index 100% rename from Runtime/UnitaskFbtNodes.cs.meta rename to Runtime/MainNodes.cs.meta diff --git a/package.json b/package.json index f5798dd..9d3548d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.baltin.ufbt", - "version": "0.6.0", + "version": "0.6.1", "displayName": "UniTaskFBT", "description": "Async Functional Behavior Tree implementation based on UniTask", "unity": "2021.2",