{"bugs":{"url":"https://github.com/antvis/g/issues"},"dist":{"shasum":"d78cbe8ace86817bf45ec771054a191d31efc518","tarball":"https://registry.npmjs.org/@antv/g-ecs/-/g-ecs-1.0.0-alpha.15.tgz","fileCount":46,"integrity":"sha512-2pjlJPSC272B4XYS2D2z9VyPdgtAnAtf6GEeDHJNeKi9JU8lOfmUBN910pjpb/UqCa48dUxmFY5Af4XUY1P4gA==","signatures":[{"sig":"MEUCIQCIbLlGYnQeQkXDVDjPKxXZI1E9pKtu2cTzEX0LR+UQYQIgdcoJH+S9lVGlbL6ngnRYwC8fp7MefwkRzqgDOxm4plg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":64627,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhlgz3CRA9TVsSAnZWagAAFu4P/RaP5uwhfca0C5K5PIS3\nO7MWaIeo2KphW7YDf1w4oUk3oldQ6zc5lXn9D8/M03jPU16pr6MiRi2sewOb\naHh6guWX+o9Bh85RKt8sADos/gIOTuKqGIdi2YNvQIxOi8Zu17Z9xpaUc9A5\nC2Y2x/OBHwrConnH4aGAVHwaiALnRJhmhG8sQ/rh8A18HRmPXd30DtmBCa94\nzXH5Nj8zp5G/SOC/tDnKG6AI1CWxE5O0xfEtYK9VJAfy0WKOZ2NN/2CZqIx/\ng8J/DYqAlnaC7mBrCtiDUm45FbprlqeWSZD6G6C0neyAm/vvNDoWJLVxHhJ2\naEnY3+x8YkDqIMLuE+ejaGPlveOnvEUYtrkQvh42cbDirgiLl5jaKJ5zR6VZ\nHKqqt2A8slhgWLGU6qtSyY2uP+NAGv/dXmhyh10KHBNKg8JYB4F+6fH0l4FF\n1MrWSNuhm9P0iLcO5Z7UdDhtSvc4f16SLYSswnftSWttgshrM8tZHNzVDHKB\n3TqTIZ/Zglh6J0nHfX/DDTbsH0WNnl2qVztXMuFPZUZssYnWdkWofs16hPxb\nJuK5tUsSwtu8Xlw4mZRoiAVsNgfeUU0se3m/pnKbAXToOBylsYU6YS9fp5lp\nEHlvzuUpa9aGZl8G6NZOIjXULkzPxRwIpaQlRSX9daMWK7wPIvKFoubmLQgT\nDzBX\r\n=6Dwv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"lib/index.js","name":"@antv/g-ecs","types":"es/index.d.ts","unpkg":"dist/index.umd.js","author":{"name":"https://github.com/orgs/antvis/people"},"module":"es/index.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) ![](https://img.shields.io/badge/language-javascript-red.svg) ![](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, true);\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, true);\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":"c0f918d5477e3099b9bfa3ecb077cc411c0b2e3a","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":"zeyuwang","email":"zywangx@gmail.com"},{"name":"yanxiong","email":"496845051@qq.com"},{"name":"susiwen8","email":"susiwen8@gmail.com"},{"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":{"mana-syringe":"^0.2.2","eventemitter3":"^4.0.0"},"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"},"_npmOperationalInternal":{"tmp":"tmp/g-ecs_1.0.0-alpha.15_1637223671544_0.8625963916904442","host":"s3://npm-registry-packages"},"_id":"@antv/g-ecs@1.0.0-alpha.15","version":"1.0.0-alpha.15"}