{"id":16405606,"url":"https://github.com/aecsocket/bevy_cleanup","last_synced_at":"2025-10-26T17:31:38.393Z","repository":{"id":191409318,"uuid":"684745093","full_name":"aecsocket/bevy_cleanup","owner":"aecsocket","description":"Cleanup design pattern tools for Bevy","archived":false,"fork":false,"pushed_at":"2023-08-29T19:21:50.000Z","size":22,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T21:52:59.426Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aecsocket.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}},"created_at":"2023-08-29T19:09:07.000Z","updated_at":"2023-11-19T20:51:12.000Z","dependencies_parsed_at":"2023-08-29T20:13:02.508Z","dependency_job_id":null,"html_url":"https://github.com/aecsocket/bevy_cleanup","commit_stats":null,"previous_names":["aecsocket/bevy_cleanup","aecsocket/bevy-cleanup"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aecsocket%2Fbevy_cleanup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aecsocket%2Fbevy_cleanup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aecsocket%2Fbevy_cleanup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aecsocket%2Fbevy_cleanup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aecsocket","download_url":"https://codeload.github.com/aecsocket/bevy_cleanup/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238375247,"owners_count":19461571,"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":"2024-10-11T06:06:41.013Z","updated_at":"2025-10-26T17:31:33.120Z","avatar_url":"https://github.com/aecsocket.png","language":"Rust","readme":"# bevy_cleanup\n\n[![crates.io](https://img.shields.io/crates/v/bevy_cleanup.svg)](https://crates.io/crates/bevy_cleanup)\n[![docs.rs](https://img.shields.io/docsrs/bevy_cleanup)](https://docs.rs/bevy_cleanup)\n\nProviders helpers for using the cleanup design pattern in Bevy, where entities are automatically\nremoved after a state transition, depending on any `Cleanup` marker components they have.\n\n```rs\nuse bevy::prelude::*;\nuse bevy_cleanup::{Cleanup, AddStateCleanup};\n\n// Set up your States enum and keep your Cleanup component types close by\n\n#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, States)]\nenum AppState {\n    #[default]\n    Menu,\n    Game,\n}\n\n#[derive(Component, Cleanup)]\nstruct CleanupMenu;\n\n#[derive(Component, Cleanup)]\nstruct CleanupGame;\n\n// Set up your App\n\nfn main() {\n    App::new()\n        .add_state::\u003cAppState\u003e()\n        .add_state_cleanup::\u003c_, CleanupMenu\u003e(AppState::Menu)\n        .add_state_cleanup::\u003c_, CleanupGame\u003e(AppState::Game)\n        .add_systems(OnEnter(AppState::Menu), setup_menu)\n        .run();\n}\n\nfn setup_menu(mut commands: Commands) {\n    // When spawning an entity, give it one of your `Cleanup` component types\n    // Typically, you put the Name and Cleanup types at the top of the component tuple\n    commands.spawn((\n        Name::new(\"Menu entity\"),\n        CleanupMenu,\n        // everything else...\n    ));\n}\n\n// When you want to switch from Menu to Game...\nfn switch_to_game(mut next_state: ResMut\u003cNextState\u003cAppState\u003e\u003e) {\n    // After this, any entities with the cleanup component of the current state (`CleanupMenu`)\n    // will be automatically recursively despawned.\n    next_state.set(AppState::Game);\n}\n```\n\n# License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or\n  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\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in\nthe work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without\nany additional terms or conditions.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faecsocket%2Fbevy_cleanup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faecsocket%2Fbevy_cleanup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faecsocket%2Fbevy_cleanup/lists"}