-
-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Boss Bar API #371
Boss Bar API #371
Conversation
… code; Created tests file
Yes it's like in a db you put the id of what you want to ref.
When you use
No, BossBar are not link to the instance, but you should spawn a new bevy_entity commands.spawn(BossBarBundle::new(...)); |
Regarding your questions
Yes, that's how you should do it. Otherwise, you would be attempting to violate rust's aliasing rules.
You need to query for clients separately, and then you can use the fn foo(clients: Query<Client>) {
// Then you can look up the client using the entity
clients.get(entity)
For unit tests, operating directly on |
Hey thanks for your help! The problem I have is that I don't know how to modify something in the Bundle. I could simply make a method to change a property but how am I supposed to send the packets then? Because since it's not a system I can't query anything right? |
Hey thanks a lot for your help!
So I have to do that in a system? But isn't a system supposed to be executed every tick? Or I should use something like an event?
Fine I will do that! |
You want to send the packet when the bossbar is created or that an component change for that you can use changeDetection fn foo(clients: Query<Client>, bossbar: Query<(UniqueId, ...), Added<BossBarBundle>>) { // not sure if you can put a bundle here, but if you can't use a component that uniquely identify a bossbar
// you generates packets for each bossbar
// Then you can look up each client of the bossbar to send them like you did before
} |
you don't make method to modify the component. fn update_bossbar(mob: Query<&Hp, &BossBarLink, Change<Hp>>, bossbar: Query<&mut BossBarHealth>) {
for (hp, link) in mob {
if let Ok(bossbar_health) = bossbar.get(link) {
bossbat_health -= hp;
}
}
} That will trigger a change detection on BossBarHealth that you can use to send the updatede packet |
That's exactly what I was looking for, thanks |
…tributes update handlers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Graph in crates/README.md
needs an update.
…enamed systems; Made components module private; Added more lints to the crate; Removed unwrap uses; Fixed system queries; Improved boss bar update viewers handler's code; Improved packets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
valence_boss_bar
needs to be exported as boss_bar
in the main valence
crate. Also, please add an example to examples/
.
Looks good, thanks. |
Description
Hey, I started working on this issue #337.
So far:
valence/crates/valence_core/src/protocol/packet.rs
Line 612 in 2ed5a88
Playground
I've tested the API in playground and it works fine.
mp4.mp4.online-video-cutter.com.mp4