{"bugs":{"url":"https://github.com/antvis/g/issues"},"dist":{"shasum":"92a57421839e1088bc2bea85e7e94ee973486684","tarball":"https://registry.npmjs.org/@antv/g-ecs/-/g-ecs-1.0.0-alpha.9.tgz","fileCount":20,"integrity":"sha512-UVPuSVPQj9zfWPPCF+F7vLZIJtTCtjPGWl6MnIsEEsAuu9YESrwf1E6Olwzu1rNbo0rNOoD82Hvh5XwQ4Ekv6w==","signatures":[{"sig":"MEQCIAE/68BFTOVqGRXC1CS5HeJ3laavXEyg5C4BlG3fvV7pAiAVPOt8djRti5uKIWxKSOMfexHLrUAjJWLrebumjnKXog==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":194255},"main":"dist/index.js","name":"@antv/g-ecs","types":"dist/index.d.ts","author":{"name":"https://github.com/orgs/antvis/people"},"module":"dist/index.esm.js","readme":"English | [简体中文](./README-zh_CN.md)\n\n# g-ecs\n\n[![](https://img.shields.io/travis/antvis/g-ecs.svg)](https://travis-ci.org/antvis/g-ecs)\n![](https://img.shields.io/badge/language-javascript-red.svg)\n![](https://img.shields.io/badge/license-MIT-000000.svg)\n\n- a simple ECS implement for G\n\n## Architecture\n\nA typical ECS architecture(borrow from ecsy), we use `Matcher` instead of `Query`:\n\n![](https://blog.mozvr.com/content/images/2019/10/ECSY-Architecture.svg)\n\n## Usage\n\n```javascript\nimport { Container } from 'inversify';\nimport { Component, System, World, containerModule } from '@antv/g-ecs';\n\n// create a container\nconst container = new Container();\n// load ECS module\ncontainer.load(containerModule);\n\n// create a world\nconst world = container.get(World);\n\n// register components\nclass C1 extends Component {\n  static tag = 'c1';\n  p1: number;\n}\nclass C2 extends Component {\n  static tag = 'c2';\n}\nclass C3 extends Component {\n  static tag = 'c3';\n}\nworld.registerComponent(C1).registerComponent(C2).registerComponent(C3);\n\n// register systems\nclass S1 extends System {\n  static tag = 's1';\n\n  trigger() {\n    return new Matcher().allOf(C1);\n  }\n\n  execute(entities: Entity[]) {\n    entities.forEach((entity) => {\n      const c1 = entity.getComponent(C1);\n      c1.p1++;\n    });\n  }\n}\nworld.registerSystem(S1);\n\n// create an entity\nconst entity = world.createEntity();\nentity.addComponent(C1, { p1: 2 }).addComponent(C2).addComponent(C3);\n\n// make a loop\nlet lastTime = performance.now();\nconst run = () => {\n  const time = performance.now();\n  const delta = time - lastTime;\n  // run all the systems\n  world.execute(delta, time);\n\n  lastTime = time;\n  requestAnimationFrame(run);\n};\nrun();\n```\n\n## World\n\nA world is the container of ECS. We get a world from container instead of creating it manually.\n\n```javascript\nimport { Container } from 'inversify';\nimport { World, containerModule } from '@antv/g-ecs';\n\n// create a container\nconst container = new Container();\n// load ECS module\ncontainer.load(containerModule);\n\n// create a world\nconst world = container.get(World);\n```\n\n### createEntity\n\nCreate a new entity:\n\n```javascript\nconst entity = world.createEntity();\n```\n\n### registerComponent\n\n```javascript\nclass C1 extends Component {\n  static tag = 'c1';\n  p1: number;\n}\nclass C2 extends Component {\n  static tag = 'c2';\n}\nclass C3 extends Component {\n  static tag = 'c3';\n}\nworld.registerComponent(C1).registerComponent(C2).registerComponent(C3);\n```\n\n### registerSystem\n\n```javascript\nclass S1 extends System {\n  static tag = 's1';\n\n  trigger() {\n    return new Matcher().allOf(C1);\n  }\n\n  execute(entities: Entity[]) {\n    entities.forEach((entity) => {\n      const c1 = entity.getComponent(C1);\n      c1.p1++;\n    });\n  }\n}\nworld.registerSystem(S1);\n```\n\n## Entitiy\n\n### addComponent\n\nWe can add a component and its initial data to an entity:\n\n```javascript\nentity.addComponent(C1, { p1: 2 }).addComponent(C2).addComponent(C3);\n```\n\n### removeComponent\n\nWe can remove a component from an entity:\n\n```javascript\nentity.removeComponent(C1);\n```\n\n## Component\n\n## System\n\n## See also\n\n- [ecsy](https://blog.mozvr.com/introducing-ecsy/)\n- [Entitas](https://github.com/sschmid/Entitas-CSharp)\n- [EntitasCookBook](https://github.com/mzaks/EntitasCookBook)\n","gitHead":"e2b8bc287c7faa181013d9e5df071ff97d702c94","license":"MIT","_npmUser":{"name":"panyuqi","email":"pyqiverson@gmail.com"},"homepage":"https://github.com/antvis/g#readme","keywords":["util","antv","g"],"repository":{"url":"git+https://github.com/antvis/g.git","type":"git"},"_npmVersion":"lerna/3.22.1/node@v14.17.5+x64 (darwin)","description":"A simple ECS implement","directories":{},"maintainers":[{"name":"freestyle21","email":"675861708@qq.com"},{"name":"soundquiet","email":"fulingsun515@gmail.com"},{"name":"elaine.q.10","email":"yilin.qyl@antfin.com"},{"name":"sturuby","email":"xingya.shi@gmail.com"},{"name":"lviser","email":"liuvigongzuoshi@gmail.com"},{"name":"sakuya223","email":"360965398@qq.com"},{"name":"serializedowen","email":"wjh199455@gmail.com"},{"name":"xdzhao","email":"zhaoxiaodong@zju.edu.cn"},{"name":"yangzhanmei","email":"15809244435@163.com"},{"name":"wjgogogo","email":"906626481@qq.com"},{"name":"leungwensen","email":"leungwensen@gmail.com"},{"name":"dori","email":"418466938@qq.com"},{"name":"iaaron","email":"943720372@qq.com"},{"name":"yard","email":"zjwengyidong@outlook.com"},{"name":"simaq","email":"sima.zhang1990@gmail.com"},{"name":"dxq613","email":"dxq613@gmail.com"},{"name":"intchous","email":"h.a.p.p.y.y.x.d@163.com"},{"name":"susan_ann","email":"lisuwe_n@163.com"},{"name":"jinke.li","email":"1359518268@qq.com"},{"name":"lzxue","email":"120635640@qq.com"},{"name":"army8735","email":"army8735@qq.com"},{"name":"atool","email":"i@hust.cc"},{"name":"baizn","email":"576375879@qq.com"},{"name":"dengfuping","email":"dengfuping_develop@163.com"},{"name":"neoddish","email":"neoddish@outlook.com"},{"name":"jeffy2012","email":"yuanjiefeng@gmail.com"},{"name":"zqlu","email":"zqlu.cn@gmail.com"},{"name":"afc163","email":"afc163@gmail.com"},{"name":"pomelo-nwu","email":"czynwu@gmail.com"},{"name":"kopiluwaky","email":"yanyanwang93@gmail.com"},{"name":"ccnuzindex","email":"ccnuzindex@gmail.com"},{"name":"panyuqi","email":"pyqiverson@gmail.com"},{"name":"bubkoo","email":"bubkoo.wy@gmail.com"},{"name":"zengyue","email":"yezengyue@gmail.com"},{"name":"kasmine","email":"736929286@qq.com"},{"name":"boyu.zlj","email":"boyu.zlj@antfin.com"},{"name":"l1ud0ngq1","email":"lliudongqi@gmail.com"},{"name":"newbyvector","email":"vectorse@126.com"},{"name":"winniexing","email":"wanyingxing@gmail.com"},{"name":"chenluli","email":"chenluuli@gmail.com"},{"name":"kn9117","email":"1175863618@qq.com"},{"name":"xdddst","email":"deng25st@163.com"},{"name":"semious2020","email":"semious@163.com"},{"name":"esora","email":"tygyh2012@gmail.com"},{"name":"nadia_liu","email":"1803275951@qq.com"},{"name":"bbsqq","email":"1491812683@qq.com"},{"name":"mxz96102","email":"mxz96102@qq.com"},{"name":"openwayne","email":"openwayne@gmail.com"},{"name":"pearmini","email":"subairui@icloud.com"},{"name":"pddpd","email":"pddpengdi@gmail.com"},{"name":"yiqianyao","email":"2912401452@qq.com"},{"name":"zhanba","email":"c5e1856@gmail.com"},{"name":"cxxxxxn","email":"christy05.chen@gmail.com"}],"_nodeVersion":"14.17.5","dependencies":{"inversify":"^5.0.1","eventemitter3":"^4.0.0","reflect-metadata":"^0.1.13"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"webpack":"^4.39.3","@types/jest":"^25.0.0","npm-run-all":"^4.1.5","webpack-cli":"^3.3.7","@types/lodash":"^4.14.138"},"_npmOperationalInternal":{"tmp":"tmp/g-ecs_1.0.0-alpha.9_1636103543894_0.7951157621672642","host":"s3://npm-registry-packages"},"_id":"@antv/g-ecs@1.0.0-alpha.9","version":"1.0.0-alpha.9"}