Skip to main content

latest

TypeScript entity component system favouring simple objects.

This package works with Node.js, Deno, Bun, BrowsersIt is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
94%
Published
7 months ago (0.1.7)
class Archetype

An archetype is a collection of entities that share the same components. Archetypes should not be constructed directly, but rather through the World class using the World#archetype method.

Constructors

new
Archetype(unnamed 0: { world: World<Entity>; entities: Set<Entity>; components: Components; without?: Array<Exclude<keyof Entity, Components[number]>>; })

Type Parameters

Entity extends JsonObject
Components extends Array<keyof Entity>

Properties

readonly
components: Readonly<Components>
readonly
entities: ReadonlySet<SafeEntity<Entity, Components[number]>>
readonly
excluding: Readonly<Array<Exclude<keyof Entity, Components[number]>>>

Methods

Verify if the entity matches the archetype components criteria.

without<Component extends keyof Entity>(...components: Component[]): Archetype<SafeEntity<Omit<Entity, (components)[number]>, Exclude<Components[number], (components)[number]>>, Array<Exclude<Components[number], (components)[number]>>>

Returns a new archetype based on the current archetype, but excludes the specified components.

Add Package

deno add jsr:@gamedev/objecs

Import symbol

import { Archetype } from "@gamedev/objecs";

---- OR ----

Import directly with a jsr specifier

import { Archetype } from "jsr:@gamedev/objecs";

Add Package

npx jsr add @gamedev/objecs

Import symbol

import { Archetype } from "@gamedev/objecs";

Add Package

yarn dlx jsr add @gamedev/objecs

Import symbol

import { Archetype } from "@gamedev/objecs";

Add Package

pnpm dlx jsr add @gamedev/objecs

Import symbol

import { Archetype } from "@gamedev/objecs";

Add Package

bunx jsr add @gamedev/objecs

Import symbol

import { Archetype } from "@gamedev/objecs";