From 1761fc1b0d5a18e8d882811f2bce941fb0ce2557 Mon Sep 17 00:00:00 2001 From: hit9 Date: Wed, 24 Apr 2024 09:40:48 +0800 Subject: [PATCH] Update README --- README.md | 27 ++++++++++++++------------- README.zh.md | 29 +++++++++++++++-------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 9676bbb..77b55a3 100644 --- a/README.md +++ b/README.md @@ -104,10 +104,10 @@ Reference: - [RandomSelector](#random-selector) - [Priority](#priority) - [Stateful Composite nodes](#stateful) + - [Switch Case](#switchcase) - [Decorators](#decorators) - [If](#if) - [Invert](#invert) - - [Switch Case](#switchcase) - [Repeat](#repeat) - [Timeout](#timeout) - [Delay](#delay) @@ -381,6 +381,19 @@ Reference: The stateful data for stateful compositors are all stored in their `NodeBlob` structs. +* `Switch/Case` are just syntax sugar based on `Selector` and `If`: [↑] + + ```cpp + // Only one case will success, or all fail. + // Cases will be tested sequentially from top to bottom, one fails and then another. + + .Switch() + ._().Case() + ._()._().Action() + ._().Case() + ._()._().Action() + ``` + * **Decorators** [↑] * `If` executes its child node only if given condition turns `true`. [↑] @@ -402,18 +415,6 @@ Reference: // FAILURE => SUCCESS ``` - * `Switch/Case` are just syntax sugar based on `Selector` and `If`: [↑] - - ```cpp - // Only one case will success, or all fail. - // Cases will be tested sequentially from top to bottom, one fails and then another. - - .Switch() - ._().Case() - ._()._().Action() - ._().Case() - ._()._().Action() - ``` * `Repeat(n)` (alias `Loop`) repeats its child node' execution for exactly `n` times, it fails immediately if its child fails. [↑] diff --git a/README.zh.md b/README.zh.md index d926346..029ae6c 100644 --- a/README.zh.md +++ b/README.zh.md @@ -98,10 +98,10 @@ while(...) { - [随机选择节点 RandomSelector](#random-selector) - [优先级](#priority) - [有状态的组合节点](#stateful) + - [Switch Case](#switchcase) - [装饰器 Decorators](#decorators) - [If](#if) - [Invert 反转](#invert) - - [Switch Case](#switchcase) - [Repeat 重复](#repeat) - [Timeout 超时](#timeout) - [Delay 延时](#delay) @@ -371,6 +371,20 @@ while(...) { 有状态的组合节点的状态数据都存储在了 `NodeBlob` 中。 +* `Switch/Case` 是基于 `Selector` 和 `If` 的一种语法糖: [↑] + + ```cpp + // 只有一个 case 会成功,或者全部失败。 + // 每个 case 会从上到下的顺序被依次测试,一旦一个失败了,则开始测试下一个。 + + .Switch() + ._().Case() + ._()._().Action() + ._().Case() + ._()._().Action() + ``` + + * **Decorators** [↑] * `If` 只有在它的条件满足时执行其装饰的子节点: [↑] @@ -392,19 +406,6 @@ while(...) { // FAILURE => SUCCESS ``` - * `Switch/Case` 是基于 `Selector` 和 `If` 的一种语法糖: [↑] - - ```cpp - // 只有一个 case 会成功,或者全部失败。 - // 每个 case 会从上到下的顺序被依次测试,一旦一个失败了,则开始测试下一个。 - - .Switch() - ._().Case() - ._()._().Action() - ._().Case() - ._()._().Action() - ``` - * `Repeat(n)` (别名 `Loop`) 会重复执行被修饰的子节点正好 `n` 次, 如果子节点失败,它会立即失败。 [↑] 如果把节点从 开始 `RUNNING`、到 `SUCCESS` 或者 `FAILURE` 叫做一轮的话,`Repeat(n)` 的作用就是执行被修饰的子节点 `n` 轮。