pub struct UtilitySystems;Expand description
实用系统
提供常用的实用系统实现。
Implementations§
Source§impl UtilitySystems
impl UtilitySystems
Sourcepub fn time_update_system(time: ResMut<'_, Time>)
pub fn time_update_system(time: ResMut<'_, Time>)
时间更新系统
更新全局时间资源。
§示例
use anvilkit_ecs::prelude::*;
use anvilkit_ecs::schedule::AnvilKitSchedule;
let mut app = App::new();
app.add_systems(AnvilKitSchedule::PreUpdate, UtilitySystems::time_update_system);Sourcepub fn visibility_filter_system(
query: Query<'_, '_, (Entity, &mut Visibility, Option<&Parent>), (With<Transform>, Changed<Visibility>)>,
)
pub fn visibility_filter_system( query: Query<'_, '_, (Entity, &mut Visibility, Option<&Parent>), (With<Transform>, Changed<Visibility>)>, )
可见性过滤系统
根据可见性组件过滤实体的处理。
§示例
use anvilkit_ecs::prelude::*;
fn render_system(query: Query<&Transform, With<Visibility>>) {
// 只处理可见的实体
for transform in &query {
// 渲染逻辑
}
}Sourcepub fn layer_sorting_system(
query: Query<'_, '_, (Entity, &Layer), Changed<Layer>>,
)
pub fn layer_sorting_system( query: Query<'_, '_, (Entity, &Layer), Changed<Layer>>, )
层级排序系统
根据层级组件对实体进行排序处理。
§示例
use anvilkit_ecs::prelude::*;
use anvilkit_ecs::schedule::AnvilKitSchedule;
let mut app = App::new();
app.add_systems(AnvilKitSchedule::PostUpdate, UtilitySystems::layer_sorting_system);Sourcepub fn cleanup_system<T>(
commands: Commands<'_, '_>,
query: Query<'_, '_, Entity, With<T>>,
)where
T: Component,
pub fn cleanup_system<T>(
commands: Commands<'_, '_>,
query: Query<'_, '_, Entity, With<T>>,
)where
T: Component,
清理系统
清理标记为删除的实体和组件。
§示例
use anvilkit_ecs::prelude::*;
use anvilkit_ecs::schedule::AnvilKitSchedule;
#[derive(Component)]
struct ToDelete;
let mut app = App::new();
app.add_systems(AnvilKitSchedule::Cleanup, UtilitySystems::cleanup_system::<ToDelete>);Auto Trait Implementations§
impl Freeze for UtilitySystems
impl RefUnwindSafe for UtilitySystems
impl Send for UtilitySystems
impl Sync for UtilitySystems
impl Unpin for UtilitySystems
impl UnsafeUnpin for UtilitySystems
impl UnwindSafe for UtilitySystems
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.