1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-12-26 22:31:14 +00:00

ecs: yaml?

This commit is contained in:
Steven Hugg 2022-01-27 18:02:37 -06:00
parent 44ffa5e988
commit b0810a2f66
3 changed files with 127 additions and 61 deletions

168
package-lock.json generated
View File

@ -11,16 +11,17 @@
"dependencies": { "dependencies": {
"@types/chroma-js": "^2.1.3", "@types/chroma-js": "^2.1.3",
"@types/emscripten": "^1.39.5", "@types/emscripten": "^1.39.5",
"@types/js-yaml": "^4.0.5",
"@wasmer/wasi": "^0.12.0", "@wasmer/wasi": "^0.12.0",
"@wasmer/wasmfs": "^0.12.0", "@wasmer/wasmfs": "^0.12.0",
"binaryen": "^101.0.0", "binaryen": "^101.0.0",
"chroma-js": "^2.1.2", "chroma-js": "^2.1.2",
"chromedriver": "^97.0.1",
"clipboard": "^2.0.6", "clipboard": "^2.0.6",
"error-stack-parser": "^2.0.6", "error-stack-parser": "^2.0.6",
"fast-png": "^5.0.4", "fast-png": "^5.0.4",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"jquery": "^3.6.0", "jquery": "^3.6.0",
"js-yaml": "^4.1.0",
"jszip": "^3.7.0", "jszip": "^3.7.0",
"localforage": "^1.9.0", "localforage": "^1.9.0",
"mousetrap": "^1.6.5", "mousetrap": "^1.6.5",
@ -399,6 +400,11 @@
"@types/sizzle": "*" "@types/sizzle": "*"
} }
}, },
"node_modules/@types/js-yaml": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.5.tgz",
"integrity": "sha512-FhpRzf927MNQdRZP0J5DLIdTXhjLYzeUTmLAu69mnVksLH9CJY3IuSeEgbKUki7GQZm0WqDkGzyxju2EZGD2wA=="
},
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "14.18.9", "version": "14.18.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.9.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.9.tgz",
@ -589,13 +595,9 @@
"optional": true "optional": true
}, },
"node_modules/argparse": { "node_modules/argparse": {
"version": "1.0.10", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
"optional": true,
"dependencies": {
"sprintf-js": "~1.0.2"
}
}, },
"node_modules/array-equal": { "node_modules/array-equal": {
"version": "1.0.0", "version": "1.0.0",
@ -3152,13 +3154,11 @@
"optional": true "optional": true
}, },
"node_modules/js-yaml": { "node_modules/js-yaml": {
"version": "3.13.1", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
"optional": true,
"dependencies": { "dependencies": {
"argparse": "^1.0.7", "argparse": "^2.0.1"
"esprima": "^4.0.0"
}, },
"bin": { "bin": {
"js-yaml": "bin/js-yaml.js" "js-yaml": "bin/js-yaml.js"
@ -3826,12 +3826,6 @@
"url": "https://github.com/chalk/ansi-styles?sponsor=1" "url": "https://github.com/chalk/ansi-styles?sponsor=1"
} }
}, },
"node_modules/mocha/node_modules/argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"dev": true
},
"node_modules/mocha/node_modules/camelcase": { "node_modules/mocha/node_modules/camelcase": {
"version": "6.3.0", "version": "6.3.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz",
@ -4003,18 +3997,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/mocha/node_modules/js-yaml": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
"dev": true,
"dependencies": {
"argparse": "^2.0.1"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
}
},
"node_modules/mocha/node_modules/locate-path": { "node_modules/mocha/node_modules/locate-path": {
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
@ -4333,6 +4315,15 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/nightwatch/node_modules/argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"optional": true,
"dependencies": {
"sprintf-js": "~1.0.2"
}
},
"node_modules/nightwatch/node_modules/chalk": { "node_modules/nightwatch/node_modules/chalk": {
"version": "2.4.2", "version": "2.4.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
@ -4369,6 +4360,19 @@
"ms": "^2.1.1" "ms": "^2.1.1"
} }
}, },
"node_modules/nightwatch/node_modules/js-yaml": {
"version": "3.13.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
"optional": true,
"dependencies": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
}
},
"node_modules/nightwatch/node_modules/log-symbols": { "node_modules/nightwatch/node_modules/log-symbols": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz",
@ -4677,6 +4681,28 @@
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/nyc/node_modules/argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"optional": true,
"dependencies": {
"sprintf-js": "~1.0.2"
}
},
"node_modules/nyc/node_modules/js-yaml": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
"optional": true,
"dependencies": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
}
},
"node_modules/nyc/node_modules/rimraf": { "node_modules/nyc/node_modules/rimraf": {
"version": "2.7.1", "version": "2.7.1",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
@ -7212,6 +7238,11 @@
"@types/sizzle": "*" "@types/sizzle": "*"
} }
}, },
"@types/js-yaml": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.5.tgz",
"integrity": "sha512-FhpRzf927MNQdRZP0J5DLIdTXhjLYzeUTmLAu69mnVksLH9CJY3IuSeEgbKUki7GQZm0WqDkGzyxju2EZGD2wA=="
},
"@types/node": { "@types/node": {
"version": "14.18.9", "version": "14.18.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.9.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.9.tgz",
@ -7368,13 +7399,9 @@
"optional": true "optional": true
}, },
"argparse": { "argparse": {
"version": "1.0.10", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
"optional": true,
"requires": {
"sprintf-js": "~1.0.2"
}
}, },
"array-equal": { "array-equal": {
"version": "1.0.0", "version": "1.0.0",
@ -9329,13 +9356,11 @@
"optional": true "optional": true
}, },
"js-yaml": { "js-yaml": {
"version": "3.13.1", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
"optional": true,
"requires": { "requires": {
"argparse": "^1.0.7", "argparse": "^2.0.1"
"esprima": "^4.0.0"
} }
}, },
"jsbn": { "jsbn": {
@ -9898,12 +9923,6 @@
"color-convert": "^2.0.1" "color-convert": "^2.0.1"
} }
}, },
"argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"dev": true
},
"camelcase": { "camelcase": {
"version": "6.3.0", "version": "6.3.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz",
@ -10023,15 +10042,6 @@
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
"dev": true "dev": true
}, },
"js-yaml": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
"dev": true,
"requires": {
"argparse": "^2.0.1"
}
},
"locate-path": { "locate-path": {
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
@ -10262,6 +10272,15 @@
"color-convert": "^1.9.0" "color-convert": "^1.9.0"
} }
}, },
"argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"optional": true,
"requires": {
"sprintf-js": "~1.0.2"
}
},
"chalk": { "chalk": {
"version": "2.4.2", "version": "2.4.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
@ -10293,6 +10312,16 @@
"ms": "^2.1.1" "ms": "^2.1.1"
} }
}, },
"js-yaml": {
"version": "3.13.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
"optional": true,
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
}
},
"log-symbols": { "log-symbols": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz",
@ -10549,6 +10578,25 @@
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
"optional": true "optional": true
}, },
"argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"optional": true,
"requires": {
"sprintf-js": "~1.0.2"
}
},
"js-yaml": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
"optional": true,
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
}
},
"rimraf": { "rimraf": {
"version": "2.7.1", "version": "2.7.1",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",

View File

@ -12,6 +12,7 @@
"dependencies": { "dependencies": {
"@types/chroma-js": "^2.1.3", "@types/chroma-js": "^2.1.3",
"@types/emscripten": "^1.39.5", "@types/emscripten": "^1.39.5",
"@types/js-yaml": "^4.0.5",
"@wasmer/wasi": "^0.12.0", "@wasmer/wasi": "^0.12.0",
"@wasmer/wasmfs": "^0.12.0", "@wasmer/wasmfs": "^0.12.0",
"binaryen": "^101.0.0", "binaryen": "^101.0.0",
@ -21,6 +22,7 @@
"fast-png": "^5.0.4", "fast-png": "^5.0.4",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"jquery": "^3.6.0", "jquery": "^3.6.0",
"js-yaml": "^4.1.0",
"jszip": "^3.7.0", "jszip": "^3.7.0",
"localforage": "^1.9.0", "localforage": "^1.9.0",
"mousetrap": "^1.6.5", "mousetrap": "^1.6.5",

View File

@ -1,9 +1,13 @@
import * as YAML from "js-yaml";
// entity scopes contain entities, and are nested // entity scopes contain entities, and are nested
// also contain segments (code, bss, rodata) // also contain segments (code, bss, rodata)
// components and systems are global // components and systems are global
// component fields are stored in arrays, range of entities, can be bit-packed // component fields are stored in arrays, range of entities, can be bit-packed
// some values can be constant, are stored in rodata (or loaded immediate) // some values can be constant, are stored in rodata (or loaded immediate)
// optional components? on or off
// union components? either X or Y or Z...
// //
// systems receive and send events, execute code on entities // systems receive and send events, execute code on entities
// systems are generated on a per-scope basis // systems are generated on a per-scope basis
@ -649,6 +653,12 @@ export class EntityManager {
} }
} }
} }
toYAML() {
return YAML.dump({
components: this.components,
systems: this.systems,
})
}
} }
/// ///
@ -894,7 +904,11 @@ function test() {
name: 'sprite', fields: [ name: 'sprite', fields: [
{ name: 'height', dtype: 'int', lo: 0, hi: 255 }, { name: 'height', dtype: 'int', lo: 0, hi: 255 },
{ name: 'plyrindex', dtype: 'int', lo: 0, hi: 1 }, { name: 'plyrindex', dtype: 'int', lo: 0, hi: 1 },
{ name: 'nusiz', dtype: 'int', lo: 0, hi: 15 }, ]
})
let c_plyrflags = em.defineComponent({
name: 'nusizable', fields: [
{ name: 'plyrflags', dtype: 'int', lo: 0, hi: 63 },
] ]
}) })
let c_player = em.defineComponent({ let c_player = em.defineComponent({
@ -1048,8 +1062,10 @@ function test() {
root.generateCode(); root.generateCode();
root.dump(src); root.dump(src);
console.log(src.toString()); console.log(src.toString());
//console.log(em.toYAML());
} }
// TODO: files in markdown? // TODO: files in markdown?
test(); test();