redscript-mc 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/.github/workflows/ci.yml +1 -0
  2. package/README.md +119 -313
  3. package/README.zh.md +118 -314
  4. package/ROADMAP.md +5 -5
  5. package/dist/data/impl_test/function/counter/get.mcfunction +5 -0
  6. package/dist/data/impl_test/function/counter/inc.mcfunction +7 -0
  7. package/dist/data/impl_test/function/counter/new.mcfunction +4 -0
  8. package/dist/data/impl_test/function/load.mcfunction +1 -0
  9. package/dist/data/impl_test/function/test_impl.mcfunction +10 -0
  10. package/dist/data/minecraft/tags/function/load.json +5 -0
  11. package/dist/data/playground/function/load.mcfunction +1 -0
  12. package/dist/data/playground/function/start.mcfunction +4 -0
  13. package/dist/data/playground/function/start__say_macro_t1.mcfunction +1 -0
  14. package/dist/data/playground/function/stop.mcfunction +5 -0
  15. package/dist/data/playground/function/stop__say_macro_t0.mcfunction +1 -0
  16. package/dist/data/stdlib_queue8_test/function/__queue_append_apply.mcfunction +4 -0
  17. package/dist/data/stdlib_queue8_test/function/__queue_peek_apply.mcfunction +4 -0
  18. package/dist/data/stdlib_queue8_test/function/__queue_size_raw_apply.mcfunction +4 -0
  19. package/dist/data/stdlib_queue8_test/function/load.mcfunction +1 -0
  20. package/dist/data/stdlib_queue8_test/function/queue_clear.mcfunction +6 -0
  21. package/dist/data/stdlib_queue8_test/function/queue_empty__merge_1.mcfunction +5 -0
  22. package/dist/data/stdlib_queue8_test/function/queue_empty__then_0.mcfunction +5 -0
  23. package/dist/data/stdlib_queue8_test/function/queue_peek__merge_1.mcfunction +13 -0
  24. package/dist/data/stdlib_queue8_test/function/queue_peek__then_0.mcfunction +5 -0
  25. package/dist/data/stdlib_queue8_test/function/queue_pop__merge_1.mcfunction +15 -0
  26. package/dist/data/stdlib_queue8_test/function/queue_pop__then_0.mcfunction +5 -0
  27. package/dist/data/stdlib_queue8_test/function/queue_push__const_11.mcfunction +6 -0
  28. package/dist/data/stdlib_queue8_test/function/queue_push__const_22.mcfunction +6 -0
  29. package/dist/data/stdlib_queue8_test/function/queue_size.mcfunction +13 -0
  30. package/dist/data/stdlib_queue8_test/function/test_queue_push_and_size.mcfunction +13 -0
  31. package/dist/data/test/function/load.mcfunction +1 -0
  32. package/dist/data/test/function/say_at.mcfunction +6 -0
  33. package/dist/data/test/function/test.mcfunction +4 -0
  34. package/dist/pack.mcmeta +6 -0
  35. package/dist/package.json +1 -1
  36. package/dist/src/__tests__/formatter-extra.test.d.ts +7 -0
  37. package/dist/src/__tests__/formatter-extra.test.js +123 -0
  38. package/dist/src/__tests__/global-vars.test.d.ts +13 -0
  39. package/dist/src/__tests__/global-vars.test.js +156 -0
  40. package/dist/src/__tests__/lint/new-rules.test.d.ts +9 -0
  41. package/dist/src/__tests__/lint/new-rules.test.js +402 -0
  42. package/dist/src/__tests__/lsp-rename.test.d.ts +8 -0
  43. package/dist/src/__tests__/lsp-rename.test.js +157 -0
  44. package/dist/src/__tests__/mc-integration/say-fstring.test.d.ts +11 -0
  45. package/dist/src/__tests__/mc-integration/say-fstring.test.js +220 -0
  46. package/dist/src/__tests__/mc-integration/stdlib-coverage-2.test.js +1 -1
  47. package/dist/src/__tests__/mc-integration/stdlib-coverage-3.test.js +1 -1
  48. package/dist/src/__tests__/mc-integration/stdlib-coverage-4.test.js +1 -1
  49. package/dist/src/__tests__/mc-integration/stdlib-coverage-5.test.js +1 -1
  50. package/dist/src/__tests__/mc-integration/stdlib-coverage-6.test.js +1 -1
  51. package/dist/src/__tests__/mc-integration/stdlib-coverage-7.test.js +1 -1
  52. package/dist/src/__tests__/mc-integration/stdlib-coverage-8.test.js +1 -1
  53. package/dist/src/__tests__/mc-syntax.test.js +4 -1
  54. package/dist/src/__tests__/monomorphize-coverage.test.d.ts +9 -0
  55. package/dist/src/__tests__/monomorphize-coverage.test.js +204 -0
  56. package/dist/src/__tests__/optimizer-cse.test.d.ts +7 -0
  57. package/dist/src/__tests__/optimizer-cse.test.js +226 -0
  58. package/dist/src/__tests__/parser.test.js +4 -13
  59. package/dist/src/__tests__/repl-server-extra.test.js +6 -7
  60. package/dist/src/__tests__/repl-server.test.js +5 -7
  61. package/dist/src/__tests__/stdlib/queue.test.js +6 -6
  62. package/dist/src/cli.js +0 -0
  63. package/dist/src/lexer/index.js +2 -1
  64. package/dist/src/lint/index.d.ts +12 -5
  65. package/dist/src/lint/index.js +730 -5
  66. package/dist/src/lsp/main.js +0 -0
  67. package/dist/src/mc-test/client.d.ts +21 -0
  68. package/dist/src/mc-test/client.js +34 -0
  69. package/dist/src/mir/lower.js +108 -6
  70. package/dist/src/optimizer/interprocedural.js +37 -2
  71. package/dist/src/parser/decl-parser.d.ts +19 -0
  72. package/dist/src/parser/decl-parser.js +323 -0
  73. package/dist/src/parser/expr-parser.d.ts +46 -0
  74. package/dist/src/parser/expr-parser.js +759 -0
  75. package/dist/src/parser/index.d.ts +8 -129
  76. package/dist/src/parser/index.js +13 -2262
  77. package/dist/src/parser/stmt-parser.d.ts +28 -0
  78. package/dist/src/parser/stmt-parser.js +577 -0
  79. package/dist/src/parser/type-parser.d.ts +20 -0
  80. package/dist/src/parser/type-parser.js +257 -0
  81. package/dist/src/parser/utils.d.ts +34 -0
  82. package/dist/src/parser/utils.js +141 -0
  83. package/docs/dev/README-mc-integration-tests.md +141 -0
  84. package/docs/lint-rules.md +162 -0
  85. package/docs/stdlib/bigint.md +2 -0
  86. package/editors/vscode/README.md +63 -41
  87. package/editors/vscode/out/extension.js +1881 -1776
  88. package/editors/vscode/out/lsp-server.js +4257 -3651
  89. package/editors/vscode/package-lock.json +3 -3
  90. package/editors/vscode/package.json +1 -1
  91. package/examples/loops-demo.mcrs +87 -0
  92. package/package.json +1 -1
  93. package/redscript-docs/docs/en/stdlib/advanced.md +629 -0
  94. package/redscript-docs/docs/en/stdlib/bigint.md +316 -0
  95. package/redscript-docs/docs/en/stdlib/bits.md +292 -0
  96. package/redscript-docs/docs/en/stdlib/bossbar.md +177 -0
  97. package/redscript-docs/docs/en/stdlib/calculus.md +289 -0
  98. package/redscript-docs/docs/en/stdlib/color.md +353 -0
  99. package/redscript-docs/docs/en/stdlib/combat.md +88 -0
  100. package/redscript-docs/docs/en/stdlib/cooldown.md +82 -0
  101. package/redscript-docs/docs/en/stdlib/dialog.md +155 -0
  102. package/redscript-docs/docs/en/stdlib/easing.md +558 -0
  103. package/redscript-docs/docs/en/stdlib/ecs.md +475 -0
  104. package/redscript-docs/docs/en/stdlib/effects.md +324 -0
  105. package/redscript-docs/docs/en/stdlib/events.md +3 -0
  106. package/redscript-docs/docs/en/stdlib/expr.md +45 -0
  107. package/redscript-docs/docs/en/stdlib/fft.md +141 -0
  108. package/redscript-docs/docs/en/stdlib/geometry.md +430 -0
  109. package/redscript-docs/docs/en/stdlib/graph.md +259 -0
  110. package/redscript-docs/docs/en/stdlib/heap.md +185 -0
  111. package/redscript-docs/docs/en/stdlib/interactions.md +179 -0
  112. package/redscript-docs/docs/en/stdlib/inventory.md +97 -0
  113. package/redscript-docs/docs/en/stdlib/linalg.md +557 -0
  114. package/redscript-docs/docs/en/stdlib/list.md +559 -0
  115. package/redscript-docs/docs/en/stdlib/map.md +140 -0
  116. package/redscript-docs/docs/en/stdlib/math.md +193 -0
  117. package/redscript-docs/docs/en/stdlib/math_hp.md +149 -0
  118. package/redscript-docs/docs/en/stdlib/matrix.md +403 -0
  119. package/redscript-docs/docs/en/stdlib/mobs.md +965 -0
  120. package/redscript-docs/docs/en/stdlib/noise.md +244 -0
  121. package/redscript-docs/docs/en/stdlib/ode.md +253 -0
  122. package/redscript-docs/docs/en/stdlib/parabola.md +342 -0
  123. package/redscript-docs/docs/en/stdlib/particles.md +311 -0
  124. package/redscript-docs/docs/en/stdlib/pathfind.md +255 -0
  125. package/redscript-docs/docs/en/stdlib/physics.md +493 -0
  126. package/redscript-docs/docs/en/stdlib/player.md +78 -0
  127. package/redscript-docs/docs/en/stdlib/quaternion.md +673 -0
  128. package/redscript-docs/docs/en/stdlib/queue.md +134 -0
  129. package/redscript-docs/docs/en/stdlib/random.md +223 -0
  130. package/redscript-docs/docs/en/stdlib/result.md +143 -0
  131. package/redscript-docs/docs/en/stdlib/scheduler.md +183 -0
  132. package/redscript-docs/docs/en/stdlib/set_int.md +190 -0
  133. package/redscript-docs/docs/en/stdlib/sets.md +101 -0
  134. package/redscript-docs/docs/en/stdlib/signal.md +400 -0
  135. package/redscript-docs/docs/en/stdlib/sort.md +104 -0
  136. package/redscript-docs/docs/en/stdlib/spawn.md +147 -0
  137. package/redscript-docs/docs/en/stdlib/state.md +142 -0
  138. package/redscript-docs/docs/en/stdlib/strings.md +154 -0
  139. package/redscript-docs/docs/en/stdlib/tags.md +3451 -0
  140. package/redscript-docs/docs/en/stdlib/teams.md +153 -0
  141. package/redscript-docs/docs/en/stdlib/timer.md +246 -0
  142. package/redscript-docs/docs/en/stdlib/vec.md +158 -0
  143. package/redscript-docs/docs/en/stdlib/world.md +298 -0
  144. package/redscript-docs/docs/zh/stdlib/advanced.md +615 -0
  145. package/redscript-docs/docs/zh/stdlib/bigint.md +316 -0
  146. package/redscript-docs/docs/zh/stdlib/bits.md +292 -0
  147. package/redscript-docs/docs/zh/stdlib/bossbar.md +170 -0
  148. package/redscript-docs/docs/zh/stdlib/calculus.md +287 -0
  149. package/redscript-docs/docs/zh/stdlib/color.md +353 -0
  150. package/redscript-docs/docs/zh/stdlib/combat.md +88 -0
  151. package/redscript-docs/docs/zh/stdlib/cooldown.md +84 -0
  152. package/redscript-docs/docs/zh/stdlib/dialog.md +152 -0
  153. package/redscript-docs/docs/zh/stdlib/easing.md +558 -0
  154. package/redscript-docs/docs/zh/stdlib/ecs.md +472 -0
  155. package/redscript-docs/docs/zh/stdlib/effects.md +324 -0
  156. package/redscript-docs/docs/zh/stdlib/events.md +3 -0
  157. package/redscript-docs/docs/zh/stdlib/expr.md +37 -0
  158. package/redscript-docs/docs/zh/stdlib/fft.md +128 -0
  159. package/redscript-docs/docs/zh/stdlib/geometry.md +430 -0
  160. package/redscript-docs/docs/zh/stdlib/graph.md +259 -0
  161. package/redscript-docs/docs/zh/stdlib/heap.md +185 -0
  162. package/redscript-docs/docs/zh/stdlib/interactions.md +160 -0
  163. package/redscript-docs/docs/zh/stdlib/inventory.md +94 -0
  164. package/redscript-docs/docs/zh/stdlib/linalg.md +543 -0
  165. package/redscript-docs/docs/zh/stdlib/list.md +561 -0
  166. package/redscript-docs/docs/zh/stdlib/map.md +132 -0
  167. package/redscript-docs/docs/zh/stdlib/math.md +193 -0
  168. package/redscript-docs/docs/zh/stdlib/math_hp.md +143 -0
  169. package/redscript-docs/docs/zh/stdlib/matrix.md +396 -0
  170. package/redscript-docs/docs/zh/stdlib/mobs.md +965 -0
  171. package/redscript-docs/docs/zh/stdlib/noise.md +244 -0
  172. package/redscript-docs/docs/zh/stdlib/ode.md +243 -0
  173. package/redscript-docs/docs/zh/stdlib/parabola.md +337 -0
  174. package/redscript-docs/docs/zh/stdlib/particles.md +307 -0
  175. package/redscript-docs/docs/zh/stdlib/pathfind.md +255 -0
  176. package/redscript-docs/docs/zh/stdlib/physics.md +493 -0
  177. package/redscript-docs/docs/zh/stdlib/player.md +78 -0
  178. package/redscript-docs/docs/zh/stdlib/quaternion.md +669 -0
  179. package/redscript-docs/docs/zh/stdlib/queue.md +124 -0
  180. package/redscript-docs/docs/zh/stdlib/random.md +222 -0
  181. package/redscript-docs/docs/zh/stdlib/result.md +147 -0
  182. package/redscript-docs/docs/zh/stdlib/scheduler.md +173 -0
  183. package/redscript-docs/docs/zh/stdlib/set_int.md +180 -0
  184. package/redscript-docs/docs/zh/stdlib/sets.md +107 -0
  185. package/redscript-docs/docs/zh/stdlib/signal.md +373 -0
  186. package/redscript-docs/docs/zh/stdlib/sort.md +104 -0
  187. package/redscript-docs/docs/zh/stdlib/spawn.md +142 -0
  188. package/redscript-docs/docs/zh/stdlib/state.md +134 -0
  189. package/redscript-docs/docs/zh/stdlib/strings.md +107 -0
  190. package/redscript-docs/docs/zh/stdlib/tags.md +3451 -0
  191. package/redscript-docs/docs/zh/stdlib/teams.md +150 -0
  192. package/redscript-docs/docs/zh/stdlib/timer.md +254 -0
  193. package/redscript-docs/docs/zh/stdlib/vec.md +158 -0
  194. package/redscript-docs/docs/zh/stdlib/world.md +289 -0
  195. package/src/__tests__/formatter-extra.test.ts +139 -0
  196. package/src/__tests__/global-vars.test.ts +171 -0
  197. package/src/__tests__/lint/new-rules.test.ts +437 -0
  198. package/src/__tests__/lsp-rename.test.ts +171 -0
  199. package/src/__tests__/mc-integration/say-fstring.test.ts +211 -0
  200. package/src/__tests__/mc-integration/stdlib-coverage-2.test.ts +1 -1
  201. package/src/__tests__/mc-integration/stdlib-coverage-3.test.ts +1 -1
  202. package/src/__tests__/mc-integration/stdlib-coverage-4.test.ts +1 -1
  203. package/src/__tests__/mc-integration/stdlib-coverage-5.test.ts +1 -1
  204. package/src/__tests__/mc-integration/stdlib-coverage-6.test.ts +1 -1
  205. package/src/__tests__/mc-integration/stdlib-coverage-7.test.ts +1 -1
  206. package/src/__tests__/mc-integration/stdlib-coverage-8.test.ts +1 -1
  207. package/src/__tests__/mc-syntax.test.ts +3 -0
  208. package/src/__tests__/monomorphize-coverage.test.ts +220 -0
  209. package/src/__tests__/optimizer-cse.test.ts +250 -0
  210. package/src/__tests__/parser.test.ts +4 -13
  211. package/src/__tests__/repl-server-extra.test.ts +6 -6
  212. package/src/__tests__/repl-server.test.ts +5 -6
  213. package/src/__tests__/stdlib/queue.test.ts +6 -6
  214. package/src/lexer/index.ts +2 -1
  215. package/src/lint/index.ts +713 -5
  216. package/src/mc-test/client.ts +40 -0
  217. package/src/mir/lower.ts +111 -2
  218. package/src/optimizer/interprocedural.ts +40 -2
  219. package/src/parser/decl-parser.ts +349 -0
  220. package/src/parser/expr-parser.ts +838 -0
  221. package/src/parser/index.ts +17 -2558
  222. package/src/parser/stmt-parser.ts +585 -0
  223. package/src/parser/type-parser.ts +276 -0
  224. package/src/parser/utils.ts +173 -0
  225. package/src/stdlib/queue.mcrs +19 -6
@@ -0,0 +1,244 @@
1
+ # Noise
2
+
3
+ > 本文档由 `src/stdlib/noise.mcrs` 自动生成,请勿手动编辑。
4
+
5
+ ## API 列表
6
+
7
+ - [hash_1d](#hash-1d)
8
+ - [hash_2d](#hash-2d)
9
+ - [hash_1d_pos](#hash-1d-pos)
10
+ - [hash_2d_pos](#hash-2d-pos)
11
+ - [value_noise_1d](#value-noise-1d)
12
+ - [value_noise_2d](#value-noise-2d)
13
+ - [fbm_1d](#fbm-1d)
14
+ - [fbm_2d](#fbm-2d)
15
+ - [terrain_height](#terrain-height)
16
+
17
+ ---
18
+
19
+ ## `hash_1d` <Badge type="info" text="v1.0.0" />
20
+
21
+ 从一维整数坐标生成伪随机整数
22
+
23
+ ```redscript
24
+ fn hash_1d(x: int): int
25
+ ```
26
+
27
+ **参数**
28
+
29
+ | 参数 | 说明 |
30
+ |------|------|
31
+ | `x` | 输入坐标(任意整数) |
32
+
33
+ **返回:** 伪随机整数(任意值;用 % 限制范围)
34
+
35
+ **示例**
36
+
37
+ ```redscript
38
+ let h: int = hash_1d(42) // deterministic hash of coordinate 42
39
+ ```
40
+
41
+ ---
42
+
43
+ ## `hash_2d` <Badge type="info" text="v1.0.0" />
44
+
45
+ 从二维整数坐标对生成伪随机整数
46
+
47
+ ```redscript
48
+ fn hash_2d(x: int, z: int): int
49
+ ```
50
+
51
+ **参数**
52
+
53
+ | 参数 | 说明 |
54
+ |------|------|
55
+ | `x` | 第一个坐标 |
56
+ | `z` | 第二个坐标 |
57
+
58
+ **返回:** 确定性组合两个输入的伪随机整数
59
+
60
+ **示例**
61
+
62
+ ```redscript
63
+ let h: int = hash_2d(10, 20) // deterministic hash of (10, 20)
64
+ ```
65
+
66
+ ---
67
+
68
+ ## `hash_1d_pos` <Badge type="info" text="v1.0.0" />
69
+
70
+ Generate a non-negative hash in [0, 10000] from a 1D coordinate.
71
+
72
+ ```redscript
73
+ fn hash_1d_pos(x: int): int
74
+ ```
75
+
76
+ **参数**
77
+
78
+ | 参数 | 说明 |
79
+ |------|------|
80
+ | `x` | Input coordinate |
81
+
82
+ **返回:** Integer in [0, 10000]
83
+
84
+ **示例**
85
+
86
+ ```redscript
87
+ let v: int = hash_1d_pos(5) // value between 0 and 10000
88
+ ```
89
+
90
+ ---
91
+
92
+ ## `hash_2d_pos` <Badge type="info" text="v1.0.0" />
93
+
94
+ Generate a non-negative hash in [0, 10000] from a 2D coordinate pair.
95
+
96
+ ```redscript
97
+ fn hash_2d_pos(x: int, z: int): int
98
+ ```
99
+
100
+ **参数**
101
+
102
+ | 参数 | 说明 |
103
+ |------|------|
104
+ | `x` | First coordinate |
105
+ | `z` | Second coordinate |
106
+
107
+ **返回:** Integer in [0, 10000]
108
+
109
+ **示例**
110
+
111
+ ```redscript
112
+ let v: int = hash_2d_pos(3, 7) // value between 0 and 10000
113
+ ```
114
+
115
+ ---
116
+
117
+ ## `value_noise_1d` <Badge type="info" text="v1.0.0" />
118
+
119
+ 定点数位置处的平滑一维值噪声
120
+
121
+ ```redscript
122
+ fn value_noise_1d(x_fx: int): int
123
+ ```
124
+
125
+ **参数**
126
+
127
+ | 参数 | 说明 |
128
+ |------|------|
129
+ | `x_fx` | 位置 ×10000(如 10000 = 坐标 1.0) |
130
+
131
+ **返回:** 噪声值,范围 [0, 10000],整数坐标间平滑插值
132
+
133
+ **示例**
134
+
135
+ ```redscript
136
+ let n: int = value_noise_1d(15000) // smooth noise at x=1.5
137
+ ```
138
+
139
+ ---
140
+
141
+ ## `value_noise_2d` <Badge type="info" text="v1.0.0" />
142
+
143
+ 定点数位置处的平滑二维值噪声
144
+
145
+ ```redscript
146
+ fn value_noise_2d(x_fx: int, z_fx: int): int
147
+ ```
148
+
149
+ **参数**
150
+
151
+ | 参数 | 说明 |
152
+ |------|------|
153
+ | `x_fx` | X 位置 ×10000 |
154
+ | `z_fx` | Z 位置 ×10000 |
155
+
156
+ **返回:** 噪声值,范围 [0, 10000],双线性平滑插值
157
+
158
+ **示例**
159
+
160
+ ```redscript
161
+ let n: int = value_noise_2d(15000, 23000) // noise at (1.5, 2.3)
162
+ ```
163
+
164
+ ---
165
+
166
+ ## `fbm_1d` <Badge type="info" text="v1.0.0" />
167
+
168
+ 一维分形布朗运动(fBm)— 叠加多组八度值噪声
169
+
170
+ ```redscript
171
+ fn fbm_1d(x_fx: int, octaves: int, persistence_fx: int): int
172
+ ```
173
+
174
+ **参数**
175
+
176
+ | 参数 | 说明 |
177
+ |------|------|
178
+ | `x_fx` | 位置 ×10000 |
179
+ | `octaves` | 噪声层数(1–6;越多细节越丰富但越慢) |
180
+ | `persistence_fx` | 每八度振幅衰减因子 ×10000(5000 = 0.5 推荐) |
181
+
182
+ **返回:** 归一化噪声值,约在 [0, 10000]
183
+
184
+ **示例**
185
+
186
+ ```redscript
187
+ let h: int = fbm_1d(50000, 4, 5000) // 4 octave noise at x=5.0
188
+ ```
189
+
190
+ ---
191
+
192
+ ## `fbm_2d` <Badge type="info" text="v1.0.0" />
193
+
194
+ 二维分形布朗运动 — 叠加多组二维值噪声
195
+
196
+ ```redscript
197
+ fn fbm_2d(x_fx: int, z_fx: int, octaves: int, persistence_fx: int): int
198
+ ```
199
+
200
+ **参数**
201
+
202
+ | 参数 | 说明 |
203
+ |------|------|
204
+ | `x_fx` | X 位置 ×10000 |
205
+ | `z_fx` | Z 位置 ×10000 |
206
+ | `octaves` | 噪声层数(1–6) |
207
+ | `persistence_fx` | 振幅衰减因子 ×10000 |
208
+
209
+ **返回:** 归一化噪声值,约在 [0, 10000]
210
+
211
+ **示例**
212
+
213
+ ```redscript
214
+ let h: int = fbm_2d(30000, 50000, 3, 5000) // 3 octave 2D noise
215
+ ```
216
+
217
+ ---
218
+
219
+ ## `terrain_height` <Badge type="info" text="v1.0.0" />
220
+
221
+ 使用 3 组八度 fBm 噪声生成地形高度
222
+
223
+ ```redscript
224
+ fn terrain_height(x: int, z: int, base_y: int, amplitude: int): int
225
+ ```
226
+
227
+ **参数**
228
+
229
+ | 参数 | 说明 |
230
+ |------|------|
231
+ | `x` | 方块 X 坐标(整数,非定点数) |
232
+ | `z` | 方块 Z 坐标(整数,非定点数) |
233
+ | `base_y` | 基础高度(方块) |
234
+ | `amplitude` | 最大高度变化(方块) |
235
+
236
+ **返回:** 坐标 (x, z) 处的方块高度
237
+
238
+ **示例**
239
+
240
+ ```redscript
241
+ let h: int = terrain_height(100, 200, 64, 16) // terrain at (100, 200) near y=64
242
+ ```
243
+
244
+ ---
@@ -0,0 +1,243 @@
1
+ # Ode
2
+
3
+ > 本文档由 `src/stdlib/ode.mcrs` 自动生成,请勿手动编辑。
4
+
5
+ ## API 列表
6
+
7
+ - [ode_mul_fx](#ode-mul-fx)
8
+ - [ode_weighted_increment](#ode-weighted-increment)
9
+ - [ode_reset](#ode-reset)
10
+ - [ode_get_system](#ode-get-system)
11
+ - [ode_get_t](#ode-get-t)
12
+ - [ode_get_y](#ode-get-y)
13
+ - [ode_get_y2](#ode-get-y2)
14
+ - [ode_get_k](#ode-get-k)
15
+ - [ode_get_extra](#ode-get-extra)
16
+ - [ode_get_steps](#ode-get-steps)
17
+ - [ode_step](#ode-step)
18
+ - [ode_run](#ode-run)
19
+ - [ode_run2](#ode-run2)
20
+
21
+ ---
22
+
23
+ ## `ode_mul_fx` <Badge type="info" text="v2.0.0" />
24
+
25
+ 定点数乘法:a_fx * b_fx / 10000
26
+
27
+ ```redscript
28
+ fn ode_mul_fx(a_fx: int, b_fx: int): int
29
+ ```
30
+
31
+ **参数**
32
+
33
+ | 参数 | 说明 |
34
+ |------|------|
35
+ | `a_fx` | 第一个操作数 ×10000 |
36
+ | `b_fx` | 第二个操作数 ×10000 |
37
+
38
+ **返回:** 乘积(×10000)
39
+
40
+ ---
41
+
42
+ ## `ode_weighted_increment` <Badge type="info" text="v2.0.0" />
43
+
44
+ 计算 RK4 加权增量:h * (k1 + 2k2 + 2k3 + k4) / 6
45
+
46
+ ```redscript
47
+ fn ode_weighted_increment(h_fx: int, deriv_sum_fx: int): int
48
+ ```
49
+
50
+ **参数**
51
+
52
+ | 参数 | 说明 |
53
+ |------|------|
54
+ | `h_fx` | 步长 ×10000 |
55
+ | `deriv_sum_fx` | k1 + 2k2 + 2k3 + k4,×10000 |
56
+
57
+ **返回:** 加权增量 ×10000
58
+
59
+ ---
60
+
61
+ ## `ode_reset` <Badge type="info" text="v2.0.0" />
62
+
63
+ 在 storage rs:ode 中初始化 ODE 模块状态
64
+
65
+ ```redscript
66
+ fn ode_reset(system_id: int, t_fx: int, y_fx: int, y2_fx: int, k_fx: int, extra_fx: int)
67
+ ```
68
+
69
+ **参数**
70
+
71
+ | 参数 | 说明 |
72
+ |------|------|
73
+ | `system_id` | 内置系统常量(1=衰减,2=增长,3=振荡器) |
74
+ | `t_fx` | 初始时间 ×10000 |
75
+ | `y_fx` | 初始主变量 y(0) ×10000 |
76
+ | `y2_fx` | 初始次变量 y'(0) ×10000(仅 system 3 使用) |
77
+ | `k_fx` | 速率/弹性常数 ×10000 |
78
+ | `extra_fx` | 阻尼系数 ×10000(仅 system 3 使用) |
79
+
80
+ **示例**
81
+
82
+ ```redscript
83
+ ode_reset(1, 0, 10000, 0, 10000, 0)
84
+ ```
85
+
86
+ ---
87
+
88
+ ## `ode_get_system` <Badge type="info" text="v2.0.0" />
89
+
90
+ 返回 ODE 状态中的系统 ID
91
+
92
+ ```redscript
93
+ fn ode_get_system(): int
94
+ ```
95
+
96
+ **返回:** 槽位 0 中存储的系统 ID
97
+
98
+ ---
99
+
100
+ ## `ode_get_t` <Badge type="info" text="v2.0.0" />
101
+
102
+ 返回当前时间 t(×10000)
103
+
104
+ ```redscript
105
+ fn ode_get_t(): int
106
+ ```
107
+
108
+ **返回:** 当前时间 ×10000
109
+
110
+ ---
111
+
112
+ ## `ode_get_y` <Badge type="info" text="v2.0.0" />
113
+
114
+ 返回当前主变量 y(×10000)
115
+
116
+ ```redscript
117
+ fn ode_get_y(): int
118
+ ```
119
+
120
+ **返回:** 当前 y 值 ×10000
121
+
122
+ ---
123
+
124
+ ## `ode_get_y2` <Badge type="info" text="v2.0.0" />
125
+
126
+ 返回当前次变量 y'(×10000,仅对 system 3 有意义)
127
+
128
+ ```redscript
129
+ fn ode_get_y2(): int
130
+ ```
131
+
132
+ **返回:** 当前 y' 值 ×10000
133
+
134
+ ---
135
+
136
+ ## `ode_get_k` <Badge type="info" text="v2.0.0" />
137
+
138
+ 返回速率常数 k(×10000)
139
+
140
+ ```redscript
141
+ fn ode_get_k(): int
142
+ ```
143
+
144
+ **返回:** 速率常数 ×10000
145
+
146
+ ---
147
+
148
+ ## `ode_get_extra` <Badge type="info" text="v2.0.0" />
149
+
150
+ 返回额外参数(×10000,system 3 中表示阻尼)
151
+
152
+ ```redscript
153
+ fn ode_get_extra(): int
154
+ ```
155
+
156
+ **返回:** 额外参数 ×10000
157
+
158
+ ---
159
+
160
+ ## `ode_get_steps` <Badge type="info" text="v2.0.0" />
161
+
162
+ 返回已执行的步数
163
+
164
+ ```redscript
165
+ fn ode_get_steps(): int
166
+ ```
167
+
168
+ **返回:** 步数(普通整数)
169
+
170
+ ---
171
+
172
+ ## `ode_step` <Badge type="info" text="v2.0.0" />
173
+
174
+ 向前推进一个 RK4 步
175
+
176
+ ```redscript
177
+ fn ode_step(h_fx: int)
178
+ ```
179
+
180
+ **参数**
181
+
182
+ | 参数 | 说明 |
183
+ |------|------|
184
+ | `h_fx` | 步长 ×10000(如 1000 = 0.1 时间单位) |
185
+
186
+ ---
187
+
188
+ ## `ode_run` <Badge type="info" text="v2.0.0" />
189
+
190
+ 对标量 ODE 系统执行 steps 步 RK4 积分
191
+
192
+ ```redscript
193
+ fn ode_run(system_id: int, t0_fx: int, y0_fx: int, h_fx: int, steps: int, k_fx: int)
194
+ ```
195
+
196
+ **参数**
197
+
198
+ | 参数 | 说明 |
199
+ |------|------|
200
+ | `system_id` | 内置系统常量(1 或 2 用于标量系统) |
201
+ | `t0_fx` | 初始时间 ×10000 |
202
+ | `y0_fx` | 初始 y 值 ×10000 |
203
+ | `h_fx` | 步长 ×10000 |
204
+ | `steps` | RK4 步数 |
205
+ | `k_fx` | 速率常数 ×10000 |
206
+
207
+ **示例**
208
+
209
+ ```redscript
210
+ ode_run(1, 0, 10000, 1000, 10, 10000)
211
+ let y: int = ode_get_y()
212
+ ```
213
+
214
+ ---
215
+
216
+ ## `ode_run2` <Badge type="info" text="v2.0.0" />
217
+
218
+ 对二维 ODE 系统(如谐振子)执行 steps 步 RK4 积分
219
+
220
+ ```redscript
221
+ fn ode_run2(system_id: int, t0_fx: int, y0_fx: int, y20_fx: int, h_fx: int, steps: int, k_fx: int, extra_fx: int)
222
+ ```
223
+
224
+ **参数**
225
+
226
+ | 参数 | 说明 |
227
+ |------|------|
228
+ | `system_id` | 内置系统常量(system 3 = 谐振子) |
229
+ | `t0_fx` | 初始时间 ×10000 |
230
+ | `y0_fx` | 初始 y 值 ×10000 |
231
+ | `y20_fx` | 初始 y' 值 ×10000 |
232
+ | `h_fx` | 步长 ×10000 |
233
+ | `steps` | RK4 步数 |
234
+ | `k_fx` | 弹性常数 ×10000 |
235
+ | `extra_fx` | 阻尼系数 ×10000 |
236
+
237
+ **示例**
238
+
239
+ ```redscript
240
+ ode_run2(3, 0, 10000, 0, 1000, 20, 10000, 500)
241
+ ```
242
+
243
+ ---