pub struct Spawner {
pub template: AssetId,
pub interval: f32,
pub lifetime: f32,
pub elapsed: f32,
pub count: u32,
}Expand description
Periodically instantiates copies of an existing placement at this entity’s position.
A spawner clones template (the name of another placement in the world)
every interval seconds, giving each copy a lifetime after which it is
automatically removed. Pairing a short lifetime with a short interval keeps a
bounded population churning (an enemy wave, a particle of debris, a fountain
of props) and is what exercises GPU draw-slot recycling: each expiry frees a
slot the next spawn reuses.
The spawner’s own Transform (its position) is where copies appear, so place
the spawner where you want the stream to originate.
Fields§
§template: AssetIdName of the placement to copy on each spawn.
interval: f32Seconds between spawns.
lifetime: f32Seconds each spawned copy lives before auto-removal; 0 keeps it forever.
elapsed: f32Runtime: seconds accumulated toward the next spawn.
count: u32Runtime: number of copies spawned so far.
Implementations§
Trait Implementations§
Source§impl Component for Spawner
impl Component for Spawner
Source§fn from_baked(bytes: &[u8]) -> Result<Spawner, CnResult>
fn from_baked(bytes: &[u8]) -> Result<Spawner, CnResult>
Source§fn inject_locator(&mut self, _locator: PayloadLocator)
fn inject_locator(&mut self, _locator: PayloadLocator)
Source§fn inject_name(&mut self, _id: AssetId)
fn inject_name(&mut self, _id: AssetId)
Source§impl ComponentSlot for Spawner
impl ComponentSlot for Spawner
Source§const DISCRIMINANT: u8
const DISCRIMINANT: u8
ComponentId.Source§impl<'de> Deserialize<'de> for Spawner
impl<'de> Deserialize<'de> for Spawner
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Spawner, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Spawner, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<Spawner> for ComponentAsset
impl From<Spawner> for ComponentAsset
Source§fn from(c: Spawner) -> ComponentAsset
fn from(c: Spawner) -> ComponentAsset
impl RuntimeComponent for Spawner
Source§impl Serialize for Spawner
impl Serialize for Spawner
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for Spawner
impl RefUnwindSafe for Spawner
impl Send for Spawner
impl Sync for Spawner
impl Unpin for Spawner
impl UnsafeUnpin for Spawner
impl UnwindSafe for Spawner
Blanket Implementations§
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> 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