mirror of
https://github.com/Ukendio/jecs.git
synced 2025-09-14 04:29:18 +00:00
query should use internal world type
Some checks failed
Some checks failed
This commit is contained in:
parent
9d1665944e
commit
5de842d144
4 changed files with 21 additions and 6 deletions
|
@ -603,12 +603,26 @@ function World:exists(
|
|||
|
||||
## cleanup
|
||||
|
||||
Cleans up deleted entities and their associated data. This is automatically called by jecs, but can be called manually if needed.
|
||||
Cleans up empty archetypes.
|
||||
|
||||
```luau
|
||||
function World:cleanup(): void
|
||||
```
|
||||
|
||||
:::info
|
||||
It is recommended to profile the optimal interval you should cleanup because it varies completely from game to game.
|
||||
|
||||
Here are a couple of reasons from Sander Mertens:
|
||||
- some applications are memory constrained, so any wasted memory on empty
|
||||
archetypes has to get cleaned up
|
||||
- many archetypes can get created during game startup but aren't used later
|
||||
on, so it would be wasteful to keep them around
|
||||
- empty archetypes can slow queries down, especially if there are many more
|
||||
empty ones than non-empty ones
|
||||
- if the total number of component permutations (/relationships) is too
|
||||
high, you have no choice but to periodically cleanup empty archetypes
|
||||
:::
|
||||
|
||||
Example:
|
||||
|
||||
::: code-group
|
||||
|
|
|
@ -74,7 +74,7 @@ type query = {
|
|||
filter_with: { i53 },
|
||||
filter_without: { i53 },
|
||||
next: () -> (i53, ...any),
|
||||
world: World,
|
||||
world: world,
|
||||
}
|
||||
|
||||
export type observer = {
|
||||
|
@ -1181,9 +1181,10 @@ local function query_archetypes(query: query)
|
|||
compatible_archetypes = {}
|
||||
query.compatible_archetypes = compatible_archetypes
|
||||
|
||||
local archetypes = query.world.archetypes
|
||||
local world = query.world
|
||||
local archetypes = world.archetypes
|
||||
|
||||
local component_index = query.world.component_index
|
||||
local component_index = world.component_index
|
||||
|
||||
local idr: componentrecord?
|
||||
local with = query.filter_with
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@rbxts/jecs",
|
||||
"version": "0.9.0-rc.11",
|
||||
"version": "0.9.0-rc.12",
|
||||
"description": "Stupidly fast Entity Component System",
|
||||
"main": "jecs.luau",
|
||||
"repository": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "ukendio/jecs"
|
||||
version = "0.9.0-rc.11"
|
||||
version = "0.9.0-rc.12"
|
||||
registry = "https://github.com/UpliftGames/wally-index"
|
||||
realm = "shared"
|
||||
license = "MIT"
|
||||
|
|
Loading…
Reference in a new issue