TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Ukendio/jecs/llms.txt
Use this file to discover all available pages before exploring further.
World is the main container for all entities, components, and systems in jecs. It manages the ECS registry and provides methods for entity manipulation, querying, and lifecycle management.
Creating a World
world()
Creates a new World instance.Enable debug mode for better error messages and assertions
World
Entity Management
entity()
Creates a new entity in the world.Optional entity ID to create. If provided, creates an entity with that specific ID.
Entity (Tag if no ID provided)
component()
Creates a new component entity in the first 256 IDs for fast access. These are static components optimized for performance.The type of data this component will store
Entity<TData>
delete()
Completely removes an entity from the world, including all its components and relationships.The entity to delete
clear()
Removes all components and relationships from an entity, but keeps the entity alive in the world.The entity to clear
contains()
Checks if an entity exists in the world.The entity to check
boolean
exists()
Checks if an entity with the given ID is currently alive, ignoring its generation.The entity to verify
boolean
Component Operations
set()
Sets a component value on an entity, or installs a hook on a component.Set Component Value
The target entity
The component or pair to set
The value to store
Install Hook
The component to hook
The hook type to install
The callback function:
(entity, id, value) => voidadd()
Adds a tag component (with no value) to an entity.The target entity
The tag component to add
get()
Retrieves component values from an entity. Supports up to 4 components at once.The entity to query
1-4 components to retrieve
undefined if not present
has()
Checks if an entity has all specified components. Supports up to 4 components.The entity to check
1-4 components to check for
boolean
remove()
Removes a component from an entity.The target entity
The component to remove
Querying
query()
Creates a query to search for entities with specific components.Components to query for
Query<T> - See Query API
each()
Iterates over all entities that have a specific component or relationship.The component or relationship to search for
Relationships
target()
Gets the target entity of a relationship. For example, withChildOf(parent), this returns the parent entity.
The entity with the relationship
The relationship component (e.g., ChildOf)
Index if multiple targets exist
Entity | undefined
parent()
Gets the parent entity (target of ChildOf relationship).The entity to get the parent of
Entity | undefined
children()
Iterates over all child entities of a parent.The parent entity
Change Detection
added()
Registers a listener for when a component is added to any entity.The component to listen for
Callback:
(entity, id, value) => void() => void
changed()
Registers a listener for when a component value changes.The component to listen for
Callback:
(entity, id, value) => void() => void
removed()
Registers a listener for when a component is removed from an entity.The component to listen for
Callback:
(entity, id, deleted?) => void() => void
Utility
range()
Enforces entity creation within a specific ID range.Starting ID for the range
Ending ID for the range (optional)