# menhera-ecs

> ```bash $ yarn menhera menhera-ecs ```

Latest version **0.0.3** (published 2018-05-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install menhera-ecs
pnpm add menhera-ecs
yarn add menhera-ecs
bun add menhera-ecs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2018-05-10 |
| First published | 2018-05-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | vaiii |

## Links

- npm: https://www.npmjs.com/package/menhera-ecs
- npm.io page: https://npm.io/package/menhera-ecs

## Dependencies (3)

- [menhera](https://npm.io/package/menhera.md) ^0.7.8-rc1
- [menhera-cli](https://npm.io/package/menhera-cli.md) ^0.3.1-rc4
- [menhera-utils](https://npm.io/package/menhera-utils.md) ^0.0.1

## Recent versions

- 0.0.3 (latest) — 2018-05-10
- 0.0.2 — 2018-05-10
- 0.0.1 — 2018-05-09

## README

## Install

```bash
$ yarn menhera menhera-ecs
```

## Example

```js
import Mhr from "menhera";
import ECS from "menhera-ecs";

let moveSystem = {
  system: {},
  methods: {
    update() {
      let entities = this.engine.get(["Position", "Velocity"]);
      entities.forEach(e => {
        console.log(e);
        e.Position.x += e.Velocity.x;
        e.Position.y += e.Velocity.y;
      });
    }
  }
};

let recycleSystem = {
  system: {},
  methods: {
    update() {
      let entities = this.engine.get(["~Components"]);
      entities.forEach(e => {
        let cps = [...e["~Components"], "~Components"];
        this.engine.removeComponents(cps, e);
      });
    }
  }
};

let Entities1 = {
  entity: {},
  components: {
    Name: "Entities1",
    Position: {
      x: 1,
      y: 1
    },
    Velocity: {
      x: 1,
      y: 1
    }
  }
};

let Entities2 = {
  entity: {},
  components: {
    Name: "Entities2",
    Position: {
      x: 1,
      y: 1
    },
    Velocity: {
      x: 2,
      y: 2
    }
  }
};

Mhr.$use({
  _mount: {
    ECS
  },
  _run: {
    Systems: [testSystem, moveSystem, recycleSystem],
    Entities: [Entities1, Entities2]
  }
});

setInterval(() => {
  ECS.update();
}, 1000 / 60);
```

---
_Source: https://npm.io/package/menhera-ecs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
