{"id":16731702,"url":"https://github.com/spearwolf/ecs","last_synced_at":"2025-03-15T18:26:23.426Z","repository":{"id":40942660,"uuid":"170848755","full_name":"spearwolf/ecs","owner":"spearwolf","description":"an entity component system for javascript","archived":false,"fork":false,"pushed_at":"2023-01-04T21:53:32.000Z","size":936,"stargazers_count":0,"open_issues_count":19,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T08:13:43.422Z","etag":null,"topics":["ecs","javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spearwolf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-15T10:42:51.000Z","updated_at":"2020-01-02T11:02:50.000Z","dependencies_parsed_at":"2023-02-02T21:16:50.687Z","dependency_job_id":null,"html_url":"https://github.com/spearwolf/ecs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spearwolf%2Fecs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spearwolf%2Fecs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spearwolf%2Fecs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spearwolf%2Fecs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spearwolf","download_url":"https://codeload.github.com/spearwolf/ecs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243772729,"owners_count":20345705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ecs","javascript"],"created_at":"2024-10-12T23:38:35.993Z","updated_at":"2025-03-15T18:26:23.400Z","avatar_url":"https://github.com/spearwolf.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `@spearwolf/ecs`\n\nAn [entity component system](https://en.wikipedia.org/wiki/Entity_component_system) for javascript.\n\n## What does a Component look like?\n\n```js\n\n@Component({\n  name: 'foo'\n})\nclass Foo {\n\n  hello() =\u003e {\n    console.log('moin moin!');\n  };\n\n  connectToEntity(entity) {\n    entity.on('hello', this);\n  }\n\n  disconnectFromEntity(entity) {\n    entity.off(this);\n  }\n\n}\n\n@Component({\n  name: 'bar'\n})\nclass Bar {\n\n  initialize(message) {\n    this.message = message;\n  }\n\n  sayHello = () =\u003e {\n    console.log(this.message);\n  }\n\n  connectToEntity(entity) {\n    entity.on('hello', this.sayHello);\n  }\n\n  disconnectFromEntity(entity) {\n    entity.off(this.sayHello);\n  }\n\n  // destroy()\n\n}\n\n```\n\n## What is an Entity and how does it play together?\n\n```js\n\n// first, you need an entrypoint\n// .. where you can register your components\nconst ecs = new ECS([ Foo, Bar ]);\n\n// then you can create an entity and attach some components to it\nconst entity = ecs.createEntity([\n  Foo,\n  [Bar, \"hej!\"], // our Bar component needs some configuration\n]);\n\n// as a result you will get an object with 'foo' and 'bar' properties\n// both properties are pointing to their component instances\n\nentity.foo // is an instance of Foo\nentity.bar // is an instance of Bar\n\nentity.id // each entity has an unique id!\n\n// now we can play with our entity ..\n\nentity.bar.sayHello() // =\u003e 'hej!'\n\nentity.emit('hello') // emit the event 'action'\n\n// =\u003e 'moin moin!'\n// =\u003e 'hej!'\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspearwolf%2Fecs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspearwolf%2Fecs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspearwolf%2Fecs/lists"}