Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace World

A module used to create and manage worlds—the root object of a Harmony game.

Index

Classes

Type aliases

Functions

Type aliases

Struct

Struct: { rootArchetype: Archetype.Struct; entityHead: number; entityIndex: (Archetype.Struct | undefined)[]; schemaIndex: Schema.AnySchema[]; size: number }

The root object of the ECS. A world maintains entity identifiers, stores schemas, and associates components with entities in tables called archetypes: collections of entities that share the same component makeup.

Archetypes are stored in a connected graph structure, where each node is linked to adjacent archetypes by the addition or removal or a single component type. An entity's archetype is selected based on its current component composition. An entity can belong only to a single archetype at a time.

Entities without any components (e.g. destroyed entities) are never discarded, but moved to the world's root archetype.

Type declaration

  • rootArchetype: Archetype.Struct
  • entityHead: number
  • entityIndex: (Archetype.Struct | undefined)[]
  • schemaIndex: Schema.AnySchema[]
  • size: number

Functions

make

  • Create a world. Requires a maximum entity size which is used to allocate fixed memory for binary component arrays.

    example

    Create a world capable of storing one million entities

    const world = World.make(1e6)
    

    Parameters

    • size: number

    Returns World.Struct

Generated using TypeDoc