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
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,15 @@
|
||||
pub mod auto_rotate;
|
||||
pub mod billboards;
|
||||
pub mod commands;
|
||||
pub mod explosions;
|
||||
pub mod observers;
|
||||
pub mod sprite_3d_animation;
|
||||
pub mod squish_animation;
|
||||
pub mod trail;
|
||||
|
||||
use bevy::prelude::*;
|
||||
pub(crate) use observers::global_observer;
|
||||
|
||||
pub fn plugin(app: &mut App) {
|
||||
app.add_plugins(observers::plugin);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user