@origingame/engine 0.0.0-stage → 0.1.1
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.
- package/bin/og.mjs +25 -0
- package/dist/web/origin-engine.d.ts +1233 -0
- package/dist/web/origin-engine.js +8628 -0
- package/dist/web/origin-engine_bg.wasm +0 -0
- package/dist/web/origin-engine_bg.wasm.d.ts +366 -0
- package/dist/web-publish/origin-engine-lanes.js +8509 -0
- package/dist/web-publish/origin-engine-lanes_bg.wasm +0 -0
- package/dist/web-publish/origin-engine.d.ts +1176 -0
- package/dist/web-publish/origin-engine.js +8313 -0
- package/dist/web-publish/origin-engine_bg.wasm +0 -0
- package/dist/web-publish/origin-engine_bg.wasm.d.ts +347 -0
- package/dist/web-publish/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.no-bundler.js +77 -0
- package/dist/web-publish-2d/origin-engine-lanes.js +8509 -0
- package/dist/web-publish-2d/origin-engine-lanes_bg.wasm +0 -0
- package/dist/web-publish-2d/origin-engine.d.ts +1176 -0
- package/dist/web-publish-2d/origin-engine.js +8313 -0
- package/dist/web-publish-2d/origin-engine_bg.wasm +0 -0
- package/dist/web-publish-2d/origin-engine_bg.wasm.d.ts +347 -0
- package/dist/web-publish-2d/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.no-bundler.js +77 -0
- package/knowledge/README.md +31 -0
- package/knowledge/knowledge.json +13 -0
- package/knowledge/looks/catalogue.json +1871 -0
- package/knowledge/package.json +33 -0
- package/knowledge/rules/platform.json +329 -0
- package/knowledge/scaffold/README.md +27 -0
- package/knowledge/scaffold/distribution.json +48 -0
- package/knowledge/scaffold/origin-engine.json +19 -0
- package/knowledge/scaffold/template/.origin/setup +14 -0
- package/knowledge/scaffold/template/LICENSES.md +23 -0
- package/knowledge/scaffold/template/README.md +37 -0
- package/knowledge/scaffold/template/assets/ai/guard.ogt +48 -0
- package/knowledge/scaffold/template/assets/audio/click.ogt +9 -0
- package/knowledge/scaffold/template/assets/fonts/NotoSansSC-Regular-subset.ttf.ogt +12 -0
- package/knowledge/scaffold/template/assets/fonts/OFL.txt +93 -0
- package/knowledge/scaffold/template/assets/looks/origin-game.ogt +12 -0
- package/knowledge/scaffold/template/assets/nav/yard.ogt +27 -0
- package/knowledge/scaffold/template/assets/scenes/main.ogt +34 -0
- package/knowledge/scaffold/template/assets/strings/en.ogt +14 -0
- package/knowledge/scaffold/template/assets/textures/stone_n.png.ogt +7 -0
- package/knowledge/scaffold/template/gitattributes +22 -0
- package/knowledge/scaffold/template/gitignore +8 -0
- package/knowledge/scaffold/template/package.json +18 -0
- package/knowledge/scaffold/template/project.ogt +25 -0
- package/knowledge/scaffold/template/src/main.ts +246 -0
- package/knowledge/scaffold/template/tests/guard.og.ts +67 -0
- package/knowledge/scaffold/template/tests/smoke.og.ts +43 -0
- package/knowledge/scaffold/template/tsconfig.json +17 -0
- package/knowledge/scripts/lib.ts +207 -0
- package/knowledge/scripts/mount.ts +210 -0
- package/knowledge/scripts/pack.ts +25 -0
- package/knowledge/scripts/scaffold.ts +72 -0
- package/knowledge/scripts/validate.ts +749 -0
- package/knowledge/skills/og-ai/SKILL.md +386 -0
- package/knowledge/skills/og-audio/SKILL.md +191 -0
- package/knowledge/skills/og-build/SKILL.md +330 -0
- package/knowledge/skills/og-core/SKILL.md +285 -0
- package/knowledge/skills/og-feel/SKILL.md +385 -0
- package/knowledge/skills/og-game/SKILL.md +1479 -0
- package/knowledge/skills/og-i18n/SKILL.md +220 -0
- package/knowledge/skills/og-platform-sdk/SKILL.md +199 -0
- package/knowledge/skills/og-taste/SKILL.md +537 -0
- package/knowledge/skills/og-ui/SKILL.md +444 -0
- package/knowledge/wiki/ai.md +627 -0
- package/knowledge/wiki/anim.md +1187 -0
- package/knowledge/wiki/atmosphere.md +636 -0
- package/knowledge/wiki/audio.md +732 -0
- package/knowledge/wiki/camera.md +711 -0
- package/knowledge/wiki/commands.md +357 -0
- package/knowledge/wiki/game.md +220 -0
- package/knowledge/wiki/i18n.md +213 -0
- package/knowledge/wiki/index.md +1027 -0
- package/knowledge/wiki/input.md +1714 -0
- package/knowledge/wiki/load.md +1280 -0
- package/knowledge/wiki/math.md +166 -0
- package/knowledge/wiki/nav.md +1154 -0
- package/knowledge/wiki/physics.md +3142 -0
- package/knowledge/wiki/platform.md +857 -0
- package/knowledge/wiki/probe.md +1692 -0
- package/knowledge/wiki/reflect.md +285 -0
- package/knowledge/wiki/render.md +3511 -0
- package/knowledge/wiki/rng.md +393 -0
- package/knowledge/wiki/stream.md +376 -0
- package/knowledge/wiki/system.md +197 -0
- package/knowledge/wiki/systems.md +43 -0
- package/knowledge/wiki/terrain.md +727 -0
- package/knowledge/wiki/tilemap.md +422 -0
- package/knowledge/wiki/time.md +150 -0
- package/knowledge/wiki/transform.md +230 -0
- package/knowledge/wiki/tween.md +580 -0
- package/knowledge/wiki/ui.md +8000 -0
- package/knowledge/wiki/world.md +909 -0
- package/package.json +68 -4
- package/schema/api.schema.json +29675 -0
- package/shell/README.md +22 -0
- package/shell/brand/README.md +23 -0
- package/shell/brand/icon-192.png +0 -0
- package/shell/brand/icon-512.png +0 -0
- package/shell/brand/mark-on-paper.svg +6 -0
- package/shell/brand/origin-mark.svg +5 -0
- package/shell/brand/origin-motion.css +251 -0
- package/shell/brand/tokens.css +20 -0
- package/shell/brand.ts +132 -0
- package/shell/page.ts +715 -0
- package/shell/platform.ts +203 -0
- package/shell/player.ts +238 -0
- package/shell/shell.css +185 -0
- package/shell/sw.ts +177 -0
- package/shell/transport.ts +515 -0
- package/shell/wire.ts +369 -0
- package/src/e6.ts +69 -0
- package/src/env.d.ts +100 -0
- package/src/generated/abi.ts +980 -0
- package/src/index.ts +193 -0
- package/src/node/audio.ts +86 -0
- package/src/node/build.ts +109 -0
- package/src/node/device.ts +981 -0
- package/src/node/doctor.ts +60 -0
- package/src/node/index.ts +102 -0
- package/src/node/platform.ts +24 -0
- package/src/node/playtest-run.ts +249 -0
- package/src/node/png.ts +130 -0
- package/src/node/polish.ts +976 -0
- package/src/node/run.ts +373 -0
- package/src/node/web-build.ts +808 -0
- package/src/p2.ts +35 -0
- package/src/platform-local.ts +211 -0
- package/src/playtest.ts +131 -0
- package/src/runtime.ts +1509 -0
- package/src/systems/cameras.ts +247 -0
- package/src/ui-kit/bind.ts +141 -0
- package/src/ui-kit/huds.ts +303 -0
- package/src/ui-kit/index.ts +36 -0
- package/src/ui-kit/menus.ts +187 -0
- package/src/ui-kit/settings.ts +131 -0
- package/src/ui-kit/store.ts +222 -0
- package/src/ui-kit/story.ts +89 -0
- package/src/ui-kit/util.ts +106 -0
- package/src/web/a11y.ts +429 -0
- package/src/web/audio-worklet.ts +193 -0
- package/src/web/audio.ts +307 -0
- package/src/web/basis.ts +239 -0
- package/src/web/gamepad.ts +123 -0
- package/src/web/host.ts +166 -0
- package/src/web/input.ts +237 -0
- package/src/web/lanes.ts +21 -0
- package/src/web/play.ts +20 -0
- package/src/web/rpc-ring.ts +110 -0
- package/src/web/settle.ts +122 -0
- package/src/web/shell.ts +643 -0
- package/src/web/text-input.ts +248 -0
- package/src/web/worker.ts +1002 -0
- package/types/bindings.json +13654 -0
- package/types/index.d.ts +20090 -0
- package/vendor/basis/LICENSE +201 -0
- package/vendor/basis/NOTICE +15 -0
- package/vendor/basis/README.md +18 -0
- package/vendor/basis/basis_transcoder.js +19 -0
- package/vendor/basis/basis_transcoder.wasm +0 -0
- package/README.md +0 -3
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
<!-- Generated from crates/og-api/api.ogt by `og api gen`. Do not edit: `og api check` fails on any difference; change api.ogt and regenerate. -->
|
|
2
|
+
|
|
3
|
+
# The `tilemap` module
|
|
4
|
+
|
|
5
|
+
Tilemaps: layers of tiles from a tileset atlas (an `.ogt` of `type tileset`: grid, solid tiles and collision rects, animated tiles, 47-blob and 16-bitmask auto-tiling terrains), loaded from a cooked map (a hand-written `.ogt` of `type tilemap`, a Tiled `.tmj` or an LDtk `.ldtk`) with og.load.tilemap and placed by an og.Tilemap component.
|
|
6
|
+
|
|
7
|
+
Layers draw through the sprite batch in 16x16-tile chunks culled to the view, each at the map's sprite layer plus its z, scrolled by its parallax; solid tiles become static og-physics colliders merged into rectangles. Runtime edits (og.tilemap.setTile, re-auto-tiling the neighbourhood) are world state (the og.tilemap state block), and the colliders follow them.
|
|
8
|
+
|
|
9
|
+
With og.Lighting2D enabled, a layer whose sprite layer (the map's layer plus its z) lies in minLayer to maxLayer is lit as the sprites there are: multiplied by the ambient plus every Light2D reaching it, with the shadows of Occluder2Ds and castShadow sprites, so a dark cave lit by torches is the map, its lights and its occluders. A layer that should stay as authored in the lit range (a sky, a far parallax backdrop) opts out: a bool custom property `lit` set to false on the Tiled layer, or a `lit false` line in a tilemap `.ogt`'s layer block (TileLayerInfo.lit reports it).
|
|
10
|
+
|
|
11
|
+
Cells count from the top-left corner, x right and y down (Tiled's); the map's top-left corner is at the entity's position.
|
|
12
|
+
|
|
13
|
+
- **TypeScript**: functions are the namespace `og.tilemap`; components, resources and events are tokens on `og`.
|
|
14
|
+
- **Publish builds**: kept (members may override).
|
|
15
|
+
- **Skill**: `og-game`, which teaches the module (how much of it to use, and how to prove it).
|
|
16
|
+
- **Index**: [every module and name](index.md).
|
|
17
|
+
|
|
18
|
+
```ogt
|
|
19
|
+
module tilemap {
|
|
20
|
+
# declarations follow, each quoted below
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
<sub>`api.ogt` line 6263</sub>
|
|
24
|
+
|
|
25
|
+
## Contents
|
|
26
|
+
|
|
27
|
+
| Name | Kind | Summary |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| [`TilemapAsset`](#type-TilemapAsset) | handle | A loaded map: its layers, tilesets and objects. |
|
|
30
|
+
| [`TilemapAsset()`](#column-TilemapAsset) | column kind | A TilemapAsset handle field. |
|
|
31
|
+
| [`og.Tilemap`](#record-Tilemap) | component | Draws a loaded map with its top-left corner at the entity's position (z included) and gives its collision layers static colliders. The og.tilemap system adopts it in the first tick it exists: from then on og.tilemap.setTile and getTile reach it. |
|
|
32
|
+
| [`TileLayerInfo`](#type-TileLayerInfo) | struct | One layer of a map. |
|
|
33
|
+
| [`TileObject`](#type-TileObject) | struct | An object of a map (a Tiled object, an LDtk entity, an `object` block): spawn points, doors, triggers. |
|
|
34
|
+
| [`TilemapInfo`](#type-TilemapInfo) | struct | What og.load.tilemap loaded. |
|
|
35
|
+
| [`SetTileDesc`](#type-SetTileDesc) | desc struct | One cell to change. |
|
|
36
|
+
| [`TileCell`](#type-TileCell) | struct | A cell of a map. |
|
|
37
|
+
| [`og.tilemap.setTile`](#fn-setTile) | function | Change a cell. It applies at once to getTile, and to drawing and colliders at the og.tilemap system (this tick when called before it). Deterministic: equal edits in equal order give equal maps. |
|
|
38
|
+
| [`og.tilemap.getTile`](#fn-getTile) | function | A cell's tile id, -1 when empty: on a terrain layer the tile auto-tiling resolved from the neighbours (setTile writes 1 or 0 there; the id changes with them). -1 outside the map or before the map is adopted. |
|
|
39
|
+
| [`og.tilemap.cellAt`](#fn-cellAt) | function | The cell under a world point (its xy), for a map at its entity's position. |
|
|
40
|
+
| [`og.tilemap.cellCenter`](#fn-cellCenter) | function | A cell's centre in world coordinates (z of the map). |
|
|
41
|
+
|
|
42
|
+
## Functions
|
|
43
|
+
|
|
44
|
+
<a id="fn-setTile"></a>
|
|
45
|
+
|
|
46
|
+
### `og.tilemap.setTile`
|
|
47
|
+
|
|
48
|
+
Change a cell. It applies at once to getTile, and to drawing and colliders at the og.tilemap system (this tick when called before it). Deterministic: equal edits in equal order give equal maps.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
og.tilemap.setTile(world: World, desc?: SetTileDesc): Result<void>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
| Parameter | Type | Optional | Doc |
|
|
55
|
+
|---|---|---|---|
|
|
56
|
+
| `world` | `World` | no | The world. |
|
|
57
|
+
| `desc` | `SetTileDesc` | yes | The map, the layer, the cell and the tile. |
|
|
58
|
+
|
|
59
|
+
**Returns** `Result<void>`: Refused for an entity whose map is not adopted yet, an unknown layer, a cell outside the map or a tile the tileset lacks.
|
|
60
|
+
|
|
61
|
+
Binding symbol `og_tilemap_set_tile` · publish builds: kept
|
|
62
|
+
|
|
63
|
+
```ogt
|
|
64
|
+
fn setTile {
|
|
65
|
+
doc "Change a cell. It applies at once to getTile, and to drawing and colliders at the og.tilemap system (this tick when called before it). Deterministic: equal edits in equal order give equal maps."
|
|
66
|
+
param world World "The world."
|
|
67
|
+
param desc SetTileDesc "The map, the layer, the cell and the tile."
|
|
68
|
+
returns Result.Void "Refused for an entity whose map is not adopted yet, an unknown layer, a cell outside the map or a tile the tileset lacks."
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
<sub>`api.ogt` line 6371</sub>
|
|
73
|
+
|
|
74
|
+
<a id="fn-getTile"></a>
|
|
75
|
+
|
|
76
|
+
### `og.tilemap.getTile`
|
|
77
|
+
|
|
78
|
+
A cell's tile id, -1 when empty: on a terrain layer the tile auto-tiling resolved from the neighbours (setTile writes 1 or 0 there; the id changes with them). -1 outside the map or before the map is adopted.
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
og.tilemap.getTile(world: World, entity: Entity, layer: string, x: number, y: number): number
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
| Parameter | Type | Optional | Doc |
|
|
85
|
+
|---|---|---|---|
|
|
86
|
+
| `world` | `World` | no | The world. |
|
|
87
|
+
| `entity` | `Entity` | no | The entity with the og.Tilemap. |
|
|
88
|
+
| `layer` | `string` | no | The layer's name. |
|
|
89
|
+
| `x` | `number` | no | The column. |
|
|
90
|
+
| `y` | `number` | no | The row. |
|
|
91
|
+
|
|
92
|
+
**Returns** `number`.
|
|
93
|
+
|
|
94
|
+
Binding symbol `og_tilemap_get_tile` · publish builds: kept
|
|
95
|
+
|
|
96
|
+
```ogt
|
|
97
|
+
fn getTile {
|
|
98
|
+
doc "A cell's tile id, -1 when empty: on a terrain layer the tile auto-tiling resolved from the neighbours (setTile writes 1 or 0 there; the id changes with them). -1 outside the map or before the map is adopted."
|
|
99
|
+
param world World "The world."
|
|
100
|
+
param entity Entity "The entity with the og.Tilemap."
|
|
101
|
+
param layer String "The layer's name."
|
|
102
|
+
param x u32 "The column."
|
|
103
|
+
param y u32 "The row."
|
|
104
|
+
returns i32
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
<sub>`api.ogt` line 6378</sub>
|
|
109
|
+
|
|
110
|
+
<a id="fn-cellAt"></a>
|
|
111
|
+
|
|
112
|
+
### `og.tilemap.cellAt`
|
|
113
|
+
|
|
114
|
+
The cell under a world point (its xy), for a map at its entity's position.
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
og.tilemap.cellAt(world: World, entity: Entity, point: Vector3): TileCell
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
| Parameter | Type | Optional | Doc |
|
|
121
|
+
|---|---|---|---|
|
|
122
|
+
| `world` | `World` | no | The world. |
|
|
123
|
+
| `entity` | `Entity` | no | The entity with the og.Tilemap. |
|
|
124
|
+
| `point` | `Vector3` | no | A world point. |
|
|
125
|
+
|
|
126
|
+
**Returns** `TileCell`.
|
|
127
|
+
|
|
128
|
+
Binding symbol `og_tilemap_cell_at` · publish builds: kept
|
|
129
|
+
|
|
130
|
+
```ogt
|
|
131
|
+
fn cellAt {
|
|
132
|
+
doc "The cell under a world point (its xy), for a map at its entity's position."
|
|
133
|
+
param world World "The world."
|
|
134
|
+
param entity Entity "The entity with the og.Tilemap."
|
|
135
|
+
param point Vector3 "A world point."
|
|
136
|
+
returns TileCell
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
<sub>`api.ogt` line 6388</sub>
|
|
141
|
+
|
|
142
|
+
<a id="fn-cellCenter"></a>
|
|
143
|
+
|
|
144
|
+
### `og.tilemap.cellCenter`
|
|
145
|
+
|
|
146
|
+
A cell's centre in world coordinates (z of the map).
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
og.tilemap.cellCenter(world: World, entity: Entity, x: number, y: number): Vector3
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
| Parameter | Type | Optional | Doc |
|
|
153
|
+
|---|---|---|---|
|
|
154
|
+
| `world` | `World` | no | The world. |
|
|
155
|
+
| `entity` | `Entity` | no | The entity with the og.Tilemap. |
|
|
156
|
+
| `x` | `number` | no | The column. |
|
|
157
|
+
| `y` | `number` | no | The row. |
|
|
158
|
+
|
|
159
|
+
**Returns** `Vector3`.
|
|
160
|
+
|
|
161
|
+
Binding symbol `og_tilemap_cell_center` · publish builds: kept
|
|
162
|
+
|
|
163
|
+
```ogt
|
|
164
|
+
fn cellCenter {
|
|
165
|
+
doc "A cell's centre in world coordinates (z of the map)."
|
|
166
|
+
param world World "The world."
|
|
167
|
+
param entity Entity "The entity with the og.Tilemap."
|
|
168
|
+
param x u32 "The column."
|
|
169
|
+
param y u32 "The row."
|
|
170
|
+
returns Vector3
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
<sub>`api.ogt` line 6396</sub>
|
|
175
|
+
|
|
176
|
+
## Components, resources and events
|
|
177
|
+
|
|
178
|
+
<a id="record-Tilemap"></a>
|
|
179
|
+
|
|
180
|
+
### `og.Tilemap` (component)
|
|
181
|
+
|
|
182
|
+
Draws a loaded map with its top-left corner at the entity's position (z included) and gives its collision layers static colliders. The og.tilemap system adopts it in the first tick it exists: from then on og.tilemap.setTile and getTile reach it.
|
|
183
|
+
|
|
184
|
+
Token `og.Tilemap`, registered under the schema name `og.Tilemap`; its value type is `Tilemap`.
|
|
185
|
+
|
|
186
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
187
|
+
|---|---|---|---|---|---|---|
|
|
188
|
+
| `map` | `TilemapAsset` | `0` | — | — | — | The map (og.load.tilemap's `map`); 0 is none. |
|
|
189
|
+
| `layer` | `number` | `-10` | — | — | — | The sprite layer of the map's layer 0; every layer draws at this plus its z (default: its index). |
|
|
190
|
+
| `color` | `Color` | `{ r: 1, g: 1, b: 1 }` | — | — | — | A linear tint. |
|
|
191
|
+
| `opacity` | `number` | `1` | 0 … 1 | — | — | The alpha, times each layer's. |
|
|
192
|
+
| `visible` | `boolean` | `true` | — | — | — | Whether it is drawn. |
|
|
193
|
+
| `collision` | `boolean` | `true` | — | — | — | Give the layers marked collision static colliders (rectangles merged from the solid tiles). |
|
|
194
|
+
| `colliderLayers` | `number` | `1` | — | — | — | The collision layers of those colliders, as bits (Collider.layers). |
|
|
195
|
+
| `friction` | `number` | `0.5` | 0 … 2 | — | — | The colliders' friction. |
|
|
196
|
+
|
|
197
|
+
```ogt
|
|
198
|
+
component Tilemap {
|
|
199
|
+
doc "Draws a loaded map with its top-left corner at the entity's position (z included) and gives its collision layers static colliders. The og.tilemap system adopts it in the first tick it exists: from then on og.tilemap.setTile and getTile reach it."
|
|
200
|
+
field map TilemapAsset "The map (og.load.tilemap's `map`); 0 is none."
|
|
201
|
+
field layer i32 "The sprite layer of the map's layer 0; every layer draws at this plus its z (default: its index)." {
|
|
202
|
+
default -10
|
|
203
|
+
}
|
|
204
|
+
field color Color "A linear tint." {
|
|
205
|
+
default 1 1 1
|
|
206
|
+
}
|
|
207
|
+
field opacity f32 "The alpha, times each layer's." {
|
|
208
|
+
default 1
|
|
209
|
+
min 0
|
|
210
|
+
max 1
|
|
211
|
+
}
|
|
212
|
+
field visible bool "Whether it is drawn." {
|
|
213
|
+
default true
|
|
214
|
+
}
|
|
215
|
+
field collision bool "Give the layers marked collision static colliders (rectangles merged from the solid tiles)." {
|
|
216
|
+
default true
|
|
217
|
+
}
|
|
218
|
+
field colliderLayers u32 "The collision layers of those colliders, as bits (Collider.layers)." {
|
|
219
|
+
default 1
|
|
220
|
+
}
|
|
221
|
+
field friction f32 "The colliders' friction." {
|
|
222
|
+
default 0.5
|
|
223
|
+
min 0
|
|
224
|
+
max 2
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
<sub>`api.ogt` line 6279</sub>
|
|
230
|
+
|
|
231
|
+
## Types
|
|
232
|
+
|
|
233
|
+
<a id="type-TilemapAsset"></a>
|
|
234
|
+
|
|
235
|
+
### `TilemapAsset` (handle)
|
|
236
|
+
|
|
237
|
+
A loaded map: its layers, tilesets and objects.
|
|
238
|
+
|
|
239
|
+
A generational handle: a number the engine hands out. A dead handle is an error value, never a crash.
|
|
240
|
+
|
|
241
|
+
```ogt
|
|
242
|
+
handle TilemapAsset "A loaded map: its layers, tilesets and objects."
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
<sub>`api.ogt` line 6270</sub>
|
|
246
|
+
|
|
247
|
+
<a id="type-TileLayerInfo"></a>
|
|
248
|
+
|
|
249
|
+
### `TileLayerInfo` (struct)
|
|
250
|
+
|
|
251
|
+
One layer of a map.
|
|
252
|
+
|
|
253
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
254
|
+
|---|---|---|---|---|---|---|
|
|
255
|
+
| `name` | `string` | `""` | — | — | — | Its name. |
|
|
256
|
+
| `index` | `number` | `0` | — | — | — | Its index (what drawing order and z start from). |
|
|
257
|
+
| `z` | `number` | `0` | — | — | — | Its sprite-layer offset from Tilemap.layer. |
|
|
258
|
+
| `parallax` | `Vector2` | `{ x: 0, y: 0 }` | — | — | — | Its scroll factors: 1 1 moves with the world, 0.5 at half the camera's speed (far away), 0 stays with the camera. |
|
|
259
|
+
| `collision` | `boolean` | `false` | — | — | — | Its solid tiles collide. |
|
|
260
|
+
| `terrain` | `string` | `""` | — | — | — | The auto-tiling terrain of a terrain layer (its cells are 1 filled or 0 empty); empty for a tile layer. |
|
|
261
|
+
| `visible` | `boolean` | `false` | — | — | — | Whether it is drawn. |
|
|
262
|
+
| `lit` | `boolean` | `false` | — | — | — | Whether og.Lighting2D lights it when its sprite layer is in the lit range (true unless the Tiled layer's bool property `lit` or the `.ogt` layer's `lit` line says false). |
|
|
263
|
+
|
|
264
|
+
```ogt
|
|
265
|
+
struct TileLayerInfo {
|
|
266
|
+
doc "One layer of a map."
|
|
267
|
+
field name String "Its name."
|
|
268
|
+
field index u32 "Its index (what drawing order and z start from)."
|
|
269
|
+
field z i32 "Its sprite-layer offset from Tilemap.layer."
|
|
270
|
+
field parallax Vector2 "Its scroll factors: 1 1 moves with the world, 0.5 at half the camera's speed (far away), 0 stays with the camera."
|
|
271
|
+
field collision bool "Its solid tiles collide."
|
|
272
|
+
field terrain String "The auto-tiling terrain of a terrain layer (its cells are 1 filled or 0 empty); empty for a tile layer."
|
|
273
|
+
field visible bool "Whether it is drawn."
|
|
274
|
+
field lit bool "Whether og.Lighting2D lights it when its sprite layer is in the lit range (true unless the Tiled layer's bool property `lit` or the `.ogt` layer's `lit` line says false)."
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
<sub>`api.ogt` line 6309</sub>
|
|
279
|
+
|
|
280
|
+
<a id="type-TileObject"></a>
|
|
281
|
+
|
|
282
|
+
### `TileObject` (struct)
|
|
283
|
+
|
|
284
|
+
An object of a map (a Tiled object, an LDtk entity, an `object` block): spawn points, doors, triggers.
|
|
285
|
+
|
|
286
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
287
|
+
|---|---|---|---|---|---|---|
|
|
288
|
+
| `name` | `string` | `""` | — | — | — | Its name. |
|
|
289
|
+
| `kind` | `string` | `""` | — | — | — | Its type or class. |
|
|
290
|
+
| `position` | `Vector2` | `{ x: 0, y: 0 }` | — | `m` | — | Its top-left corner, in world units relative to the map's top-left corner (y up, so below the corner is negative). |
|
|
291
|
+
| `size` | `Vector2` | `{ x: 0, y: 0 }` | — | `m` | — | Its width and height (0 0 for a point). |
|
|
292
|
+
| `center` | `Vector2` | `{ x: 0, y: 0 }` | — | `m` | — | Its centre, relative to the map's corner. |
|
|
293
|
+
| `properties` | `Readonly<Record<string, string>>` | `{}` | — | — | — | Its custom properties, as text. |
|
|
294
|
+
|
|
295
|
+
```ogt
|
|
296
|
+
struct TileObject {
|
|
297
|
+
doc "An object of a map (a Tiled object, an LDtk entity, an `object` block): spawn points, doors, triggers."
|
|
298
|
+
field name String "Its name."
|
|
299
|
+
field kind String "Its type or class."
|
|
300
|
+
field position Vector2 "Its top-left corner, in world units relative to the map's top-left corner (y up, so below the corner is negative)." {
|
|
301
|
+
unit m
|
|
302
|
+
}
|
|
303
|
+
field size Vector2 "Its width and height (0 0 for a point)." {
|
|
304
|
+
unit m
|
|
305
|
+
}
|
|
306
|
+
field center Vector2 "Its centre, relative to the map's corner." {
|
|
307
|
+
unit m
|
|
308
|
+
}
|
|
309
|
+
field properties Map.String "Its custom properties, as text."
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
<sub>`api.ogt` line 6321</sub>
|
|
314
|
+
|
|
315
|
+
<a id="type-TilemapInfo"></a>
|
|
316
|
+
|
|
317
|
+
### `TilemapInfo` (struct)
|
|
318
|
+
|
|
319
|
+
What og.load.tilemap loaded.
|
|
320
|
+
|
|
321
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
322
|
+
|---|---|---|---|---|---|---|
|
|
323
|
+
| `map` | `TilemapAsset` | `0` | — | — | — | What Tilemap.map takes. |
|
|
324
|
+
| `width` | `number` | `0` | — | — | — | Cells across. |
|
|
325
|
+
| `height` | `number` | `0` | — | — | — | Cells down. |
|
|
326
|
+
| `tileWidth` | `number` | `0` | — | `m` | — | A cell's width in world units. |
|
|
327
|
+
| `tileHeight` | `number` | `0` | — | `m` | — | A cell's height in world units. |
|
|
328
|
+
| `layers` | `readonly TileLayerInfo[]` | `[]` | — | — | — | Its layers, drawing order. |
|
|
329
|
+
| `objects` | `readonly TileObject[]` | `[]` | — | — | — | Its objects. |
|
|
330
|
+
|
|
331
|
+
```ogt
|
|
332
|
+
struct TilemapInfo {
|
|
333
|
+
doc "What og.load.tilemap loaded."
|
|
334
|
+
field map TilemapAsset "What Tilemap.map takes."
|
|
335
|
+
field width u32 "Cells across."
|
|
336
|
+
field height u32 "Cells down."
|
|
337
|
+
field tileWidth f32 "A cell's width in world units." {
|
|
338
|
+
unit m
|
|
339
|
+
}
|
|
340
|
+
field tileHeight f32 "A cell's height in world units." {
|
|
341
|
+
unit m
|
|
342
|
+
}
|
|
343
|
+
field layers List.TileLayerInfo "Its layers, drawing order."
|
|
344
|
+
field objects List.TileObject "Its objects."
|
|
345
|
+
}
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
<sub>`api.ogt` line 6337</sub>
|
|
349
|
+
|
|
350
|
+
<a id="type-SetTileDesc"></a>
|
|
351
|
+
|
|
352
|
+
### `SetTileDesc` (desc struct)
|
|
353
|
+
|
|
354
|
+
One cell to change.
|
|
355
|
+
|
|
356
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
357
|
+
|
|
358
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
359
|
+
|---|---|---|---|---|---|---|
|
|
360
|
+
| `entity` | `Entity` | `0` | — | — | — | The entity with the og.Tilemap. |
|
|
361
|
+
| `layer` | `string` | `""` | — | — | — | The layer's name. |
|
|
362
|
+
| `x` | `number` | `0` | — | — | — | The column (0 is the left). |
|
|
363
|
+
| `y` | `number` | `0` | — | — | — | The row (0 is the top). |
|
|
364
|
+
| `tile` | `number` | `0` | ≥ -1 | — | — | A tile layer: the tile id, -1 empty. A terrain layer: 1 fills, 0 clears, and the neighbours re-tile. |
|
|
365
|
+
|
|
366
|
+
```ogt
|
|
367
|
+
struct SetTileDesc {
|
|
368
|
+
doc "One cell to change."
|
|
369
|
+
desc true
|
|
370
|
+
field entity Entity "The entity with the og.Tilemap."
|
|
371
|
+
field layer String "The layer's name."
|
|
372
|
+
field x u32 "The column (0 is the left)."
|
|
373
|
+
field y u32 "The row (0 is the top)."
|
|
374
|
+
field tile i32 "A tile layer: the tile id, -1 empty. A terrain layer: 1 fills, 0 clears, and the neighbours re-tile." {
|
|
375
|
+
min -1
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
<sub>`api.ogt` line 6352</sub>
|
|
381
|
+
|
|
382
|
+
<a id="type-TileCell"></a>
|
|
383
|
+
|
|
384
|
+
### `TileCell` (struct)
|
|
385
|
+
|
|
386
|
+
A cell of a map.
|
|
387
|
+
|
|
388
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
389
|
+
|---|---|---|---|---|---|---|
|
|
390
|
+
| `x` | `number` | `0` | — | — | — | The column. |
|
|
391
|
+
| `y` | `number` | `0` | — | — | — | The row. |
|
|
392
|
+
| `inside` | `boolean` | `false` | — | — | — | Whether the point was on the map. |
|
|
393
|
+
|
|
394
|
+
```ogt
|
|
395
|
+
struct TileCell {
|
|
396
|
+
doc "A cell of a map."
|
|
397
|
+
field x u32 "The column."
|
|
398
|
+
field y u32 "The row."
|
|
399
|
+
field inside bool "Whether the point was on the map."
|
|
400
|
+
}
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
<sub>`api.ogt` line 6364</sub>
|
|
404
|
+
|
|
405
|
+
## Column kinds
|
|
406
|
+
|
|
407
|
+
Each is a factory, `TilemapAsset(value?, options?)`, that makes one field of a component or resource layout.
|
|
408
|
+
|
|
409
|
+
| Column | Value | Typed array | Stride | Doc |
|
|
410
|
+
|---|---|---|---|---|
|
|
411
|
+
| <a id="column-TilemapAsset"></a>`TilemapAsset` | `TilemapAsset` | `Uint32Array` | 2 | A TilemapAsset handle field. |
|
|
412
|
+
|
|
413
|
+
```ogt
|
|
414
|
+
column TilemapAsset {
|
|
415
|
+
doc "A TilemapAsset handle field."
|
|
416
|
+
array Uint32Array
|
|
417
|
+
stride 2
|
|
418
|
+
value TilemapAsset
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
<sub>`api.ogt` line 6272</sub>
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<!-- Generated from crates/og-api/api.ogt by `og api gen`. Do not edit: `og api check` fails on any difference; change api.ogt and regenerate. -->
|
|
2
|
+
|
|
3
|
+
# The `time` module
|
|
4
|
+
|
|
5
|
+
Simulation time. Game code never reads the wall clock; it reads Time.
|
|
6
|
+
|
|
7
|
+
- **TypeScript**: functions are the namespace `og.time`; components, resources and events are tokens on `og`.
|
|
8
|
+
- **Publish builds**: kept (members may override).
|
|
9
|
+
- **Skill**: `og-feel`, which teaches the module (how much of it to use, and how to prove it).
|
|
10
|
+
- **Index**: [every module and name](index.md).
|
|
11
|
+
|
|
12
|
+
```ogt
|
|
13
|
+
module time {
|
|
14
|
+
# declarations follow, each quoted below
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
<sub>`api.ogt` line 582</sub>
|
|
18
|
+
|
|
19
|
+
## Contents
|
|
20
|
+
|
|
21
|
+
| Name | Kind | Summary |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| [`og.Time`](#record-Time) | resource | The fixed tick's clock. Every value is a function of the tick count, so a replay sees the same numbers. The world keeps the time scale in a second resource, og.TimeScale (`scale`, `hitStop`, and `elapsed`, which is scaledElapsed), set through og.time.setScale and og.time.hitStop; read og.Time, which carries all of it. The probe's `get:og.Time` answers every field here, as a system's `time` does; `set:og.TimeScale.scale=0.5` slows time from a script. |
|
|
24
|
+
| [`og.time.setScale`](#fn-setScale) | function | Set the global time scale (slow motion): physics, og.anim, flipbooks and tweens advance by dt * scale from the system after the call; systems may call it. |
|
|
25
|
+
| [`og.time.hitStop`](#fn-hitStop) | function | Freeze scaled time for `ticks` ticks from now (this tick included): physics, og.anim, flipbooks and scaled tweens hold while input, the UI, unscaled tweens and camera shake keep moving. A longer hit stop in progress is never shortened. Typical values at 60 Hz: 2-3 ticks for a light hit, 4-6 medium, 8-12 heavy, 12-20 a finishing blow (paired with slow motion). |
|
|
26
|
+
|
|
27
|
+
## Functions
|
|
28
|
+
|
|
29
|
+
<a id="fn-setScale"></a>
|
|
30
|
+
|
|
31
|
+
### `og.time.setScale`
|
|
32
|
+
|
|
33
|
+
Set the global time scale (slow motion): physics, og.anim, flipbooks and tweens advance by dt * scale from the system after the call; systems may call it.
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
og.time.setScale(world: World, scale: number): Result<void>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
| Parameter | Type | Optional | Doc |
|
|
40
|
+
|---|---|---|---|
|
|
41
|
+
| `world` | `World` | no | The world. |
|
|
42
|
+
| `scale` | `number` | no | 0 to 10: 1 is normal speed. |
|
|
43
|
+
|
|
44
|
+
**Returns** `Result<void>`: Refused outside 0..10.
|
|
45
|
+
|
|
46
|
+
Binding symbol `og_time_set_scale` · publish builds: kept
|
|
47
|
+
|
|
48
|
+
```ogt
|
|
49
|
+
fn setScale {
|
|
50
|
+
doc "Set the global time scale (slow motion): physics, og.anim, flipbooks and tweens advance by dt * scale from the system after the call; systems may call it."
|
|
51
|
+
param world World "The world."
|
|
52
|
+
param scale f32 "0 to 10: 1 is normal speed."
|
|
53
|
+
returns Result.Void "Refused outside 0..10."
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
<sub>`api.ogt` line 624</sub>
|
|
58
|
+
|
|
59
|
+
<a id="fn-hitStop"></a>
|
|
60
|
+
|
|
61
|
+
### `og.time.hitStop`
|
|
62
|
+
|
|
63
|
+
Freeze scaled time for `ticks` ticks from now (this tick included): physics, og.anim, flipbooks and scaled tweens hold while input, the UI, unscaled tweens and camera shake keep moving. A longer hit stop in progress is never shortened. Typical values at 60 Hz: 2-3 ticks for a light hit, 4-6 medium, 8-12 heavy, 12-20 a finishing blow (paired with slow motion).
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
og.time.hitStop(world: World, ticks: number): Result<void>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
| Parameter | Type | Optional | Doc |
|
|
70
|
+
|---|---|---|---|
|
|
71
|
+
| `world` | `World` | no | The world. |
|
|
72
|
+
| `ticks` | `number` | no | Ticks to hold. |
|
|
73
|
+
|
|
74
|
+
**Returns** `Result<void>`.
|
|
75
|
+
|
|
76
|
+
Binding symbol `og_time_hit_stop` · publish builds: kept
|
|
77
|
+
|
|
78
|
+
```ogt
|
|
79
|
+
fn hitStop {
|
|
80
|
+
doc "Freeze scaled time for `ticks` ticks from now (this tick included): physics, og.anim, flipbooks and scaled tweens hold while input, the UI, unscaled tweens and camera shake keep moving. A longer hit stop in progress is never shortened. Typical values at 60 Hz: 2-3 ticks for a light hit, 4-6 medium, 8-12 heavy, 12-20 a finishing blow (paired with slow motion)."
|
|
81
|
+
param world World "The world."
|
|
82
|
+
param ticks u32 "Ticks to hold."
|
|
83
|
+
returns Result.Void
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
<sub>`api.ogt` line 631</sub>
|
|
88
|
+
|
|
89
|
+
## Components, resources and events
|
|
90
|
+
|
|
91
|
+
<a id="record-Time"></a>
|
|
92
|
+
|
|
93
|
+
### `og.Time` (resource)
|
|
94
|
+
|
|
95
|
+
The fixed tick's clock. Every value is a function of the tick count, so a replay sees the same numbers. The world keeps the time scale in a second resource, og.TimeScale (`scale`, `hitStop`, and `elapsed`, which is scaledElapsed), set through og.time.setScale and og.time.hitStop; read og.Time, which carries all of it. The probe's `get:og.Time` answers every field here, as a system's `time` does; `set:og.TimeScale.scale=0.5` slows time from a script.
|
|
96
|
+
|
|
97
|
+
Token `og.Time`, registered under the schema name `og.Time`; its value type is `Time`.
|
|
98
|
+
|
|
99
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
100
|
+
|---|---|---|---|---|---|---|
|
|
101
|
+
| `tick` | `number` | `0` | — | `ticks` | read only | Fixed steps taken since load. |
|
|
102
|
+
| `dt` | `number` | `0` | — | `s` | read only | The length of one tick: 1 / rate. |
|
|
103
|
+
| `elapsed` | `number` | `0` | — | `s` | read only | Simulation time since load: tick * dt. |
|
|
104
|
+
| `rate` | `number` | `0` | — | `hz` | read only | The tick rate, from GameDesc.tick. |
|
|
105
|
+
| `scale` | `number` | `1` | 0 … 10 | — | read only | Global slow motion, set with og.time.setScale: 1 is normal, 0.5 half speed, 0 stopped. Physics, animation, flipbooks and tweens advance by scaledDt; the tick itself, the UI, input and the probe keep their pace. |
|
|
106
|
+
| `hitStop` | `number` | `0` | — | `ticks` | read only | Ticks of hit stop left (og.time.hitStop): while above 0, scaledDt is 0. |
|
|
107
|
+
| `scaledDt` | `number` | `0` | — | `s` | read only | This tick's scaled length: 0 during a hit stop, else dt * scale. Move gameplay by it so slow motion and hit stop reach game code too. |
|
|
108
|
+
| `scaledElapsed` | `number` | `0` | — | `s` | read only | Scaled seconds since load: the sum of every finished tick's scaledDt. |
|
|
109
|
+
|
|
110
|
+
```ogt
|
|
111
|
+
resource Time {
|
|
112
|
+
doc "The fixed tick's clock. Every value is a function of the tick count, so a replay sees the same numbers. The world keeps the time scale in a second resource, og.TimeScale (`scale`, `hitStop`, and `elapsed`, which is scaledElapsed), set through og.time.setScale and og.time.hitStop; read og.Time, which carries all of it. The probe's `get:og.Time` answers every field here, as a system's `time` does; `set:og.TimeScale.scale=0.5` slows time from a script."
|
|
113
|
+
field tick u32 "Fixed steps taken since load." {
|
|
114
|
+
readonly true
|
|
115
|
+
unit ticks
|
|
116
|
+
}
|
|
117
|
+
field dt f32 "The length of one tick: 1 / rate." {
|
|
118
|
+
readonly true
|
|
119
|
+
unit s
|
|
120
|
+
}
|
|
121
|
+
field elapsed f64 "Simulation time since load: tick * dt." {
|
|
122
|
+
readonly true
|
|
123
|
+
unit s
|
|
124
|
+
}
|
|
125
|
+
field rate u32 "The tick rate, from GameDesc.tick." {
|
|
126
|
+
readonly true
|
|
127
|
+
unit hz
|
|
128
|
+
}
|
|
129
|
+
field scale f32 "Global slow motion, set with og.time.setScale: 1 is normal, 0.5 half speed, 0 stopped. Physics, animation, flipbooks and tweens advance by scaledDt; the tick itself, the UI, input and the probe keep their pace." {
|
|
130
|
+
readonly true
|
|
131
|
+
default 1
|
|
132
|
+
min 0
|
|
133
|
+
max 10
|
|
134
|
+
}
|
|
135
|
+
field hitStop u32 "Ticks of hit stop left (og.time.hitStop): while above 0, scaledDt is 0." {
|
|
136
|
+
readonly true
|
|
137
|
+
unit ticks
|
|
138
|
+
}
|
|
139
|
+
field scaledDt f32 "This tick's scaled length: 0 during a hit stop, else dt * scale. Move gameplay by it so slow motion and hit stop reach game code too." {
|
|
140
|
+
readonly true
|
|
141
|
+
unit s
|
|
142
|
+
}
|
|
143
|
+
field scaledElapsed f64 "Scaled seconds since load: the sum of every finished tick's scaledDt." {
|
|
144
|
+
readonly true
|
|
145
|
+
unit s
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
<sub>`api.ogt` line 586</sub>
|