Creates an entity that matches a specific archetype.
Type-safe entity creation using pre-defined archetypes. Validates that all required components are present and generates an ID if not provided.
The archetype definition with required components.
The component values for the entity.
A new entity matching the archetype.
If any required archetype components are missing.
// Using built-in archetypesconst movable = createFromArchetype( ARCHETYPES.MOVABLE, { position: { x: 0, y: 0, z: 0 }, velocity: { x: 1, y: 0, z: 0 } }); Copy
// Using built-in archetypesconst movable = createFromArchetype( ARCHETYPES.MOVABLE, { position: { x: 0, y: 0, z: 0 }, velocity: { x: 1, y: 0, z: 0 } });
// Custom archetypeconst PLAYER_ARCHETYPE: Archetype<GameEntity> = { name: 'player', components: ['position', 'health', 'inventory'], tags: ['player', 'combat']};const player = createFromArchetype(PLAYER_ARCHETYPE, { position: { x: 0, y: 0, z: 0 }, health: 100, inventory: []}); Copy
// Custom archetypeconst PLAYER_ARCHETYPE: Archetype<GameEntity> = { name: 'player', components: ['position', 'health', 'inventory'], tags: ['player', 'combat']};const player = createFromArchetype(PLAYER_ARCHETYPE, { position: { x: 0, y: 0, z: 0 }, health: 100, inventory: []});
Creates an entity that matches a specific archetype.
Type-safe entity creation using pre-defined archetypes. Validates that all required components are present and generates an ID if not provided.