game-data-gen 3.0.0 → 3.0.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/README.md +15 -11
- package/dist/main.js +5 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,15 +39,18 @@ For example `src/data.md`:
|
|
|
39
39
|
|
|
40
40
|
```md
|
|
41
41
|
# game group
|
|
42
|
+
|
|
42
43
|
- activeEntities array entity
|
|
43
44
|
- activeEntityIds array number
|
|
44
45
|
- playerId number
|
|
45
46
|
|
|
46
47
|
# vector struct
|
|
48
|
+
|
|
47
49
|
- x number
|
|
48
50
|
- y number
|
|
49
51
|
|
|
50
52
|
# entity struct
|
|
53
|
+
|
|
51
54
|
- position vector
|
|
52
55
|
- velocity vector
|
|
53
56
|
<!-- stats -->
|
|
@@ -60,6 +63,7 @@ For example `src/data.md`:
|
|
|
60
63
|
# entities aos 2048 entity
|
|
61
64
|
|
|
62
65
|
# particle soa 10_000
|
|
66
|
+
|
|
63
67
|
- type string
|
|
64
68
|
- pos Vector
|
|
65
69
|
```
|
|
@@ -84,18 +88,18 @@ export let activeEntityIds = new Array<number>()
|
|
|
84
88
|
export let playerId = 0
|
|
85
89
|
|
|
86
90
|
/** Set the value of the activeEntities field within the game group. */
|
|
87
|
-
export function setActiveEntities(
|
|
88
|
-
activeEntities =
|
|
91
|
+
export function setActiveEntities(v: Array<Entity>) {
|
|
92
|
+
activeEntities = v
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
/** Set the value of the activeEntityIds field within the game group. */
|
|
92
|
-
export function setActiveEntityIds(
|
|
93
|
-
activeEntityIds =
|
|
96
|
+
export function setActiveEntityIds(v: Array<number>) {
|
|
97
|
+
activeEntityIds = v
|
|
94
98
|
}
|
|
95
99
|
|
|
96
100
|
/** Set the value of the playerId field within the game group. */
|
|
97
|
-
export function setPlayerId(
|
|
98
|
-
playerId =
|
|
101
|
+
export function setPlayerId(v: number) {
|
|
102
|
+
playerId = v
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
/** Zero the activeEntities field within the game group. */
|
|
@@ -227,8 +231,8 @@ export function zeroEntities() {
|
|
|
227
231
|
}
|
|
228
232
|
|
|
229
233
|
/** Zero an object at a specific index within the entities array of structures. */
|
|
230
|
-
export function zeroEntitiesAt(
|
|
231
|
-
zeroEntity(entities[
|
|
234
|
+
export function zeroEntitiesAt(i: number) {
|
|
235
|
+
zeroEntity(entities[i])
|
|
232
236
|
}
|
|
233
237
|
|
|
234
238
|
/*
|
|
@@ -243,9 +247,9 @@ export const type = new Array(10_000).fill("")
|
|
|
243
247
|
export const pos = Array.from({ length: 10_000 }, createVector)
|
|
244
248
|
|
|
245
249
|
/** Zero an index within the particle structure of arrays. */
|
|
246
|
-
export function zeroParticle(
|
|
247
|
-
type[
|
|
248
|
-
zeroVector(pos[
|
|
250
|
+
export function zeroParticle(i: number) {
|
|
251
|
+
type[i] = ""
|
|
252
|
+
zeroVector(pos[i])
|
|
249
253
|
}
|
|
250
254
|
|
|
251
255
|
/** Zero the type field within the particle structure of arrays. */
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var _a;
|
|
3
2
|
import fs from "node:fs";
|
|
4
3
|
import { Type } from "./consts.js";
|
|
5
4
|
import { addArrayOfStructures } from "./lib/aos.js";
|
|
@@ -14,17 +13,19 @@ output.push("/*");
|
|
|
14
13
|
output.push(` * Generated with game-data-gen on ${new Date().toLocaleString()}. DO NOT MODIFY THIS FILE!`);
|
|
15
14
|
output.push(" */");
|
|
16
15
|
const blocks = input
|
|
16
|
+
.replace(/^# (.+)\n\n- /gm, "$1\n")
|
|
17
|
+
.replace(/^# /gm, "")
|
|
18
|
+
.replace(/^- /gm, "")
|
|
17
19
|
.split("\n")
|
|
18
20
|
.filter((line) => !line.startsWith("<!--"))
|
|
19
21
|
.join("\n")
|
|
20
22
|
.trim()
|
|
21
23
|
.split("\n\n");
|
|
22
24
|
for (const block of blocks) {
|
|
23
|
-
const
|
|
24
|
-
const header =
|
|
25
|
+
const fields = block.split("\n");
|
|
26
|
+
const header = fields.shift();
|
|
25
27
|
if (!header)
|
|
26
28
|
continue;
|
|
27
|
-
const fields = lines.map((line) => line.replace(/^-\s*/, ""));
|
|
28
29
|
const [_, type] = header.split(" ");
|
|
29
30
|
switch (type) {
|
|
30
31
|
case Type.STRUCT:
|