ma-ecs
v0.0.2
Published
fast and tiny object ecs
Downloads
3
Readme
ma-ecs
ma-ecs is
- tiny: adds ~3kb (minified) to your bundle when fully utilized
- precise: schedule systems and groups of systems
- familiar: use any value as data
- replicable: replicate entities and events with a built-in, extensible arraybuffer protocol
Installation
npm i ma-ecs
Other stuff
Complex type rules used for both querying and network replication
let Player = create_type(
// Match entities that...
any_of(
// have a changed position, velocity, or rotation
has_changed(Position),
has_changed(Velocity),
has_changed(Rotation),
),
// have a team
one_of(TeamA, TeamB),
// and are alive
not(Dead),
)
let write_stream_reliable = use_const(Stream.create_write_stream)
let write_stream_unreliable = use_const(Stream.create_write_stream)
let query = use_query(Player)
let encode = use_encode(Player)
query((p, v, r, t) => {})
// bifurcate the stream into reliable (ops) and unreliable (updates) streams
encode(write_stream_reliable, write_stream_unreliable)
// or, just write everything reliably
encode(write_stream_reliable)
// filter per-entity
encode(write_stream_reliable, (entity, world) => /* */)
Extending the network protocol
App.add_plugin(app, app => {
let protocol = app.get_resource(Protocol)
Protocol.extend(protocol, MY_MESSAGE_ID, read_stream => {
// decode message
})
})
Constraints
An entity cannot have more than 255 components included in the same update.