{"bugs":{"url":"https://github.com/antvis/g/issues"},"dist":{"shasum":"4588efa59f1c20b5669076ee4c65d020918c98e3","tarball":"https://registry.npmjs.org/@antv/g-ecs/-/g-ecs-1.0.0-alpha.4.tgz","fileCount":18,"integrity":"sha512-TgyWm4ZB0ah+kgdbt2gc/gnyfLpbCenDYd/3CUVchy0xmkM9pb2VQJASYIYhQfGuUHwWEWzw54+gQVtOGN86GQ==","signatures":[{"sig":"MEUCIA8z8WMDPGnEi7z/H3VkB+cWPMlhtecP6aExjQZk2N8PAiEA4qfWrEv/gSEMfhisQkobXTKmueraMMW7bprzdE6g1BE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":66970,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhNXaqCRA9TVsSAnZWagAARFcP/jTlT48I8Us5BuKkxmWA\n6M8gaOltwBwKN0yBo2cn9tQtPE16uEiZALUMylWgIQ5qfn8i0ChEsEztw+td\nwaF1twOGlSaqKJIKPpTuxAJOeee+b+N381uyK8+UuHWCtPyPBO6B0CcQW+am\nBVDF19ZC0qi6y/jyT4uVNaZiD0+bFvUisDb+aS/DFIvxinImjIWf6ShToGWL\nHYkICWkhIRIHxLuqzRWk4WfCOCncA1BVY8QVCIsEqclWlDrJiVPLc1E1oc+R\nNAOss3sQ1P3INnGgeD0KkN/T5Dg3bh0NlhhbEIR2CcjiaIG4zadL+KE11m3Z\niTZXydVvQ7UyIVibFhhybnOivZKkuqdVGdugOgs77U95g0t319kbJFbMTYxB\nh5xbrvC+ykHGinvjGaSRs3BU4IvZlsFfTzXVuHuMPqdCA33qerhN9Y9oNYdK\n5efIEs5P/fhyp4XxjF4xJe1yqLdnvi7uVczYaOLZA1TTJXQl/CGmET0ppDhI\nh205OOO1Ho+KejForE6i8L39y9Ed7ozWBZpubL72mI7LsqluXsla4IOP0+il\nH4X1Lb0RTClOYzAMiiuT0qUtwkAM3IzWuHhfGT4bUay0/00II7mF4wB9xJzc\n7vuI3bWmJKqZS6B/uwqeOLMRdHEzIjYyEAo+zzMKZyICRC9EiOlSFJuhHtRD\nDyWa\r\n=JH0U\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","name":"@antv/g-ecs","types":"dist/index.d.ts","unpkg":"dist/index.umd.min.js","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","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":"6.14.14","description":"A simple ECS implement","directories":{},"maintainers":[{"name":"intchous","email":"h.a.p.p.y.y.x.d@163.com"},{"name":"soundquiet","email":"fulingsun515@gmail.com"},{"name":"lviser","email":"liuvigongzuoshi@gmail.com"},{"name":"freestyle21","email":"675861708@qq.com"},{"name":"serializedowen","email":"wjh199455@gmail.com"},{"name":"sturuby","email":"xingya.shi@gmail.com"},{"name":"xdzhao","email":"zhaoxiaodong@zju.edu.cn"},{"name":"elaine.q.10","email":"yilin.qyl@antfin.com"},{"name":"sakuya223","email":"360965398@qq.com"},{"name":"leungwensen","email":"leungwensen@gmail.com"},{"name":"dori","email":"418466938@qq.com"},{"name":"simaq","email":"sima.zhang1990@gmail.com"},{"name":"dxq613","email":"dxq613@gmail.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.4_1630893738268_0.676279029572215","host":"s3://npm-registry-packages"},"_id":"@antv/g-ecs@1.0.0-alpha.4","version":"1.0.0-alpha.4"}