Skip to content
This repository has been archived by the owner on Dec 23, 2022. It is now read-only.

Releases: grebaldi/nopun-ecs

More Query Operations

21 May 08:40
Compare
Choose a tag to compare

This Release adds more query operations, namely:

  • And(...)
  • Or(...)
  • Not(...) - This one existed before, but now accepts multiple arguments
  • Xor(...)

These can be used like this:

import { System, Or } from "nopun-ecs";

class CollisionSystem extends System {
    static queries = {
        npcs: [CollisionShape, Or(Friend, Enemy)],
        player: [CollisionShape, Player]
    };
}

Additionally, this Release adds two new Methods to entities:

entity.put(CC: ComponentConstructor, value?: object): Entity
This method adds the given component if it has not been added before, otherwise it updates it.

entity.take(...CCs: ComponentConstructor[]): Generator<C[]>
This method will check for the existence of multiple components and will only yield a result, if all components are present.