Docs addons (#112)

* Fix indentations

* Add addons page

* Fix indent
This commit is contained in:
Marcus 2024-08-31 04:13:47 +02:00 committed by GitHub
parent 4f65be279b
commit f91ab4049f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 1007 additions and 962 deletions

View file

@ -38,7 +38,8 @@ export default defineConfig({
{ text: 'Entities and Components', link: '/learn/concepts/entities-and-components' },
{ text: 'Queries', link: '/learn/concepts/queries' },
{ text: 'Relationships', link: '/learn/concepts/relationships' },
{ text: 'Builtin Component Traits', link: 'learn/concepts/builtin-component-traits' }
{ text: 'Component Traits', link: 'learn/concepts/component-traits' },
{ text: 'Addons', link: '/learn/addons' }
]
},
{

View file

@ -0,0 +1,16 @@
# Addons
A collection of third-party jecs addons made by the community. If you would like to share what you're working on, [submit a pull request]()!
# Debuggers
## [jabby](https://github.com/alicesaidhi/jabby)
A jecs debugger with a string-based query language and entity editing capabilities.
# Schedulers
## [sapphire-jecs](https://github.com/Mark-Marks/sapphire/tree/main/crates/sapphire-jecs)
A batteries-included [sapphire](https://github.com/mark-marks/sapphire) scheduler for jecs
This page takes wording and terminology directly from Bevy's [assets page](https://bevyengine.org/assets/)

View file

@ -1,10 +1,49 @@
# Builtin Component Traits
# Component Traits
Component traits are IDs and pairs that can be added to components to modify their behavior. Although it is possible to create custom traits, this manual only contains an overview of all builtin component traits supported by Jecs.
Component traits are IDs and pairs that can be added to components to modify their behavior. This manual contains an overview of all component traits supported by Jecs.
# Component
Every (component) ID comes with a `Component` which helps with the distinction between normal entities and component IDs.
# Tag
A (component) ID can be marked with `Tag´ in which the component will never contain any data. This allows for zero-cost components which improves performance for structural changes.
# Hooks
Hooks are part of the "interface" of a component. You could consider hooks as the counterpart to OOP methods in ECS. They define the behavior of a component, but can only be invoked through mutations on the component data. You can only configure a single `OnAdd`, `OnRemove` and `OnSet` hook per component, just like you can only have a single constructor and destructor.
## Examples
::: code-group
```luau [luau]
local Transform= world:component()
world:set(Transform, OnAdd, function(entity)
-- A transform component has been added to an entity
end)
world:set(Transform, OnRemove, function(entity)
-- A transform component has been removed from the entity
end)
world:set(Transform, OnSet, function(entity, value)
-- A transform component has been assigned/changed to value on the entity
end)
```
```typescript [typescript]
const Transform = world.component()
world.set(Transform, OnAdd, (entity) => {
// A transform component has been added to an entity
})
world.set(Transform, OnRemove, (entity) => {
// A transform component has been removed from the entity
})
world.set(Transform, OnSet, (entity, value) => {
// A transform component has been assigned/changed to value on the entity
})
```
:::
# Cleanup Traits
When entities that are used as tags, components, relationships or relationship targets are deleted, cleanup traits ensure that the store does not contain any dangling references. Any cleanup policy provides this guarantee, so while they are configurable, games cannot configure traits that allows for dangling references.
We also want to specify this per relationship. If an entity has `(Likes, parent)` we may not want to delete that entity, meaning the cleanup we want to perform for `Likes` and `ChildOf` may not be the same.
@ -24,11 +63,9 @@ There are two cleanup conditions:
- `OnDeleteTarget`: a target used with the relationship is deleted
## Examples
The following examples show how to use cleanup traits
### (OnDelete, Remove)
::: code-group
```luau [luau]
@ -83,7 +120,6 @@ world.delete(Archer)
:::
### (OnDeleteTarget, Delete)
::: code-group
```luau [luau]

File diff suppressed because it is too large Load diff