Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
hit9 committed Apr 24, 2024
1 parent 5662b09 commit 1761fc1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ Reference: <span id="ref"></span>
- [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)
Expand Down Expand Up @@ -381,6 +381,19 @@ Reference: <span id="ref"></span>

The stateful data for stateful compositors are all stored in their `NodeBlob` structs.

* `Switch/Case` are just syntax sugar based on `Selector` and `If`: <span id="switchcase"></span> <a href="#ref">[]</a>

```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<ConditionX>()
._()._().Action<TaskX>()
._().Case<ConditionY>()
._()._().Action<TaskY>()
```

* **Decorators** <span id="decorators"></span> <a href="#ref">[]</a>

* `If` executes its child node only if given condition turns `true`. <span id="if"></span> <a href="#ref">[]</a>
Expand All @@ -402,18 +415,6 @@ Reference: <span id="ref"></span>
// FAILURE => SUCCESS
```
* `Switch/Case` are just syntax sugar based on `Selector` and `If`: <span id="switchcase"></span> <a href="#ref">[↑]</a>
```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<ConditionX>()
._()._().Action<TaskX>()
._().Case<ConditionY>()
._()._().Action<TaskY>()
```
* `Repeat(n)` (alias `Loop`) repeats its child node' execution for exactly `n` times, it fails immediately if its child fails. <span id="repeat"></span> <a href="#ref">[↑]</a>

Expand Down
29 changes: 15 additions & 14 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -371,6 +371,20 @@ while(...) {

有状态的组合节点的状态数据都存储在了 `NodeBlob` 中。

* `Switch/Case` 是基于 `Selector``If` 的一种语法糖: <span id="switchcase"></span> <a href="#a">[]</a>

```cpp
// 只有一个 case 会成功,或者全部失败。
// 每个 case 会从上到下的顺序被依次测试,一旦一个失败了,则开始测试下一个。

.Switch()
._().Case<ConditionX>()
._()._().Action<TaskX>()
._().Case<ConditionY>()
._()._().Action<TaskY>()
```


* **Decorators** <span id="decorators"></span> <a href="#a">[]</a>

* `If` 只有在它的条件满足时执行其装饰的子节点: <span id="if"></span> <a href="#a">[]</a>
Expand All @@ -392,19 +406,6 @@ while(...) {
// FAILURE => SUCCESS
```

* `Switch/Case` 是基于 `Selector` 和 `If` 的一种语法糖: <span id="switchcase"></span> <a href="#a">[↑]</a>

```cpp
// 只有一个 case 会成功,或者全部失败。
// 每个 case 会从上到下的顺序被依次测试,一旦一个失败了,则开始测试下一个。

.Switch()
._().Case<ConditionX>()
._()._().Action<TaskX>()
._().Case<ConditionY>()
._()._().Action<TaskY>()
```

* `Repeat(n)` (别名 `Loop`) 会重复执行被修饰的子节点正好 `n` 次, 如果子节点失败,它会立即失败。 <span id="repeat"></span> <a href="#a">[↑]</a>

如果把节点从 开始 `RUNNING`、到 `SUCCESS` 或者 `FAILURE` 叫做一轮的话,`Repeat(n)` 的作用就是执行被修饰的子节点 `n` 轮。
Expand Down

0 comments on commit 1761fc1

Please sign in to comment.