-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
218 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
.eslintcache | ||
lib | ||
build | ||
dist | ||
node_modules | ||
.reports | ||
*.log | ||
*.cpuprofile | ||
.rollup.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# piecs | ||
PIECS is an entity component system with some batteries included, some not. | ||
|
||
This project is very much a work in progress, everything is subject to change. | ||
|
||
You propably know what an ECS is, if not: https://en.wikipedia.org/wiki/Entity_component_system | ||
|
||
Most of the concepts used in this ECS implementation is not new, but I couldn't find an ecs with the feature set, DX and performance I wanted, so here's my attempt at an ECS interpretation and implementation. | ||
|
||
## Noteable Features | ||
|
||
- Virtually no garbage collecting | ||
- Prefabrication of archetypes | ||
- Defering: Defer whatever you want to the end of an update cycle | ||
- DX: | ||
- Implement in Typescript | ||
- Helpful error messages | ||
- Minimal, easy to understand api | ||
- Register systems: No need to invoke them explicitly | ||
- Add systems/queries/prefabs/components whenever you want. The only requirement is that the world is initialized once before the first update. | ||
- BYO (Bring Your Own) Component sets: Might add an optional component manager/store in the future, but you may keep track of component values however you choose. However, there's propably no clean abstraction to component sets that doesn't tank the performance in javascript and serves all use-cases. | ||
|
||
## Api | ||
|
||
TODO | ||
|
||
### World.initialize() | ||
|
||
`world.initialize(): void` | ||
|
||
Initialize must be done once before the first update. Safe to call multiple times, but does nothing if the world is already initialized. | ||
Initialize serves only one purpose: to ensure unique archetypes in each query by only testing each archetype vs each query once. | ||
This enables a less complex and faster query system. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,23 +2,25 @@ | |
"name": "piecs", | ||
"version": "0.1.0", | ||
"description": "PIECS is an entity component system with some batteries included", | ||
"main": "./lib/index.js", | ||
"types": "./lib/index.d.ts", | ||
"type": "module", | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"lib" | ||
"dist" | ||
], | ||
"repository": "[email protected]:sondresj/piecs.git", | ||
"author": "Sondre <[email protected]>", | ||
"license": "MIT", | ||
"private": true, | ||
"private": false, | ||
"keywords": [ | ||
"ecs" | ||
], | ||
"scripts": { | ||
"clean": "rm -rf lib", | ||
"clean": "rm -rf dist build .reports", | ||
"test": "jest", | ||
"build": "tsc", | ||
"bench": "yarn build && cross-env NODE_ENV=production node performance/bench.mjs >> result.log", | ||
"build": "tsc -p tsconfig.build.json && tsc -p tsconfig.declaration.json && rollup -c", | ||
"bench": "yarn build && cross-env NODE_ENV=production node performance/bench.mjs >> result.log", | ||
"profile": "yarn build && cross-env NODE_ENV=production node --cpu-prof --trace-deopt performance/bench.mjs >> result.log", | ||
"prepare": "yarn clean && yarn build", | ||
"prepublishOnly": "yarn test --no-color" | ||
|
@@ -27,9 +29,6 @@ | |
"preset": "ts-jest", | ||
"testEnvironment": "node", | ||
"coverageDirectory": ".reports", | ||
"transformIgnorePatterns": [ | ||
"/node_modules/(?!asm-piecs)" | ||
], | ||
"testMatch": [ | ||
"**/__tests__/**/*.ts" | ||
], | ||
|
@@ -52,8 +51,12 @@ | |
"eslint-plugin-import": "^2.24.2", | ||
"jest": "^27.1.0", | ||
"jest-junit": "^12.2.0", | ||
"rollup": "^2.58.0", | ||
"rollup-plugin-dts": "^4.0.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"ts-jest": "^27.0.5", | ||
"ts-node": "^10.2.1", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.4.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { terser } from 'rollup-plugin-terser' | ||
import dts from 'rollup-plugin-dts' | ||
|
||
const outDir = 'dist' | ||
|
||
export default [{ | ||
input: 'build/index.js', | ||
output: [{ | ||
file: `${outDir}/index.mjs`, | ||
format: 'esm', | ||
}, { | ||
file: `${outDir}/index.cjs`, | ||
format: 'cjs', | ||
generatedCode: { consBindings: true } | ||
}, { | ||
file: `${outDir}/index.min.js`, | ||
format: 'es', | ||
plugins: [terser()] | ||
}] | ||
}, { | ||
input: 'build/index.d.ts', | ||
output: { | ||
file: `${outDir}/index.d.ts`, | ||
format: 'es' | ||
}, | ||
plugins: [dts()] | ||
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
import { World } from './World' | ||
|
||
export type { Query } from './Query' | ||
export { and, or, not, any, all, prefab, query } from './Query' | ||
export type { WorldStatistics } from './utils' | ||
export { getStatistics } from './utils' | ||
export type { Archetype } from './Archetype' | ||
export type { System } from './types' | ||
export { World } | ||
export default World | ||
export { World } from './World' | ||
export { and, or, not, any, all, prefab, query } from './Query' | ||
export { getStatistics } from './utils' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"incremental": false, | ||
"declaration": false, | ||
"removeComments": true, | ||
"sourceMap": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"incremental": false, | ||
"declaration": true, | ||
"emitDeclarationOnly": true, | ||
"removeComments": false, | ||
"sourceMap": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.