
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
ecs-machina
Advanced tools
A zero-dependency TypeScript Entity-Component-System Library
npm install ecs-machina
ECS-Machina is first and foremost a TypeScript library; it's meant to be used in TypeScript projects to take full advantage of its typing system.
I created this library to be used in TIC-80 projects, and so it has 0 dependency and is ES5-compatible. You can "install" it by copy-pasting the whole index.ts file in your own project.
// Create a world to hold your entities and components
const world = new World()
Components must be declared through the Component()
abstract factory. It returns a Component Factory, that can be used to create new components and to query the World.
// With explicit types
const Position = Component<{ x: number; y: number }>()
// With default values, and implied types
const Velocity = Component({ dx: 0, dy: 0 })
// You can also declare "tag" Components that have no attributes
const IsMonster = Component()
/*
* Add Entities to your World
*/
// Without any component
const entityA = world.spawn()
// With one or several components
const entityB = world.spawn(
Position({ x: 10, y: 25 }),
Velocity({ x: 0, y: 1 })
)
// Or with the default values, if components provide them
const entityC = world.spawn(Position())
ECS-Machina does not have Systems, but has a simple query()
function and a runSystems()
helper.
// You can create a "system" like this, a simple function that
// takes the whole World as a parameter.
function movementSystem(world: World) {
const entities = world.query(Position, Velocity)
for (const [e, pos, vel] of entities) {
console.log(`Moving entity ${e}`)
// Component instances are correctly typed for efficient auto-completion
pos.x += vel.dx
pos.y += vel.dy
}
}
function attackSystem(world: World) {
/* ... */
}
// Call `runSystems` to execute Systems within your World context
world.runSystems(movementSystem, attackSystem)
Games built with an ECS engine have a lot of different components and systems. Strong typings (and efficient autocompletion) is an essential feature to not get lost in your own code.
We have a strong decoupling between the World, the Components, and the Systems. The goal is to let you write code that you can truly reuse throughout your projects.
The world.query()
function has an efficient and transparent caching system, to provide the fastest iteration speed possible.
The trade-off is that adding/removing/updating entity is relatively slower, because the cache needs to be updated each time.
This is a work-in-progress (as ECS-Machina itself is under development), but we aim for 100% of code coverage.
This library was inspired by PECS, a PICO-8 ECS library.
FAQs
Entity-Component-System Engine
The npm package ecs-machina receives a total of 0 weekly downloads. As such, ecs-machina popularity was classified as not popular.
We found that ecs-machina demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.