pub struct MultiGenerator<V: VoxelType> { /* private fields */ }Expand description
Composite generator that dispatches each chunk request to the first
RegionGenerator whose applies_to
returns true, falling back to a universal ChunkGenerator when none
match.
Itself implements ChunkGenerator<V>, so it is a drop-in replacement for
any single-generator setup and slots into the existing
GeneratorPlugin async pipeline with no changes.
§Dispatch order
Regions are walked in insertion order. The first region whose
applies_to returns true wins; later regions never see that chunk.
Order your regions from most specific to most general.
Implementations§
Source§impl<V: VoxelType> MultiGenerator<V>
impl<V: VoxelType> MultiGenerator<V>
Sourcepub fn new(fallback: Box<dyn ChunkGenerator<V>>) -> Self
pub fn new(fallback: Box<dyn ChunkGenerator<V>>) -> Self
Creates a MultiGenerator with the given universal fallback and no
regions. Add regions via add_region or
with_region.
Sourcepub fn add_region(&mut self, region: Box<dyn RegionGenerator<V>>) -> &mut Self
pub fn add_region(&mut self, region: Box<dyn RegionGenerator<V>>) -> &mut Self
Appends a region generator. Regions are tried in insertion order.
Sourcepub fn with_region(self, region: Box<dyn RegionGenerator<V>>) -> Self
pub fn with_region(self, region: Box<dyn RegionGenerator<V>>) -> Self
Builder-style variant of add_region.
Sourcepub fn with_fallback(self, fallback: Box<dyn ChunkGenerator<V>>) -> Self
pub fn with_fallback(self, fallback: Box<dyn ChunkGenerator<V>>) -> Self
Replaces the universal fallback.
Sourcepub fn region_count(&self) -> usize
pub fn region_count(&self) -> usize
Returns the number of registered regions (excluding the fallback).
Trait Implementations§
Auto Trait Implementations§
impl<V> !RefUnwindSafe for MultiGenerator<V>
impl<V> !UnwindSafe for MultiGenerator<V>
impl<V> Freeze for MultiGenerator<V>
impl<V> Send for MultiGenerator<V>
impl<V> Sync for MultiGenerator<V>
impl<V> Unpin for MultiGenerator<V>
impl<V> UnsafeUnpin for MultiGenerator<V>
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T ShaderType for self. When used in AsBindGroup
derives, it is safe to assume that all images in self exist.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
impl<T> ConditionalSend for Twhere
T: Send,
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>, which can then be
downcast into Box<dyn 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>, which 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> DowncastSend for T
impl<T> DowncastSend for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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 more