{"id":15031455,"url":"https://github.com/dekirisu/bevy_cell","last_synced_at":"2025-04-09T22:41:12.548Z","repository":{"id":191709660,"uuid":"685444588","full_name":"dekirisu/bevy_cell","owner":"dekirisu","description":"Attach Bevy's Handles/Entities statically to Types.","archived":false,"fork":false,"pushed_at":"2024-05-10T11:14:16.000Z","size":40,"stargazers_count":37,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T00:38:14.402Z","etag":null,"topics":["bevy","lazy","macro","rustlang"],"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/dekirisu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"2023-08-31T08:42:21.000Z","updated_at":"2025-03-11T08:31:36.000Z","dependencies_parsed_at":"2024-05-10T12:29:53.223Z","dependency_job_id":null,"html_url":"https://github.com/dekirisu/bevy_cell","commit_stats":null,"previous_names":["dekirisu/bevy_cell"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekirisu%2Fbevy_cell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekirisu%2Fbevy_cell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekirisu%2Fbevy_cell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekirisu%2Fbevy_cell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dekirisu","download_url":"https://codeload.github.com/dekirisu/bevy_cell/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248124848,"owners_count":21051757,"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":["bevy","lazy","macro","rustlang"],"created_at":"2024-09-24T20:15:42.954Z","updated_at":"2025-04-09T22:41:12.507Z","avatar_url":"https://github.com/dekirisu.png","language":"Rust","readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://user-images.githubusercontent.com/78398528/282285927-6f6c28a4-7d52-46ab-b29d-1d43cbc96374.gif\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/dekirisu/bevy_cell\" style=\"position:relative\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/github-dekirisu/bevy_cell-ee6677\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://crates.io/crates/bevy_cell\" style=\"position:relative\"\u003e\n        \u003cimg src=\"https://img.shields.io/crates/v/bevy_cell\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://docs.rs/bevy_cell\" style=\"position:relative\"\u003e\n        \u003cimg src=\"https://img.shields.io/docsrs/bevy_cell\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://discord.gg/kevWvBuPFg\" style=\"position:relative\"\u003e\n        \u003cimg src=\"https://img.shields.io/discord/515100001903312898\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n🦊 Easily attach \u003ca href=\"https://github.com/bevyengine/bevy\"\u003ebevy\u003c/a\u003e's Handles/Entities statically to types \u003cbr\u003e\n🐑 Get them in any system, without using Resources.\u003cbr\u003e\n🦄 See \u003ca href=\"https://github.com/dekirisu/type_cell\"\u003etype_cell\u003c/a\u003e for any other use case!\n\u003cbr\u003e\n```toml\n[dependencies]\nbevy_cell = \"0.13\"\n```\n```rust \nuse bevy_cell::*;\n```\n---\n\n\u003cb\u003e\u003cu\u003eI.\u003c/u\u003e There are 2 valid syntaxes:\u003c/b\u003e\u003cbr\u003e\n🐰 `{Type} [name1] [name2] [name3]`\u003cbr\u003e\n🦝 `Type: [name1] [name2] [name3];`\n\u003cbr\u003e\u003cbr\u003e\n\u003cb\u003e\u003cu\u003eII.\u003c/u\u003e The syntax inside the `[]` will change the attached type:\u003c/b\u003e\u003cbr\u003e\n🐈 **Entity** - Just choose a name: `[camera]`\u003cbr\u003e\n🦥 **Handle** - Its type separated by a `|`:  `[Image|cat]`\u003cbr\u003e\n🐹 **Raw** - Its type separated by a `:`:  `[Image:cat]`\u003cbr\u003e\n🐒 If no type is set, the parent type is used: `[|cat]` `[:cat]`\n\u003cbr\u003e\u003cbr\u003e\n\u003cb\u003e\u003cu\u003eIII.\u003c/u\u003e Setting the collection type is also done inside `[]`:\u003c/b\u003e\u003cbr\u003e\n🦄 **Single** - Using the syntax as in \u003cu\u003e**II.**\u003c/u\u003e\u003cbr\u003e\n🐔 **Vec** - add a `\u003c\u003e` after the name: `[cameras\u003c\u003e]`\u003cbr\u003e\n🐲 **HashMap** - add a `\u003cKeyType\u003e` after the name: `[cameras\u003cusize\u003e]`\n\u003cbr\u003e\n```rust \n// Macro Examples\nbycell! {\n    Camera: [main] [secondary];\n    AudioSource: [|hit] [|shots\u003c\u003e];\n    Player: [main] [Scene|models\u003cu8\u003e];\n}\n```\n\u003cb\u003e\u003cu\u003eIV.\u003c/u\u003e Setting Values:\u003c/b\u003e\u003cbr\u003e\n🐑 Use `Type::set_..(value)` **ONCE** on (pre-)startup\u003cbr\u003e\n🦌 The value can be anything implementing its type!\n```rust \n// Setter Examples\nCamera::set_main(commands.spawn(..).id());\nAudioSource::set_shots([\n    assets.load(\"shot0.ogg\"),\n    assets.load(\"shot1.ogg\"),\n    assets.load(\"shot3.ogg\"),\n]);\nPlayer::set_models([\n    (5, assets.load(\"player5.glb\")),\n    (7, assets.load(\"player7.glb\")),\n]);\n```\n\u003cb\u003e\u003cu\u003eV.\u003c/u\u003e Getting Values:\u003c/b\u003e\u003cbr\u003e\n🐏 Different getters are provided, depending on the collection type!\n```rust \n// Single Getter\nCamera::main();            // Cloned\nCamera::main_ref();        // Static Reference\n// Vec Getters\nAudioSource::shots(1);     // Cloned\nAudioSource::shots_ref(1); // Static Reference\nAudioSource::shots_vec();  // Static Reference to Vec\n// HashMap Getters\nPlayer::models(\u00265);        // Cloned\nPlayer::models_ref(\u00265);    // Static Reference\nPlayer::models_map();      // Static Reference to HashMap\n```\n\n\u003cb\u003e\u003cu\u003eVI.\u003c/u\u003e Mutability:\u003c/b\u003e\u003cbr\u003e\n🐝 You can make any of those mutable by adding a `mut` before the name\u003cbr\u003e\n🦞 Only use this if you can avoid race conditions\u003cbr\u003e\n🦧 One idea is to mutate something on state change!\n```rust \n// Macro Examples\nbycell! {\n    Camera: [mut main] [mut secondary];\n    AudioSource: [|mut hit] [|mut shots\u003c\u003e];\n    Player: [mut main] [Scene|mut models\u003cu8\u003e];\n}\n```\n---\n### License\n\u003csup\u003e\nLicensed under either of \u003ca href=\"LICENSE-APACHE\"\u003eApache License, Version\n2.0\u003c/a\u003e or \u003ca href=\"LICENSE-MIT\"\u003eMIT license\u003c/a\u003e at your option.\n\u003c/sup\u003e\n\u003cbr\u003e\n\u003csub\u003e\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this crate by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.\n\u003c/sub\u003e","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdekirisu%2Fbevy_cell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdekirisu%2Fbevy_cell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdekirisu%2Fbevy_cell/lists"}