Skip to main content

World

Struct World 

Source
pub struct World {
    pub tick: u32,
    /* private fields */
}

Fields§

§tick: u32

Implementations§

Source§

impl World

Source

pub fn new() -> World

Source

pub fn increment_tick(&mut self)

Increments the local tick counter, guaranteeing it skips 0 on wrap.

Source

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

Source

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.

Source

pub fn add_observer<T, F>(&mut self, system: F) -> &mut World
where T: Component, F: FnMut(On<Insert, T>) + Send + Sync + 'static,

Registers a Component hook (Observer) for OnInsert.

Source

pub fn observe<E, F>(&mut self, entity: Entity, listener: F) -> &mut World
where E: EntityEvent, F: FnMut(On<E>) + Send + Sync + 'static,

Özel EntityEvent’ler için Entity bazlı Observer kaydı

Source

pub fn trigger<E>(&mut self, event: E)
where E: EntityEvent,

Bir Event’i tetikler ve hiyerarşide yukarı doğru yayar (bubble-up)

Source

pub fn is_component_registered<T>(&self) -> bool
where T: Component,

Belirli bir component turu kayitli mi?

Source

pub fn registered_component_count(&self) -> usize

Kayitli component metadata sayisi.

Source

pub fn register_on_add<T>( &mut self, hook: Box<dyn FnMut(&mut World, Entity) + Send + Sync>, )
where T: Component,

Source

pub fn register_on_remove<T>( &mut self, hook: Box<dyn FnMut(&mut World, Entity) + Send + Sync>, )
where T: Component,

Source

pub fn register_on_set<T>( &mut self, hook: Box<dyn FnMut(&mut World, Entity) + Send + Sync>, )
where T: Component,

Source

pub fn spawn(&mut self) -> Entity

Source

pub fn spawn_bundle<B>(&mut self, bundle: B) -> Entity
where 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()
});
Source

pub fn flush_spawn(&mut self, entity: Entity)

Source

pub fn get_entity(&self, id: u32) -> Option<Entity>

Source

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.

Source

pub fn register_despawn_hook( &mut self, hook: Box<dyn FnMut(&mut World, Entity) + Send + Sync>, )

Source

pub fn spawn_batch<I>(&mut self, iter: I) -> impl Iterator<Item = Entity>
where I: IntoIterator, <I as IntoIterator>::Item: Bundle,

Source

pub fn clear_entities(&mut self)

Tüm entityleri temizler.

Source

pub fn despawn(&mut self, entity: Entity)

Source

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.

Source

pub fn despawn_by_id(&mut self, id: u32)

Source

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!

Source

pub fn is_alive(&self, entity: Entity) -> bool

Source

pub fn add_bundle<B>(&mut self, entity: Entity, bundle: B)
where B: Bundle,

Sisteme component ekleme — Veriyi archetype sütununa taşır.

Source

pub fn remove_bundle<B>(&mut self, entity: Entity)
where B: Bundle,

Source

pub fn add_component<T>(&mut self, entity: Entity, component: T)
where T: Component,

Source

pub fn get_entity_component_types(&self, entity: Entity) -> Vec<TypeId>

Entity üzerindeki tüm bileşenlerin TypeId’lerini döndürür.

Source

pub fn get_component_ptr( &self, entity: Entity, type_id: TypeId, ) -> Option<*const u8>

Raw Component Pointer alma (Reflection/Editor için)

Source

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)

Source

pub fn reconstruct_entity(&self, id: u32) -> Option<Entity>

Entity ID’sinden geçerli nesneyi tekrar yapılandırır

Source

pub fn remove_component<T>(&mut self, entity: Entity)
where T: Component,

Sistemden component silme

Source

pub fn query<'w, Q>(&'w self) -> Option<Query<'w, Q>>
where Q: WorldQuery,

Source

pub fn borrow<'w, T>(&'w self) -> Query<'w, &'w T>
where T: Component,

Geriye uyumluluk için StorageView alternatifi

Source

pub fn borrow_mut<'w, T>(&'w self) -> Query<'w, Mut<'w, T>>
where T: Component,

Geriye uyumluluk için StorageViewMut alternatifi

Source

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.

Source

pub fn insert_batch<T>(&mut self, entities: &[Entity], component: T)
where T: Component + Clone,

Tek bir entity üzerinde Query çalıştırıp anında sonuç almanızı sağlar.

§Örnek
if let Some((mut t, mut v)) = world.query_entity_mut::<(Mut<Transform>, Mut<Velocity>)>(id) {
    t.position += v.linear * dt;
}

Toplu (Batch) component ekleme. O(N) archetype lookup maliyetini O(1)’e düşürür.

Source

pub fn remove_batch<T>(&mut self, entities: &[Entity])
where T: Component,

Toplu (Batch) component çıkarma

Source

pub fn query_entity_mut<'w, Q>( &'w mut self, entity_id: u32, ) -> Option<<Q as WorldQuery>::Item<'w>>
where Q: WorldQuery,

Source

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.

Source

pub fn entity_location(&self, entity_id: u32) -> EntityLocation

Entity’nin archetype konumunu döndürür — O(1) lookup.

Source

pub fn entity_count(&self) -> u32

Toplam yaşayan entity sayısı

Source

pub fn insert_resource<T>(&mut self, resource: T)
where T: Send + Sync + 'static,

Sisteme global bir Resource ekler veya üzerine yazar.

Source

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)

Source

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)

Source

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.

Source

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.

Source

pub fn get_resource_mut_or_default<T>(&mut self) -> ResourceWriteGuard<'_, T>
where T: Default + Send + Sync + 'static,

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.

Source

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

Source

pub fn resource_scope<T, U, F>(&mut self, f: F) -> Option<U>
where T: Send + Sync + 'static, F: FnOnce(&mut World, &mut T) -> 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");
});
Source

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.

Source

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 Default for World

Source§

fn default() -> World

Returns the “default value” for a type. Read more
Source§

impl HierarchyExt for World

Source§

fn despawn_recursive(&mut self, entity: Entity)

Despawns an entity and all of its descendants recursively.
Source§

fn add_child(&mut self, parent: Entity, child: Entity)

Adds a child to a parent entity, updating both Parent and Children components.
Source§

fn remove_child(&mut self, parent: Entity, child: Entity)

Removes a child from a parent entity.
Source§

impl WorldExt for World

Source§

fn entity_named(&self, name: &str) -> Option<u32>

İsme göre Entity ID’sini (u32) bul.
Source§

fn move_entity_named<F: FnMut(&mut Transform)>(&mut self, name: &str, f: F)

İsme göre entity’nin Transform’unu değiştir. Transform matrisi otomatik güncellenir.
Source§

fn position_of(&self, name: &str) -> Option<Vec3>

İsme göre entity’nin dünya pozisyonunu al.
Source§

fn modify<T: Component + 'static, F: FnMut(&mut T)>(&mut self, name: &str, f: F)

İsme göre herhangi bir bileşeni değiştir. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

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>

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)

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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,