@javelin/ecs
Advanced tools
Comparing version 0.1.0 to 0.1.2
@@ -6,2 +6,18 @@ # Change Log | ||
## 0.1.2 (2020-05-08) | ||
**Note:** Version bump only for package @javelin/ecs | ||
## 0.1.1 (2020-05-08) | ||
**Note:** Version bump only for package @javelin/ecs | ||
# 0.1.0 (2020-05-07) | ||
@@ -8,0 +24,0 @@ |
@@ -16,2 +16,3 @@ import { Component } from "./component"; | ||
* @param components Array of components | ||
* @returns void | ||
*/ | ||
@@ -23,2 +24,3 @@ insert(entity: number, components: Component[]): void; | ||
* @param entity Entity to associate components with | ||
* @returns void | ||
*/ | ||
@@ -25,0 +27,0 @@ remove(entity: number): void; |
@@ -14,4 +14,4 @@ "use strict"; | ||
} | ||
const last = cache.get(component) || 0; | ||
const hit = component._v > last; | ||
const last = cache.get(component); | ||
const hit = component._v > (last === undefined ? -1 : last); | ||
if (hit) { | ||
@@ -18,0 +18,0 @@ cache.set(component, component._v); |
{ | ||
"name": "@javelin/ecs", | ||
"version": "0.1.0", | ||
"version": "0.1.2", | ||
"main": "dist/index.js", | ||
"license": "MIT", | ||
"scripts": { | ||
"perf": "yarn build && node perf/index.js", | ||
"build": "tsc", | ||
"perf": "yarn build && node perf/index.js", | ||
"prepare": "yarn build" | ||
@@ -21,3 +21,3 @@ }, | ||
], | ||
"gitHead": "102f26f7092d6e665e7bb899ddbadf61eb477464" | ||
"gitHead": "6fd8a414e69f61e190a2d0536487e4ac2d4fc5cb" | ||
} |
# `@javelin/ecs` | ||
A simple, performant ECS for TypeScript. | ||
A TypeScript Entity-Component System (ECS) for Node and web browsers. | ||
## Primer | ||
ECS is a pattern commonly used in game development to associate components (state) with stateless entities (game objects). Systems then operate on collections of entities of shared composition. | ||
For example, a system could add a `Burn` component to entities with `Position` and `Health` components when their position intersects with a lava pit. | ||
## Features | ||
- **Performant** | ||
- Entities are organized based on their component makeup into Archetypes. This helps performance since the core model of ECS is to iterate over entities with like components. | ||
- Entities are organized by component makeup into Archetypes for fast iteration | ||
- Entities can be tagged with bit flags for quick filtering | ||
- **Ergonomic** | ||
- Minimal API. | ||
- Data-oriented design: no classes or inheritance. | ||
- Tag entities with bit flags for basic filtering. | ||
- Minimal API | ||
- No classes or inheritance | ||
- **Unopinionated** | ||
- Leaves many decisions up to you. For example, a helper for creating component instances is provided, but not required for library use. | ||
- Leaves many opinions up to you, meaning it can be integrated with other packages or pre-existing projects | ||
@@ -93,3 +99,3 @@ ## Performance | ||
Components created via factory are automatically pooled, but you must manually release the component back to the pool when it should be discarded: | ||
Components created via factory are automatically pooled; however, you must manually release the component back to the pool when it should be discarded: | ||
@@ -101,3 +107,3 @@ ```ts | ||
The ECS can do this automatically if you register the component factory via the `storage.registerComponentFactory` method. | ||
`Storage` can do this automatically if you register the component factory via the `storage.registerComponentFactory` method. | ||
@@ -191,4 +197,4 @@ ```ts | ||
enum Tags { | ||
Nasty = 1, // 2^0 | ||
Goopy = 2, // 2^1 | ||
Nasty = 2 ** 0, | ||
Goopy = 2 ** 1, | ||
} | ||
@@ -195,0 +201,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
296
70068
84
855