Struct voxelize::World

source ·
pub struct World {
    pub id: String,
    pub name: String,
    pub started: bool,
    pub preloading: bool,
    pub preload_progress: f32,
    /* private fields */
}
Expand description

A voxelize world.

Fields§

§id: String

ID of the world, generated from nanoid!().

§name: String

Name of the world, used for connection.

§started: bool

Whether if the world has started.

§preloading: bool

Whether if the world is preloading.

§preload_progress: f32

The progress of preloading.

Implementations§

source§

impl World

source

pub fn new(name: &str, config: &WorldConfig) -> Self

Create a new voxelize world.

source

pub fn ecs(&self) -> &ECSWorld

Get a reference to the ECS world..

source

pub fn ecs_mut(&mut self) -> &mut ECSWorld

Get a mutable reference to the ECS world.

source

pub fn add<T: Component>(&mut self, e: Entity, c: T)

Insert a component into an entity.

source

pub fn remove<T: Component>(&mut self, e: Entity)

Remove a component type from an entity.

source

pub fn read_resource<T: Resource>(&self) -> Fetch<'_, T>

Read an ECS resource generically.

source

pub fn write_resource<T: Resource>(&mut self) -> FetchMut<'_, T>

Write an ECS resource generically.

source

pub fn read_component<T: Component>(&self) -> ReadStorage<'_, T>

Read an ECS component storage.

source

pub fn write_component<T: Component>(&mut self) -> WriteStorage<'_, T>

Write an ECS component storage.

source

pub fn get_id(&self, entity: Entity) -> String

Get an ID from IDComp from an entity

source

pub fn set_dispatcher<F: Fn() -> DispatcherBuilder<'static, 'static> + 'static>( &mut self, dispatch: F )

source

pub fn set_client_modifier<F: Fn(&mut World, Entity) + 'static>( &mut self, modifier: F )

source

pub fn set_client_parser<F: Fn(&mut World, &str, Entity) + 'static>( &mut self, parser: F )

source

pub fn set_method_handle<F: Fn(&mut World, &str, &str) + 'static>( &mut self, method: &str, handle: F )

source

pub fn set_event_handle<F: Fn(&mut World, &str, &str) + 'static>( &mut self, event: &str, handle: F )

source

pub fn set_transport_handle<F: Fn(&mut World, Value) + 'static>( &mut self, handle: F )

source

pub fn set_command_handle<F: Fn(&mut World, &str, &str) + 'static>( &mut self, handle: F )

source

pub fn set_entity_loader<F: Fn(&mut World, MetadataComp) -> EntityBuilder<'_> + 'static>( &mut self, etype: &str, loader: F )

source

pub fn broadcast(&mut self, data: Message, filter: ClientFilter)

Broadcast a protobuf message to a subset or all of the clients in the world.

source

pub fn send(&self, addr: &Recipient<EncodedMessage>, data: &Message)

Send a direct message to an endpoint

source

pub fn config(&self) -> Fetch<'_, WorldConfig>

Access to the world’s config.

source

pub fn clients(&self) -> Fetch<'_, Clients>

Access all clients in the ECS world.

source

pub fn clients_mut(&mut self) -> FetchMut<'_, Clients>

Access a mutable clients map in the ECS world.

source

pub fn registry(&self) -> Fetch<'_, Registry>

Access the registry in the ECS world.

source

pub fn chunks(&self) -> Fetch<'_, Chunks>

Access chunks management in the ECS world.

source

pub fn chunks_mut(&mut self) -> FetchMut<'_, Chunks>

Access a mutable chunk manager in the ECS world.

source

pub fn physics(&self) -> Fetch<'_, Physics>

Access physics management in the ECS world.

source

pub fn physics_mut(&mut self) -> FetchMut<'_, Physics>

Access a mutable physics manager in the ECS world.

source

pub fn chunk_interest(&self) -> Fetch<'_, ChunkInterests>

Access the chunk interests manager in the ECS world.

source

pub fn chunk_interest_mut(&mut self) -> FetchMut<'_, ChunkInterests>

Access the mutable chunk interest manager in the ECS world.

source

pub fn events(&self) -> Fetch<'_, Events>

Access the event queue in the ECS world.

source

pub fn events_mut(&mut self) -> FetchMut<'_, Events>

Access the mutable events queue in the ECS world.

source

pub fn search(&self) -> Fetch<'_, Search>

Access the search tree in the ECS world.

source

pub fn search_mut(&mut self) -> FetchMut<'_, Search>

Access the mutable search tree in the ECS world.

source

pub fn stats(&self) -> Fetch<'_, Stats>

Access the stats manager in the ECS world.

source

pub fn stats_mut(&mut self) -> FetchMut<'_, Stats>

Access the mutable stats manager in the ECS world.

source

pub fn pipeline(&self) -> Fetch<'_, Pipeline>

Access pipeline management in the ECS world.

source

pub fn pipeline_mut(&mut self) -> FetchMut<'_, Pipeline>

Access a mutable pipeline management in the ECS world.

source

pub fn mesher(&self) -> Fetch<'_, Mesher>

Access the mesher in the ECS world.

source

pub fn mesher_mut(&mut self) -> FetchMut<'_, Mesher>

Access a mutable mesher in the ECS world.

source

pub fn create_base_entity(&mut self, id: &str, etype: &str) -> EntityBuilder<'_>

Create a basic entity ready to be added more.

source

pub fn create_entity(&mut self, id: &str, etype: &str) -> EntityBuilder<'_>

Create a basic entity ready to be added more.

source

pub fn create_block_entity( &mut self, id: &str, etype: &str ) -> EntityBuilder<'_>

Create a basic entity ready to be added more.

source

pub fn spawn_entity_at( &mut self, etype: &str, position: &Vec3<f32> ) -> Option<Entity>

Spawn an entity of type at a location.

source

pub fn revive_entity( &mut self, id: &str, etype: &str, metadata: MetadataComp ) -> Option<Entity>

source

pub fn populate_entity( &mut self, ent: Entity, id: &str, etype: &str, metadata: MetadataComp )

source

pub fn is_empty(&self) -> bool

Check if this world is empty.

Auto Trait Implementations§

§

impl Freeze for World

§

impl !RefUnwindSafe for World

§

impl !Send for World

§

impl !Sync for World

§

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

source§

fn from(t: T) -> T

Returns the argument unchanged.

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

source§

const ALIGN: usize = _

The alignment of pointer.
§

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

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

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

§

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

§

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