{"id":21985570,"url":"https://github.com/ickshonpe/bevy_stat_bars","last_synced_at":"2025-04-30T07:53:15.127Z","repository":{"id":53824099,"uuid":"501779018","full_name":"ickshonpe/bevy_stat_bars","owner":"ickshonpe","description":"plugin for drawing floating stat bars","archived":false,"fork":false,"pushed_at":"2022-09-28T11:25:04.000Z","size":196,"stargazers_count":8,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-09-14T21:58:47.688Z","etag":null,"topics":["2d","bevy","game-development","sprites","ui"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ickshonpe.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":"2022-06-09T19:11:31.000Z","updated_at":"2024-09-02T17:59:28.000Z","dependencies_parsed_at":"2022-08-22T07:01:15.434Z","dependency_job_id":null,"html_url":"https://github.com/ickshonpe/bevy_stat_bars","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/ickshonpe%2Fbevy_stat_bars","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ickshonpe%2Fbevy_stat_bars/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ickshonpe%2Fbevy_stat_bars/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ickshonpe%2Fbevy_stat_bars/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ickshonpe","download_url":"https://codeload.github.com/ickshonpe/bevy_stat_bars/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227185421,"owners_count":17744371,"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":["2d","bevy","game-development","sprites","ui"],"created_at":"2024-11-29T18:14:04.103Z","updated_at":"2024-11-29T18:14:04.780Z","avatar_url":"https://github.com/ickshonpe.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bevy_stat_bars\n\nBevy crate for drawing floating statbars like health bars above enemy sprites etc.\n\n## Version 0.3\n\n* Supports Bevy 0.8\n\n### New in this release\n\n* Completely rewritten. New design and API. \n* Should (hopefully) be easier to use, the redesign seems better to me but let me know if you hate the changes. \n* (Seems to) Work nicely with ```bevy_inspector_egui``` now.\n* Removed the arbitrary orientation stuff temporarily, just has reversible horizontal and\n vertical bars.\n* Statbars can track resources as well as components.\n* No plugin, need to add an observer to your Bevy ```App`` for each type of Statbar before they will draw.\n* Multiple Statbar components on one entity implemented using PhantomData. This requires\n ![/media/example.png](/media/example.png)\n\n# \n\n## How to use\n\nAdd the dependency to your Cargo.toml file with\n\n```toml\n[dependencies.bevy_stat_bars]\nversion = \"0.3\"\n```\n\nThen register any components you want to observe with a statbar with your Bevy App:\n\n```rust \nuse bevy_stat_bars::*;\n\nApp::new()\n    .add_plugins(DefaultPlugins)\n    .add_statbar_bar_component_observer::\u003cHitPoints\u003e()\n    // ..etc, rest of app\n    .run();\n```\n\nYou also need to implement the ```StatbarObservable``` trait on those components:\n\n```rust \nimpl StatbarObservable for HitPoints {\n    fn get_statbar_value(\u0026self) -\u003e f32 {\n        self.value / self.max\n    }\n}\n```\n\nAnd now you can add a ```Statbar::\u003cHitPoints\u003e``` component to an entity to visualize its HitPoints component\n\n```rust\ncommands.entity(enemy_id)\n    .insert_bundle((\n        Statbar::\u003cHitPoints\u003e {\n            empty_color: Color::NAVY,\n            length: 10.,\n            thickness: 2.,\n            displacement: 8. * Vec2::Y,\n            ..Default::default()\n        },\n        StatbarBorder::\u003cHitPoints\u003e::all(Color::WHITE, 1.),\n    ));\n```\n\n![/media/example2.png](/media/example2.png)\n\n#\n\n## Examples\n\nThere are six examples you can look at that cover most of the features and use cases,\nrun them with\n```\ncargo run --example minimal_standalone\ncargo run --example basic_interactive\ncargo run --example observe_resource\ncargo run --example demo\ncargo run --example stress --release\ncargo run --example stress2 --release\n```\nThe ```demo``` example is the probably the most useful to look at.\n\nThe ```stress2``` example uses macros to add hundreds of marker types and can take a few minutes to compile.\n\n#\n\n## Notes\n\n* Only supports 2D.\n\n* When I was writing the examples I made a mistake where instead of\n\n    ```rust\n    .add_statbar_component_observer::\u003cStat\u003cHealth\u003e\u003e()\n    ```\n    I used \n    ```rust\n    .add_statbar_component_observer::\u003cHealth\u003e()\n    ```\n    which is quite easy to miss. The crate fails silently and just won't render anything in this case, leaving the user with a frustrating bug hunt. \n\n    Likewise also when a statbar is set to observe its parent or another Entity that doesn't exist, it will render a statbar that doesn't update. \n\n* Statbars are drawn using Sprites with a z depth of 990, and if you translate the camera down more than 10 units they won't draw.\nYou can change the depth with the ```StatbarDepth``` resource. \n    \n    So with\n\n    ```rust\n    commands.insert_resource(StatbarDepth(500.));\n    ```\n\n    all Statbars will now render with a z depth of 500.\n    There currently isn't any way to control the ordering in which the individual statbars are drawn.\n\n* Still uses sprites for rendering which isn't ideal but performance seems fine. You can run the ```stress``` example to see what its like under a heavy load. I get about 100fps on my rx580.\n\n* ```add_statbar_component_observer``` adds six systems to your Bevy app per component observed. Again not ideal but doesn't seem to be a problem. I get ~100fps with the ```stress2``` example which spawns 100 entities with 200 Statbars each.\n#\n## Future Plans\n\n* Replace the sprite based rendering with a custom renderer. I have some fragment shaders already written, and should be better performance with some nice effects like rounded corners and color gradients.\n* Pie-o-meters\n* Labels and numeric indicators\n* Some sort of, posibly feature gated or debug-only, falure detection that gives an error when you insert unregistered statbars, or when a statbar can't find the component it is meant to be observing.\n* Derive macro for StatbarObservable.\n* Auto arrangement/stacking of groups of statbars. I thought this would be more difficult but I dreamt up an easyish way to do it last night.\n\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fickshonpe%2Fbevy_stat_bars","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fickshonpe%2Fbevy_stat_bars","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fickshonpe%2Fbevy_stat_bars/lists"}