Skip to content

Commit

Permalink
update documents
Browse files Browse the repository at this point in the history
  • Loading branch information
Daylily-Zeleen committed Jan 31, 2023
1 parent dd4eae2 commit f1f3bc4
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 21 deletions.
Binary file modified DOCUMENT.assets/auto_mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed DOCUMENT.assets/hfsm_Inspector.png
Binary file not shown.
Binary file modified DOCUMENT.assets/transition.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 25 additions & 9 deletions Document_cn.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 分层有限状态机 - V 1.2
# 分层有限状态机 - V 1.3

​ 总所周知,状态机是一种很常见的设计模式,这里提供了一个强大易用、可视化编辑的分层有限状态机Godot插件。

Expand Down Expand Up @@ -484,10 +484,10 @@ public class PlaceHolder: HFSM.State
​ 当您在`HFSM`监视器中正确设置代理(详见[HFSM监视器属性](#-hfsm%E7%9A%84%E7%9B%91%E8%A7%86%E5%99%A8%E5%B1%9E%E6%80%A7hfsms-inspector-porperties))之后,会在所有属于该`HFSM`里的状态脚本中添加一系列代表代理节点的变量,示例如下:

```python
###agents list start# please not modify this line.
###agents list-start# please not modify this line.
const Player = preload("res://addons/hierarchical_finite_state_machine/demo/test_2d_platform_player/Player.gd")
var player : Player
###agents list end# please not modify this line.
###agents list-end# please not modify this line.
```

​ 当您内嵌了`FSM``State`有附加的状态脚本,本插件会自动为其内嵌`FSM`中附加了脚本的所有`State`添加一个代表该`State`的变量,且变量名为`fsm_xxx` , `xxx` 为该`State`的名称,其类型引用自该状态的脚本,示例如下:
Expand Down Expand Up @@ -552,35 +552,39 @@ public class PlaceHolder: HFSM.State

### · 自动转换(Auto Transition)

具有5种模式,通过监视器中Auto transit mode进行选择。
具有~~(5)~~**6**种模式,通过监视器中Auto transit mode进行选择。

![](DOCUMENT.assets/auto_mode.png)

1. 延时定时器(Delay timer):
1. 动画结束(Animation Finish)(**v 1.3 新特性**):
​ 当起始状态的动画播放结束时,该转换的条件为真。
**注意:如果进入起始状态时无可播放的动画,该转换的条件将立刻置为真。**

2. 延时定时器(Delay timer):

![](DOCUMENT.assets/delay_timer.png)

​ 该模式下,通过配置延时时间(Delay time),当`FSM`进入该`Transition`的起始`State`时,该`Transition`会根据您设置的延时时间开始倒计时,当倒计时结束后,该转换的条件为真。

2. 内嵌状态机退出(Nested Fsm Exit):
3. 内嵌状态机退出(Nested Fsm Exit):

![](DOCUMENT.assets/nested_exit.png)

​ 只有当该转换的起始状态是内嵌了`FSM``State`时,该`Transition`的转换条件才有可能为真。当起始`State`的内嵌`FSM`运行到`Exit State`并执行完退出行为后,该转换条件为真。

3. 手动退出(Manual Exit):
4. 手动退出(Manual Exit):

![](DOCUMENT.assets/manual_exit.png)

​ 该模式下,当该转换的起始状态脚本中在正常的状态行为中通过代码调用了`manual_exit()`时,该`Transition`的转换条件为真。

4. 更新次数(Update times):
5. 更新次数(Update times):

![](DOCUMENT.assets/update_times.png)

​ 该模式下,当`FSM`进入到该`Transition`的起始`State`时,会开始计数更新的次数(即`update()`执行的次数),当达到您设定的次数时,该`Transition`的转换条件为真。

5. 物理更新次数(Physics Update times):
6. 物理更新次数(Physics Update times):

![](DOCUMENT.assets/physics_update_time.png)

Expand Down Expand Up @@ -1341,6 +1345,12 @@ public class TemplateTransion :Reference
> (v1.2 新特性 完整版特有)
> 是否反向播放动画。
8. bool animation_playing[default: false]
> (v1.3 新特性)
> 指示该状态是否正在播放动画。
> **注意:只有当该状态在HFSM的运行路径中,该属性值的含义才是可靠的。**
### · 方法(Methods)
​ 对于可重载方法,其行为详见[状态行为及其代码控制](#·状态行为及其代码控制(StateBehavior&CodeControl)).
Expand Down Expand Up @@ -1411,6 +1421,12 @@ public class TemplateTransion :Reference
> (v1.2 新特性 完整版特有)
> 是否反向播放动画。
8. bool AnimationPlaying[default: false]
> (v1.3 新特性)
> 指示该状态是否正在播放动画。
> **注意:只有当该状态在HFSM的运行路径中,该属性值的含义才是可靠的。**
### · 方法(Methods)
​ 对于可重载方法,其行为详见[状态行为及其代码控制](#·状态行为及其代码控制(StateBehavior&CodeControl)).
Expand Down
38 changes: 27 additions & 11 deletions Document_en.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Hierarchical Finite State Machine - V 1.2
# Hierarchical Finite State Machine - V 1.3

​ As we all know, state machine is a very common design pattern. Here provide a powerful and easy-to-use Godot plugin for Hierarchical Finite State Machine with visual editing.

Expand All @@ -10,7 +10,7 @@
4. Two development modes: signal callback and attached state script
5. Develop base GDscript, compatible with Godot basic version and mono version
5. **Allows `C#`script to attached as state script( New).**
5. **Suppoets `GDscript` and `C#` script to implement the logic of transition( New, full version only). **
5. **Suppoets `GDscript` and `C#` script to implement the logic of transition( New, full version only).**


Expand Down Expand Up @@ -476,10 +476,10 @@ public class PlaceHolder: HFSM.State
​ After you set the agents correctly in the HFSM inspector(read [HFSM's Inspector Porperties](### · HFSM's Inspector Porperties) for more), a series of variables representing the agent nodes will be added to all the State scripts belonging to the HFSM. The example is as follows:

```python
###agents list start# please not modify this line.
###agents list-start# please not modify this line.
const Player = preload("res://addons/hierarchical_finite_state_machine/demo/test_2d_platform_player/Player.gd")
var player : Player
###agents list end# please not modify this line.
###agents list-end# please not modify this line.
```

​ When a state with nested FSM has a state script, the plugin will automatically add a variable representing this State for all States in nested FSM and the variable name is "fsm_xxx", "xxx" is the name of the State, and its type is referenced from the script of the state. The example is as follows:
Expand Down Expand Up @@ -546,39 +546,43 @@ public class PlaceHolder: HFSM.State

### Auto Transition

​ There are 5 modes, which can be selected by "Auto transit mode" in the inspector.
​ There are ~~(5)~~ **6** modes, which can be selected by "Auto transit mode" in the inspector.

![](DOCUMENT.assets/auto_mode.png)

1. Animation Finish( **v 1.3 New Feature**):
​ When from State's animation finished, the condition of the Transition is true.
**Note: if the from State has not appropriate animation to play when it is entered, the condition of the Transition is true, too.**

1. Delay timer:

![](DOCUMENT.assets/delay_timer.png)

​ In this mode, by configuring the delay time, when FSM enters the start State of the Transition, the Transition will start countdown according to the delay time you set. When the countdown ends, the condition of the Transition is true.
​ In this mode, by configuring the delay time, when FSM enters the from State of the Transition, the Transition will start countdown according to the delay time you set. When the countdown ends, the condition of the Transition is true.

2. Nested Fsm Exit :

![](DOCUMENT.assets/nested_exit.png)

​ Only when the start State of the Transition contain a nested FSM, the condition of the Transition can be true. When the nested FSM of the start State runs to its Exit State and exit behavior is finished, the condition of the Transition is true.
​ Only when the from State of the Transition contain a nested FSM, the condition of the Transition can be true. When the nested FSM of the from State runs to its Exit State and exit behavior is finished, the condition of the Transition is true.

3. Manual Exit :

![](DOCUMENT.assets/manual_exit.png)

​ In this mode, when the start State of this Transition execute `manual_exit()` in normal State behavior, the condition of the Transition is true.
​ In this mode, when the from State of this Transition execute `manual_exit()` in normal State behavior, the condition of the Transition is true.

4. Update times :

![](DOCUMENT.assets/update_times.png)

​ In this mode, when FSM enters the start State of the Transition, it will start to count the number of updates (that is, the number of times `update()` is executed). When the number of times you set is reached, the condition of the Transition is true.
​ In this mode, when FSM enters the from State of the Transition, it will start to count the number of updates (that is, the number of times `update()` is executed). When the number of times you set is reached, the condition of the Transition is true.

5. Physics Update times :

![](DOCUMENT.assets/physics_update_time.png)

​ In this mode, when FSM enters the start State of the Transition, it will start to count the number of physics updates (that is, the number of `times physics_updates()` is executed). When the number of times you set is reached, the condition of the Transition is true.
​ In this mode, when FSM enters the from State of the Transition, it will start to count the number of physics updates (that is, the number of `times physics_updates()` is executed). When the number of times you set is reached, the condition of the Transition is true.

### Variable Transition

Expand Down Expand Up @@ -787,7 +791,7 @@ public class TemplateTransion :Reference

### Multiple Transitions

​ When the start States of multiple Transitions are the same, and multiple Transition's conditions are true, although it will not transit to the next State randomly, its priority is opaque to developers. Therefore, when you design the Transition's condition, you should avoid that multiple Transitions with the same start State can reach to true in the same frame.
​ When the from States of multiple Transitions are the same, and multiple Transition's conditions are true, although it will not transit to the next State randomly, its priority is opaque to developers. Therefore, when you design the Transition's condition, you should avoid that multiple Transitions with the same from State can reach to true in the same frame.

## Finite State Machine - FSM

Expand Down Expand Up @@ -1343,6 +1347,12 @@ The difference between process types as follow :
> (v1.2 New Feature, Full version only)
> To play the animation backward or not.

8. bool animation_playing[default: false]

> (v1.3 New Feature)
> indicating this State is playing animation or not
> **Note:If this state is not running in the HFSM path, the meaning of this property is not reliable.**

### Methods

​ Read [State Behavior](#state-behavior--code-control) for more informations of overridable methods.
Expand Down Expand Up @@ -1413,6 +1423,12 @@ The difference between process types as follow :
> (v1.2 New Feature, Full version only)
> To play the animation backward or not.

8. bool AnimationPlaying[default: false]

> (v1.3 New Feature)
> indicating this State is playing animation or not
> **Note:If this state is not running in the HFSM path, the meaning of this property is not reliable.**

### Methods

​ Read [State Behavior](#state-behavior--code-control) for more informations of overridable methods.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Hierarchical Finite State Machine - v 1.2
# Hierarchical Finite State Machine - v 1.3

​ As we all know, state machine is a very common design pattern. Here provide a powerful and easy-to-use Godot plugin for Hierarchical Finite State Machine with visual editing.

Expand Down

0 comments on commit f1f3bc4

Please sign in to comment.