{"id":13550181,"url":"https://github.com/Ralith/hecs","last_synced_at":"2025-04-02T23:32:06.202Z","repository":{"id":36475353,"uuid":"226764114","full_name":"Ralith/hecs","owner":"Ralith","description":"A handy ECS","archived":false,"fork":false,"pushed_at":"2025-03-26T21:56:58.000Z","size":588,"stargazers_count":1066,"open_issues_count":37,"forks_count":85,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-27T11:03:26.810Z","etag":null,"topics":["ecs-paradigm","hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/Ralith.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-09T02:03:13.000Z","updated_at":"2025-03-27T00:40:54.000Z","dependencies_parsed_at":"2023-01-17T01:50:54.223Z","dependency_job_id":"657a7e53-51e7-4818-8bdc-6ccc6d2a0260","html_url":"https://github.com/Ralith/hecs","commit_stats":{"total_commits":556,"total_committers":32,"mean_commits":17.375,"dds":"0.20503597122302153","last_synced_commit":"96f8289752318bea1040a04e082c92b65ece6950"},"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ralith%2Fhecs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ralith%2Fhecs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ralith%2Fhecs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ralith%2Fhecs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ralith","download_url":"https://codeload.github.com/Ralith/hecs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246911268,"owners_count":20853653,"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-paradigm","hacktoberfest"],"created_at":"2024-08-01T12:01:29.868Z","updated_at":"2025-04-02T23:32:06.195Z","avatar_url":"https://github.com/Ralith.png","language":"Rust","funding_links":[],"categories":["Rust","[ECS Libraries](#contents)"],"sub_categories":[],"readme":"# hecs\n\n[![Documentation](https://docs.rs/hecs/badge.svg)](https://docs.rs/hecs/)\n[![Crates.io](https://img.shields.io/crates/v/hecs.svg)](https://crates.io/crates/hecs)\n[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE-APACHE)\n\nhecs provides a high-performance, minimalist entity-component-system (ECS)\nworld. It is a library, not a framework. In place of an explicit \"System\"\nabstraction, a `World`'s entities are easily queried from regular code. Organize\nyour application however you like!\n\n### Example\n\n```rust\nlet mut world = World::new();\n// Nearly any type can be used as a component with zero boilerplate\nlet a = world.spawn((123, true, \"abc\"));\nlet b = world.spawn((42, false));\n// Systems can be simple for loops\nfor (id, (number, \u0026flag)) in world.query_mut::\u003c(\u0026mut i32, \u0026bool)\u003e() {\n  if flag { *number *= 2; }\n}\n// Random access is simple and safe\nassert_eq!(*world.get::\u003c\u0026i32\u003e(a).unwrap(), 246);\nassert_eq!(*world.get::\u003c\u0026i32\u003e(b).unwrap(), 42);\n```\n\n### Why ECS?\n\nEntity-component-system architecture makes it easy to compose loosely-coupled\nstate and behavior. An ECS world consists of:\n\n- any number of **entities**, which represent distinct objects\n- a collection of **component** data associated with each entity, where each\n  entity has at most one component of any type, and two entities may have\n  different components\n\nThat world is then manipulated by **systems**, each of which accesses all\nentities having a particular set of component types. Systems implement\nself-contained behavior like physics (e.g. by accessing \"position\", \"velocity\",\nand \"collision\" components) or rendering (e.g. by accessing \"position\" and\n\"sprite\" components).\n\nNew components and systems can be added to a complex application without\ninterfering with existing logic, making the ECS paradigm well suited to\napplications where many layers of overlapping behavior will be defined on the\nsame set of objects, particularly if new behaviors will be added in the\nfuture. This flexibility sets it apart from traditional approaches based on\nheterogeneous collections of explicitly defined object types, where implementing\nnew combinations of behaviors (e.g. a vehicle which is also a questgiver) can\nrequire far-reaching changes.\n\n#### Performance\n\nIn addition to having excellent composability, the ECS paradigm can also provide\nexceptional speed and cache locality. `hecs` internally tracks groups of\nentities which all have the same components. Each group has a dense, contiguous\narray for each type of component. When a system accesses all entities with a\ncertain set of components, a fast linear traversal can be made through each\ngroup having a superset of those components. This is effectively a columnar\ndatabase, and has the same benefits: the CPU can accurately predict memory\naccesses, bypassing unneeded data, maximizing cache use and minimizing latency.\n\n### Why Not ECS?\n\nhecs strives to be lightweight and unobtrusive so it can be useful in\na wide range of applications. Even so, it's not appropriate for every\ngame. If your game will have few types of entities, consider a simpler\narchitecture such as storing each type of entity in a separate plain\n`Vec`. Similarly, ECS may be overkill for games that don't call for\nbatch processing of entities.\n\nEven for games that benefit, an ECS world is not a be-all end-all data\nstructure. Most games will store significant amounts of state in other\nstructures. For example, many games maintain a spatial index structure\n(e.g. a tile map or bounding volume hierarchy) used to find entities\nand obstacles near a certain location for efficient collision\ndetection without searching the entire world.\n\nIf you need to search for specific entities using criteria other than the types\nof their components, consider maintaining a specialized index beside your world,\nstoring `Entity` handles and whatever other data is necessary. Insert into the\nindex when spawning relevant entities, and include a component with that allows\nefficiently removing them from the index when despawning.\n\n### Other Libraries\n\nhecs owes a great deal to the free exchange of ideas in Rust's ECS library\necosystem. Particularly influential examples include:\n\n- [bevy], which continually pushes the envelope for performance and ergonomics\n  in the context of a batteries-included framework\n- [specs], which was key in popularizing ECS in Rust\n- [legion], which demonstrated archetypal memory layout and trait-less\n  components\n\nIf hecs doesn't suit you, one of those might do the trick!\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally\nsubmitted for inclusion in the work by you, as defined in the\nApache-2.0 license, shall be dual licensed as above, without any\nadditional terms or conditions.\n\n[bevy]: https://github.com/bevyengine/bevy\n[specs]: https://github.com/amethyst/specs\n[legion]: https://github.com/TomGillen/legion\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRalith%2Fhecs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRalith%2Fhecs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRalith%2Fhecs/lists"}