{"id":26905070,"url":"https://github.com/rj/bevy_mutually_exclusive_components","last_synced_at":"2025-07-20T00:33:37.409Z","repository":{"id":272128083,"uuid":"915449943","full_name":"RJ/bevy_mutually_exclusive_components","owner":"RJ","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-12T10:26:12.000Z","size":13,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-12T23:46:26.947Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RJ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-01-11T21:48:27.000Z","updated_at":"2025-01-12T18:37:00.000Z","dependencies_parsed_at":"2025-01-12T11:28:33.643Z","dependency_job_id":"9a06c9d3-c106-4f5a-8fb1-af2c01e65e62","html_url":"https://github.com/RJ/bevy_mutually_exclusive_components","commit_stats":null,"previous_names":["rj/bevy_mutually_exclusive_components"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RJ/bevy_mutually_exclusive_components","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RJ%2Fbevy_mutually_exclusive_components","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RJ%2Fbevy_mutually_exclusive_components/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RJ%2Fbevy_mutually_exclusive_components/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RJ%2Fbevy_mutually_exclusive_components/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RJ","download_url":"https://codeload.github.com/RJ/bevy_mutually_exclusive_components/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RJ%2Fbevy_mutually_exclusive_components/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266048682,"owners_count":23868743,"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":[],"created_at":"2025-04-01T10:55:49.918Z","updated_at":"2025-07-20T00:33:37.385Z","avatar_url":"https://github.com/RJ.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bevy Mutually Exclusive Components\n\nMutually exclusive groups of components for bevy.\n\n## Usage\n\nThere is no plugin, just bring the `RegisterMutuallyExclusiveComponent` trait into scope:\n\n```rust\nuse bevy_mutually_exclusive_components::prelude::*;\n```\n\nComponents in a group (defined by a `u32`) are mutually exclusive – if you set up a group with\ncomponents `A`, `B`, and `C`, then insert `A` into an entity, then insert `B`, `A` will be removed.\n\n```rust\n#[derive(Component)]\nstruct A;\n#[derive(Component)]\nstruct B;\n#[derive(Component)]\nstruct C;\n\n// ...\n\n// Make components A,B,C mutually exclusive\nconst MY_GROUP: u32 = 1;\napp.register_mutually_exclusive_component::\u003cMY_GROUP, A\u003e();\napp.register_mutually_exclusive_component::\u003cMY_GROUP, B\u003e();\napp.register_mutually_exclusive_component::\u003cMY_GROUP, C\u003e();\n\n// Make components X,Y mutually exclusive\nconst MY_OTHER_GROUP: u32 = 2;\napp.register_mutually_exclusive_component::\u003cMY_OTHER_GROUP, X\u003e();\napp.register_mutually_exclusive_component::\u003cMY_OTHER_GROUP, Y\u003e();\n\n```\n\n## How it works\n\nA component hook is created for each component you register. It stores the `ComponentId` of itself\nin a private `LastMutuallyExclusiveId` component on insertion.\n\nBefore doing so, it checks if there is already a value in the `LastMutuallyExclusiveId` component,\nand if so, removes the component with that `ComponentId`.\n\nSee the test at the bottom of `lib.rs` for an example.\n\nThe `LastMutuallyExclusiveId` component takes a const generic u32, which is how groups are identified.\n\n## Caution\n\nComponents can only have one hook, so it'll panic if you try to add a component to multiple groups.\n\nIt will also panic if a component already has a hook for another reason.\n\n## License\n\nSame as bevy","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frj%2Fbevy_mutually_exclusive_components","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frj%2Fbevy_mutually_exclusive_components","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frj%2Fbevy_mutually_exclusive_components/lists"}