ecs

@motioneffector/ecs

A SQL-backed Entity Component System that brings database persistence, ACID guarantees, and powerful querying to game state management.

npm version license TypeScript

Features

Read the full manual →

Quick Start

import { createECS, defineComponent } from '@motioneffector/ecs'
import { createDatabase } from '@motioneffector/sql'

// Define component schemas
const Position = defineComponent('Position', { x: 'number', y: 'number' })
const Health = defineComponent('Health', { current: 'number', max: 'number' })

// Initialize ECS with your database
const db = createDatabase(':memory:')
const ecs = createECS(db, [Position, Health])
await ecs.initialize()

// Create entities and add components
const player = ecs.createEntity('player-1')
ecs.addComponent(player, Position, { x: 100, y: 200 })
ecs.addComponent(player, Health, { current: 80, max: 100 })

// Query entities by components
const entities = ecs.query([Position, Health])

Testing & Validation

License

MIT © motioneffector