This commit is contained in:
Ukendio 2024-05-27 03:50:46 +02:00
parent 0567856a59
commit c0594c7e75
3 changed files with 193 additions and 5 deletions

View file

@ -30,7 +30,7 @@ end
### QueryIter.without
QueryIter.without(iter: QueryIter
...: [Entity](../api-types/Entity)): QueryIter
...: [Entity](#Entity)): QueryIter
Create a new Query Iterator from the filter

188
docs/api/world.md Normal file
View file

@ -0,0 +1,188 @@
# World
### World.new
World.new(): [World](../api-types/World)
Create a new world.
#### Returns
A new world
---
### World.entity
World.entity(world: [World](../api-types/World)): [Entity](../api-types/Entity)
Creates an entity in the world.
#### Returns
A new entiity id
---
### World.target
World.target(world: [World](../api-types/World),
entity: [Entity](../api-types/Entity),
rel: [Entity](../api-types/Entity)): [Entity](../api-types/Entity)
Get the target of a relationship.
This will return a target (second element of a pair) of the entity for the specified relationship.
#### Parameters
world The world.
entity The entity.
rel The relationship between the entity and the target.
#### Returns
The first target for the relationship
---
### World.add
World.add(world: [World](../api-types/World),
entity: [Entity](../api-types/Entity),
id: [Entity](../api-types/Entity)): [Entity](../api-types/Entity)
Add a (component) id to an entity.
This operation adds a single (component) id to an entity.
If the entity already has the id, this operation will have no side effects.
#### Parameters
world The world.
entity The entity.
id The id to add.
---
### World.remove
World.remove(world: [World](../api-types/World),
entity: [Entity](../api-types/Entity),
id: [Entity](../api-types/Entity)): [Entity](../api-types/Entity)
Remove a (component) id to an entity.
This operation removes a single (component) id to an entity.
If the entity already has the id, this operation will have no side effects.
#### Parameters
world The world.
entity The entity.
id The id to add.
---
### World.get
World.get(world: [World](../api-types/World),
entity: [Entity](../api-types/Entity),
id: [Entity](../api-types/Entity)): any
Gets the component data.
#### Parameters
world The world.
entity The entity.
id The id of component to get.
#### Returns
The component data, nil if the entity does not have the componnet.
---
### World.set
World.set(world: [World](../api-types/World),
entity: [Entity](../api-types/Entity),
id: [Entity](../api-types/Entity)
data: any)
Set the value of a component.
#### Parameters
world The world.
entity The entity.
id The id of the componment set.
data The data to the component.
---
### World.query
World.query(world: [World](../api-types/World),
...: [Entity](../api-types/Entity)): [QueryIter](../api-types/QueryIter)
Create a QueryIter from the list of filters.
#### Parameters
world The world.
... The collection of components to match entities against.
#### Returns
The query iterator.
---
# Pair
### pair
pair(first: [Entity](../api-types/Entity),
second: [Entity](../api-types/Entity)): [Entity](../api-types/Entity)
Creates a composite key.
#### Parameters
first The first element.
second The second element.
#### Returns
The pair of the two elements
---
### IS_PAIR
jecs.IS_PAIR(id: [Entity](../api-types/Entity)): boolean
Creates a composite key.
#### Parameters
id The id to check.
#### Returns
If id is a pair.
---
# Constants
### OnAdd
---
### OnRemove
---
### Rest
---
### OnSet
---
### Wildcard
Matches any id, returns all matches.

View file

@ -1,7 +1,7 @@
site_name: Fusion
site_url: https://elttob.uk/Fusion/
repo_name: dphfox/Fusion
repo_url: https://github.com/dphfox/Fusion
site_name: Jecs
site_url: jecs.github.io/jecs
repo_name: ukendio/jecs
repo_url: https://github.com/ukendio/jecs
extra:
version: