Loading...
Loading...
Use Miniplex for minimalistic Entity Component System with TypeScript support.
npx skill4agent add verekia/r3f-gamedev miniplexminiplex-reactEntitiesworld.with('prop1', 'prop2')world.add()world.remove()world.addComponent()world.removeComponent()<Entities in={query}>{Component}</Entities>onEntityAddedonEntityRemoved.where()world.add(entity)world.remove(entity)world.addComponent(entity, 'component', value)world.removeComponent(entity, 'component')world.with('prop1', 'prop2')// ecs/queries.ts
export const characterQuery = world.with('position', 'isCharacter')
export const enemyQuery = world.with('position', 'isEnemy')
export const movingEntities = world.with('position', 'velocity')
// In a system file
import { movingEntities } from './ecs/queries'type Entity = {
position?: { x: number; y: number }
isCharacter?: true
}
const world = new World<Entity>()
const characters = world.with('position', 'isCharacter')
// Add entity
world.add({ position: { x: 0, y: 0 }, isCharacter: true })
// Render
<Entities in={characters}>{Character}</Entities>