mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 09:30:03 +00:00
Add addons page
This commit is contained in:
parent
a974132e29
commit
81acedd56c
3 changed files with 235 additions and 182 deletions
|
@ -38,7 +38,8 @@ export default defineConfig({
|
||||||
{ text: 'Entities and Components', link: '/learn/concepts/entities-and-components' },
|
{ text: 'Entities and Components', link: '/learn/concepts/entities-and-components' },
|
||||||
{ text: 'Queries', link: '/learn/concepts/queries' },
|
{ text: 'Queries', link: '/learn/concepts/queries' },
|
||||||
{ text: 'Relationships', link: '/learn/concepts/relationships' },
|
{ 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' }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
16
docs/learn/concepts/addons.md
Normal file
16
docs/learn/concepts/addons.md
Normal 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/)
|
|
@ -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
|
# 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.
|
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.
|
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
|
- `OnDeleteTarget`: a target used with the relationship is deleted
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
The following examples show how to use cleanup traits
|
The following examples show how to use cleanup traits
|
||||||
|
|
||||||
### (OnDelete, Remove)
|
### (OnDelete, Remove)
|
||||||
|
|
||||||
::: code-group
|
::: code-group
|
||||||
|
|
||||||
```luau [luau]
|
```luau [luau]
|
||||||
|
@ -83,7 +120,6 @@ world.delete(Archer)
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### (OnDeleteTarget, Delete)
|
### (OnDeleteTarget, Delete)
|
||||||
|
|
||||||
::: code-group
|
::: code-group
|
||||||
|
|
||||||
```luau [luau]
|
```luau [luau]
|
Loading…
Reference in a new issue