ecstc/README.md
2024-12-02 02:09:33 -06:00

779 B

CI

ecstc

This is a library.

ECS

Entities

Components

Systems

Queries

Serialization

ecstc works with crunches for binary serialization:

import {Codecs} from 'crunches';
import {Ecs, registerCodecs} from 'ecstc';

registerCodecs(Codecs);

const ecs = new Ecs({Components: {}, Systems: {}});
ecs.create(); // now has entity ID: 1 with no components

const schema = new Schema({ecs, type: 'ecstc-ecs'});
const view = schema.allocate(ecs.entities);
schema.encode(ecs.entities, view);
console.log(schema.decode(view)) // Map(1) { 1 => {} }
// or,
schema.encode(ecs.diff(), view);
console.log(schema.decode(view)) // Map(1) { 1 => {} }