game-data-gen 3.0.0 → 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.
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(value: Array<Entity>) {
88
- activeEntities = value
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(value: Array<number>) {
93
- activeEntityIds = value
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(value: number) {
98
- playerId = value
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(index: number) {
231
- zeroEntity(entities[index])
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(idx: number) {
247
- type[idx] = ""
248
- zeroVector(pos[idx])
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/lib/soa.js CHANGED
@@ -21,13 +21,13 @@ function addFieldDefinition(field, length, output) {
21
21
  const [fieldName, fieldType] = field.split(" ");
22
22
  switch (fieldType) {
23
23
  case ArrayType.STRING:
24
- output.push(`export const ${fieldName} = new Array(${length}).fill("")`);
24
+ output.push(`export const ${fieldName} = new Array<string>(${length}).fill("")`);
25
25
  break;
26
26
  case ArrayType.NUMBER:
27
- output.push(`export const ${fieldName} = new Array(${length}).fill(0)`);
27
+ output.push(`export const ${fieldName} = new Array<number>(${length}).fill(0)`);
28
28
  break;
29
29
  case ArrayType.BOOLEAN:
30
- output.push(`export const ${fieldName} = new Array(${length}).fill(false)`);
30
+ output.push(`export const ${fieldName} = new Array<boolean>(${length}).fill(false)`);
31
31
  break;
32
32
  default:
33
33
  output.push(`export const ${fieldName} = Array.from({ length: ${length} }, create${capitalize(fieldType)})`);
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 lines = block.split("\n");
24
- const header = (_a = lines.shift()) === null || _a === void 0 ? void 0 : _a.replace(/^#\s*/, "");
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:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "game-data-gen",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"