Level

Struct Level 

Source
pub struct Level {
    pub chunks: ChunkStorage,
    pub entities: EntityStorage,
    /* private fields */
}
Expand description

Main storage for a level, part of a World. This structure is intentionally not Sync + Send, however each chunk is stored in a RwLock in order to make them shared across threads if you want.

Fields§

§chunks: ChunkStorage

Chunk storage.

§entities: EntityStorage

Entities storage.

Implementations§

Source§

impl Level

Source

pub fn new<S>( id: String, env: Arc<LevelEnv>, height: ChunkHeight, source: S, ) -> Self
where S: LevelSource + 'static,

Source

pub fn get_id(&self) -> &String

Return the unique ID (unique in the owning world).

Source

pub fn get_env(&self) -> &Arc<LevelEnv>

Return the level environment used by this level.

Source

pub fn get_height(&self) -> ChunkHeight

Return the minimum and maximum chunks position allowed in this world. The limits can -128 to 127, it is more than enough.

Source

pub fn request_chunk_load(&mut self, cx: i32, cz: i32) -> bool

Request internal level source to load the given chunk.

Source

pub fn load_chunks_with_callback<F>(&mut self, callback: F)

Poll loaded chunks from internal level source, all successfully loaded chunks are added to the underlying LevelStorage. The callback is called for each loaded chunks or loading error.

Source

pub fn load_chunks(&mut self)

Poll loaded chunks from internal level source, all successfully loaded chunks are added to the underlying LevelStorage.

Source

pub fn get_loading_chunks_count(&self) -> usize

Returns the number of chunks being loaded or queued for loading (use load_chunks or load_chunks_with_callback to load actually them.

Source

pub fn request_chunk_save(&mut self, cx: i32, cz: i32) -> bool

Source

pub fn spawn_entity( &mut self, entity_type: &'static EntityType, pos: EntityPos, ) -> Option<Entity>

Auto Trait Implementations§

§

impl !Freeze for Level

§

impl !RefUnwindSafe for Level

§

impl !Send for Level

§

impl !Sync for Level

§

impl Unpin for Level

§

impl !UnwindSafe for Level

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.