concinnity_core/components/spawn_request.rs
1// src/components/spawn_request.rs
2
3use crate::components::Transform;
4use crate::ecs::asset_id::AssetId;
5
6/// Runtime-only event requesting that a copy of an existing placement be created
7/// in the world at runtime. The symmetric counterpart to DespawnRequest.
8///
9/// `template` names a placement already present in the world; the new instance
10/// reuses that placement's geometry and material at a fresh `transform`. A
11/// `name` registers the instance so it can later be addressed (despawned,
12/// reparented) like any authored placement; `None` spawns a transient copy,
13/// like a Spawner's cadence spawns. An optional `lifetime_secs` attaches a
14/// Lifetime so the instance auto-despawns after that many seconds, the churn
15/// that lets freed draw slots be recycled. GraphicsSystem reads these from its
16/// `Events<SpawnRequest>` queue each step. World authors never declare this type
17/// directly.
18#[derive(Debug, Clone, Copy, Default)]
19pub struct SpawnRequest {
20 /// The placement to copy geometry and material from.
21 pub template: AssetId,
22 /// Name to register the instance under, or `None` for a transient copy.
23 pub name: Option<AssetId>,
24 /// Where to place the new instance.
25 pub transform: Transform,
26 /// Seconds before the instance auto-despawns, when set.
27 pub lifetime_secs: Option<f32>,
28}