pub struct World {
pub time: WorldInstant,
pub chunks: Vec<Option<Chunk>>,
}
Expand description
Contains all the game state.
Fields
time: WorldInstant
The timestamp of the world currently.
chunks: Vec<Option<Chunk>>
The chunks the world consists of. The server’s chunks will never be None, but the client’s will. Only the chunks around the player character will be Some on the client-side, to save on network bandwidth and client-side performance.
Implementations
sourceimpl World
impl World
sourcepub fn empty() -> World
pub fn empty() -> World
Creates an empty world at time 0. A starting point for a client to apply ChunkUpdates to, as they come from the server.
sourcepub fn apply_effects(
&mut self,
chunk_index: usize,
chunk_effects: Vec<Effect>
) -> bool
pub fn apply_effects(
&mut self,
chunk_index: usize,
chunk_effects: Vec<Effect>
) -> bool
Applies the given effects to the chunk, and returns false if the chunk being affected is not loaded.
sourcepub fn update(&mut self)
pub fn update(&mut self)
Does deterministic simulation of the game state for one time step, and increments World::time by 1.
sourcepub fn get_player_character(
&self,
handle: PcHandle
) -> Option<(usize, &PlayerCharacter)>
pub fn get_player_character(
&self,
handle: PcHandle
) -> Option<(usize, &PlayerCharacter)>
Returns the player character and the index of the chunk where the player character is.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for World
impl Send for World
impl Sync for World
impl Unpin for World
impl UnwindSafe for World
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more