Lightyear setup (#55)
This commit is contained in:
21
crates/shared/src/utils/commands.rs
Normal file
21
crates/shared/src/utils/commands.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use bevy::ecs::{
|
||||
bundle::Bundle, resource::Resource, system::EntityCommands, world::EntityWorldMut,
|
||||
};
|
||||
|
||||
#[derive(Default, Resource)]
|
||||
pub struct IsServer;
|
||||
|
||||
pub trait CommandExt {
|
||||
fn insert_server(&mut self, bundle: impl Bundle) -> &mut Self;
|
||||
}
|
||||
|
||||
impl<'w> CommandExt for EntityCommands<'w> {
|
||||
fn insert_server(&mut self, bundle: impl Bundle) -> &mut Self {
|
||||
self.queue(|mut entity: EntityWorldMut| {
|
||||
if entity.world().contains_resource::<IsServer>() {
|
||||
entity.insert(bundle);
|
||||
}
|
||||
});
|
||||
self
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user