3.2.2 • Published 2 years ago

@curbl/ecs v3.2.2

Weekly downloads
54
License
MIT
Repository
github
Last release
2 years ago

CURBL-ECS

curbl-ecs is a lightweight Entity Component.

Example

  • Creating a Component
import { ECS } from '@curbl/ecs';

const ecs = new ECS();

@ecs.Component('Position') 
class PositionComponent {
    x: number = 0;
    y: number = 0;
}
  • Adding a Entity with components
const ecs = new ECS();
const entity = ecs.addEntity(new PositionComponent());
  • Create entity and add Component
const ecs = new ECS();
const entity = ecs.addEntity();
entity.add(new PositionComponent());
  • Get Component from Entity
entity.get<PositionComponent>('Position').x = 42;
  • Creating a System
const ecs = new ECS();

@ecs.System('Position')
export class MySystem {

    setUp(): void {
        //Called when the System is created/added to the ECS 
    }

    tearDown(): void {
        //Called when the System is removed from the ECS
    }

    update(): void {
        const entities = this.entities();
        for (let i = 0, entity: Entity; entity = entities[i]; i++) {
            //Do stuff with the entities
        }
    }
}
3.2.2

2 years ago

3.2.1

2 years ago

3.2.1-9

2 years ago

3.2.1-8

2 years ago

3.2.1-7

2 years ago

3.2.1-4

2 years ago

3.2.1-3

2 years ago

3.2.1-6

2 years ago

3.2.1-5

2 years ago

3.2.0-0

2 years ago

3.2.1-2

2 years ago

3.1.0

3 years ago

3.0.0

3 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.2

5 years ago