Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@rbxts/ecr

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rbxts/ecr

A sparse-set based ECS library for Luau, now with TS types.

latest
Source
npmnpm
Version
0.9.0-ts.0
Version published
Maintainers
1
Created
Source
ecr-ts logo

Fork of ecr for Roblox-ts.

Differences to Luau version

  • TS has no length operator, instead use .size(). Queues and Pools have it as a property, .size
  • Components don't need to be casted, instead supply the generic
  • This package is versioned with <ecr version>-ts.<x> where x is incremented for any changes to the TS version in particular

Code Sample

import ecr, { Registry } from "@rbxts/ecr";

// define components
const Position = ecr.component<Vector3>();
const Velocity = ecr.component<Vector3>();

// define a system
function update_physics(world: Registry, dt: number) {
	for (const [id, pos, vel] of world.view(Position, Velocity)) {
		world.set(id, Position, pos.add(vel.mul(dt)));
	}
}

// instantiate the world
const world = ecr.registry();

// create entities and assign components
for (const i of $range(1, 10)) {
	const id = world.create();
	world.set(id, Position, new Vector3(i, 1, 1));
	world.set(id, Velocity, new Vector3(10, 0, 0));
}

// run system
update_physics(world, 1/60);

FAQs

Package last updated on 21 May 2025

Did you know?

Socket

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.

Install

Related posts