pub struct World {
pub tick: u32,
/* private fields */
}Fields§
§tick: u32Implementations§
Source§impl World
impl World
pub fn new() -> World
Sourcepub fn increment_tick(&mut self)
pub fn increment_tick(&mut self)
Increments the local tick counter, guaranteeing it skips 0 on wrap.
Sourcepub fn apply_commands(&mut self)
pub fn apply_commands(&mut self)
Ertelenmiş komut kuyruğunu (CommandQueue) işler. Entity ekleme/çıkarma işlemleri bu sayede kilitlenme (deadlock) yaşamadan batch halinde uygulanır.
Source§impl World
impl World
Sourcepub fn register_component_type<T>(&mut self)where
T: Component,
pub fn register_component_type<T>(&mut self)where
T: Component,
Belirli bir component turunun runtime metadata’sini kaydeder. Archetype storage migration asamalarinda column olusturma icin kullanilir.
Sourcepub fn add_observer<T, F>(&mut self, system: F) -> &mut World
pub fn add_observer<T, F>(&mut self, system: F) -> &mut World
Registers a Component hook (Observer) for OnInsert.
Sourcepub fn observe<E, F>(&mut self, entity: Entity, listener: F) -> &mut World
pub fn observe<E, F>(&mut self, entity: Entity, listener: F) -> &mut World
Özel EntityEvent’ler için Entity bazlı Observer kaydı
Sourcepub fn trigger<E>(&mut self, event: E)where
E: EntityEvent,
pub fn trigger<E>(&mut self, event: E)where
E: EntityEvent,
Bir Event’i tetikler ve hiyerarşide yukarı doğru yayar (bubble-up)
Sourcepub fn is_component_registered<T>(&self) -> boolwhere
T: Component,
pub fn is_component_registered<T>(&self) -> boolwhere
T: Component,
Belirli bir component turu kayitli mi?
Sourcepub fn registered_component_count(&self) -> usize
pub fn registered_component_count(&self) -> usize
Kayitli component metadata sayisi.
pub fn register_on_add<T>(
&mut self,
hook: Box<dyn FnMut(&mut World, Entity) + Send + Sync>,
)where
T: Component,
pub fn register_on_remove<T>(
&mut self,
hook: Box<dyn FnMut(&mut World, Entity) + Send + Sync>,
)where
T: Component,
pub fn register_on_set<T>(
&mut self,
hook: Box<dyn FnMut(&mut World, Entity) + Send + Sync>,
)where
T: Component,
pub fn spawn(&mut self) -> Entity
Sourcepub fn spawn_bundle<B>(&mut self, bundle: B) -> Entitywhere
B: Bundle,
pub fn spawn_bundle<B>(&mut self, bundle: B) -> Entitywhere
B: Bundle,
Bir Bundle’ı tek seferde spawn eder — entity oluşturur ve tüm
bileşenleri ekler.
let player = world.spawn_bundle(MeshBundle {
mesh: renderer.create_cube(),
material: Material::pbr(Color::BLUE, 0.5, 0.0),
name: "Oyuncu",
..default()
});pub fn flush_spawn(&mut self, entity: Entity)
pub fn get_entity(&self, id: u32) -> Option<Entity>
Sourcepub fn clone_entity(
&mut self,
source_id: u32,
count: usize,
) -> Option<Vec<Entity>>
pub fn clone_entity( &mut self, source_id: u32, count: usize, ) -> Option<Vec<Entity>>
Derin kopyalama (O(1) Prefab Splicing) işlemi. Var olan bir Entity’nin bulunduğu archetype tablosunda tamamen bitişik olarak N adet yeni kopyasını çıkarır.
pub fn register_despawn_hook( &mut self, hook: Box<dyn FnMut(&mut World, Entity) + Send + Sync>, )
pub fn spawn_batch<I>(&mut self, iter: I) -> impl Iterator<Item = Entity>
Sourcepub fn clear_entities(&mut self)
pub fn clear_entities(&mut self)
Tüm entityleri temizler.
pub fn despawn(&mut self, entity: Entity)
Sourcepub fn compact(&mut self)
pub fn compact(&mut self)
Hafızadaki boşlukları sıkıştırır ve kullanılmayan (boş) Archetype tablolarını silerek RAM’i ve sistem performansını ilk baştaki defregmante (temiz) haline getirir. Yükleme (Loading) ekranlarında veya düşük yoğunluklu anlarda çağrılması önerilir.
pub fn despawn_by_id(&mut self, id: u32)
Sourcepub fn iter_alive_entities(&self) -> Vec<Entity>
pub fn iter_alive_entities(&self) -> Vec<Entity>
Yaşayan (despawn olmamış) tüm Entity’leri döndüren iterator. Uyarı: İterasyon boyunca Entities mutex kilidi tutulur!
pub fn is_alive(&self, entity: Entity) -> bool
Sourcepub fn add_bundle<B>(&mut self, entity: Entity, bundle: B)where
B: Bundle,
pub fn add_bundle<B>(&mut self, entity: Entity, bundle: B)where
B: Bundle,
Sisteme component ekleme — Veriyi archetype sütununa taşır.
pub fn remove_bundle<B>(&mut self, entity: Entity)where
B: Bundle,
pub fn add_component<T>(&mut self, entity: Entity, component: T)where
T: Component,
Sourcepub fn get_entity_component_types(&self, entity: Entity) -> Vec<TypeId>
pub fn get_entity_component_types(&self, entity: Entity) -> Vec<TypeId>
Entity üzerindeki tüm bileşenlerin TypeId’lerini döndürür.
Sourcepub fn get_component_ptr(
&self,
entity: Entity,
type_id: TypeId,
) -> Option<*const u8>
pub fn get_component_ptr( &self, entity: Entity, type_id: TypeId, ) -> Option<*const u8>
Raw Component Pointer alma (Reflection/Editor için)
Sourcepub fn get_component_mut_ptr(
&mut self,
entity: Entity,
type_id: TypeId,
) -> Option<*mut u8>
pub fn get_component_mut_ptr( &mut self, entity: Entity, type_id: TypeId, ) -> Option<*mut u8>
Mut mutable Component pointer alma (HierarchyExt vs için)
Sourcepub fn reconstruct_entity(&self, id: u32) -> Option<Entity>
pub fn reconstruct_entity(&self, id: u32) -> Option<Entity>
Entity ID’sinden geçerli nesneyi tekrar yapılandırır
Sourcepub fn remove_component<T>(&mut self, entity: Entity)where
T: Component,
pub fn remove_component<T>(&mut self, entity: Entity)where
T: Component,
Sistemden component silme
pub fn query<'w, Q>(&'w self) -> Option<Query<'w, Q>>where
Q: WorldQuery,
Sourcepub fn borrow<'w, T>(&'w self) -> Query<'w, &'w T>where
T: Component,
pub fn borrow<'w, T>(&'w self) -> Query<'w, &'w T>where
T: Component,
Geriye uyumluluk için StorageView alternatifi
Sourcepub fn borrow_mut<'w, T>(&'w self) -> Query<'w, Mut<'w, T>>where
T: Component,
pub fn borrow_mut<'w, T>(&'w self) -> Query<'w, Mut<'w, T>>where
T: Component,
Geriye uyumluluk için StorageViewMut alternatifi
Sourcepub fn query_cached<'w, Q>(&'w mut self) -> Option<Query<'w, Q>>where
Q: WorldQuery,
pub fn query_cached<'w, Q>(&'w mut self) -> Option<Query<'w, Q>>where
Q: WorldQuery,
Cache’li query — archetype indeks cache’ini kullanır. &mut self gerektirdiği için sadece World sahibiyken çağrılabilir.
Sourcepub fn insert_batch<T>(&mut self, entities: &[Entity], component: T)
pub fn insert_batch<T>(&mut self, entities: &[Entity], component: T)
Sourcepub fn remove_batch<T>(&mut self, entities: &[Entity])where
T: Component,
pub fn remove_batch<T>(&mut self, entities: &[Entity])where
T: Component,
Toplu (Batch) component çıkarma
pub fn query_entity_mut<'w, Q>(
&'w mut self,
entity_id: u32,
) -> Option<<Q as WorldQuery>::Item<'w>>where
Q: WorldQuery,
Sourcepub fn query_entity<'w, Q>(
&'w self,
entity_id: u32,
) -> Option<<Q as WorldQuery>::Item<'w>>where
Q: WorldQuery,
pub fn query_entity<'w, Q>(
&'w self,
entity_id: u32,
) -> Option<<Q as WorldQuery>::Item<'w>>where
Q: WorldQuery,
Tek bir entity üzerinde read-only Query çalıştırıp anında sonuç almanızı sağlar.
Sourcepub fn entity_location(&self, entity_id: u32) -> EntityLocation
pub fn entity_location(&self, entity_id: u32) -> EntityLocation
Entity’nin archetype konumunu döndürür — O(1) lookup.
Sourcepub fn entity_count(&self) -> u32
pub fn entity_count(&self) -> u32
Toplam yaşayan entity sayısı
Sourcepub fn insert_resource<T>(&mut self, resource: T)
pub fn insert_resource<T>(&mut self, resource: T)
Sisteme global bir Resource ekler veya üzerine yazar.
Sourcepub fn get_resource<T>(&self) -> Option<ResourceReadGuard<'_, T>>where
T: 'static,
pub fn get_resource<T>(&self) -> Option<ResourceReadGuard<'_, T>>where
T: 'static,
Global bir Resource’u okumak için çağrılır (Immutable Borrow)
Sourcepub fn get_resource_mut<T>(&self) -> Option<ResourceWriteGuard<'_, T>>where
T: 'static,
pub fn get_resource_mut<T>(&self) -> Option<ResourceWriteGuard<'_, T>>where
T: 'static,
Global bir Resource’u değiştirmek için çağrılır (Mutable Borrow)
Sourcepub fn try_get_resource<T>(
&self,
) -> Result<ResourceReadGuard<'_, T>, ResourceFetchError>where
T: 'static,
pub fn try_get_resource<T>(
&self,
) -> Result<ResourceReadGuard<'_, T>, ResourceFetchError>where
T: 'static,
get_resource ile aynı işlev, ama hata sebebini Result ile taşır.
Sourcepub fn try_get_resource_mut<T>(
&self,
) -> Result<ResourceWriteGuard<'_, T>, ResourceFetchError>where
T: 'static,
pub fn try_get_resource_mut<T>(
&self,
) -> Result<ResourceWriteGuard<'_, T>, ResourceFetchError>where
T: 'static,
get_resource_mut ile aynı işlev, ama hata sebebini Result ile taşır.
Sourcepub fn get_resource_mut_or_default<T>(&mut self) -> ResourceWriteGuard<'_, T>
pub fn get_resource_mut_or_default<T>(&mut self) -> ResourceWriteGuard<'_, T>
Global bir Resource yoksa Default olarak oluşturur, ardından Mutable Borrow döndürür. World mutable borrow gerektirir, böylece hashmap’e güvenle kayıt yapılabilir.
Sourcepub fn remove_resource<T>(&mut self) -> Option<T>where
T: 'static,
pub fn remove_resource<T>(&mut self) -> Option<T>where
T: 'static,
Global bir Resource’u ECS’ten tamamen çıkartır ve sahipliğini döndürür
Sourcepub fn resource_scope<T, U, F>(&mut self, f: F) -> Option<U>
pub fn resource_scope<T, U, F>(&mut self, f: F) -> Option<U>
Bir resource’u geçici olarak world’den çıkarıp closure’a geçirir ve sonra geri koyar.
Bu, resource’un içindeyken &mut World kullanmanız gerektiğinde borrow checker’ı
mutlu etmenin en temiz yoludur (Bevy’deki resource_scope benzeri).
§Örnek
world.resource_scope::<PoolManager, ()>(|world, pool| {
pool.instantiate(world, "enemy");
});Sourcepub fn swap_archetype_rows(&mut self, arch_id: u32, row_a: usize, row_b: usize)
pub fn swap_archetype_rows(&mut self, arch_id: u32, row_a: usize, row_b: usize)
Belirli bir Archetype içindeki iki satırı güvenli bir şekilde takaslar ve entity lokasyonlarını günceller.
Sourcepub fn sort_archetype_hierarchy(&mut self)
pub fn sort_archetype_hierarchy(&mut self)
Aynı archetype’da bulunan ebeveyn ve çocuk düğümleri bellekte sırt sırta verecek şekilde kümelendirir. O(N) cache swap.
Trait Implementations§
Source§impl HierarchyExt for World
impl HierarchyExt for World
Source§fn despawn_recursive(&mut self, entity: Entity)
fn despawn_recursive(&mut self, entity: Entity)
Source§fn add_child(&mut self, parent: Entity, child: Entity)
fn add_child(&mut self, parent: Entity, child: Entity)
Parent and Children components.Source§fn remove_child(&mut self, parent: Entity, child: Entity)
fn remove_child(&mut self, parent: Entity, child: Entity)
Auto Trait Implementations§
impl Freeze for World
impl !RefUnwindSafe for World
impl Send for World
impl Sync for World
impl Unpin for World
impl UnsafeUnpin for World
impl !UnwindSafe for World
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
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>
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>
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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().