30 Commits
v1.9.0 ... main

Author SHA1 Message Date
74e5693443 Merge pull request #46 from BlackMATov/dev
Dev
2026-03-30 16:23:53 +07:00
BlackMATov
8c59bdfd7c v1.11.0 2026-03-30 16:20:04 +07:00
BlackMATov
a8f95c6b99 update README 2026-03-30 16:18:19 +07:00
BlackMATov
d40cd0e4ae update teal types 2026-03-30 07:12:42 +07:00
BlackMATov
3ca898bfa0 new evolved.error_handler function
#45
2026-03-30 07:01:47 +07:00
BlackMATov
e4166b7ebe more CI lua vers 2026-03-30 05:21:51 +07:00
BlackMATov
cea9b9f051 Merge branch 'feature/cached_hooks' into dev 2026-03-30 05:15:10 +07:00
BlackMATov
b6cc943850 update changelog 2026-03-06 06:03:01 +07:00
BlackMATov
a9fecee874 hold fragments with insert/remove/explicit hooks separately 2026-03-06 05:59:26 +07:00
c072842c3a Merge pull request #44 from BlackMATov/dev
Dev
2026-02-13 23:24:38 +07:00
BlackMATov
39c0b988b5 v1.10.0 2026-02-13 23:18:20 +07:00
BlackMATov
766f7b92be update README 2026-02-13 21:13:51 +07:00
BlackMATov
e364aaab37 update teal definitions 2026-02-13 08:07:14 +07:00
BlackMATov
b941baf6bb additional nr/to spawn/lookup tests 2026-02-13 07:55:25 +07:00
BlackMATov
8b77b45421 fix new discards in tests 2026-02-13 07:36:52 +07:00
BlackMATov
f9943c9fca nr/to multi_spawn/lookup versions 2026-02-13 07:35:35 +07:00
BlackMATov
eb853c8392 update README 2026-02-09 09:52:42 +07:00
BlackMATov
b38594fdfc Merge branch 'feature/lookup' into dev 2026-02-09 09:49:15 +07:00
BlackMATov
655c0aef07 update README 2026-02-09 09:47:18 +07:00
BlackMATov
2c4cb179bc (multi_)lookup first impl 2026-02-09 09:27:00 +07:00
BlackMATov
e49a339f5e dummy lookup functions and name hooks 2026-02-08 06:56:20 +07:00
BlackMATov
340feacf55 Merge branch 'dev' into feature/lookup 2026-02-08 06:48:33 +07:00
BlackMATov
caa8cc5625 move container functions to separated local tables 2026-02-08 06:48:17 +07:00
BlackMATov
cd1a583682 lookup api and basic tests 2026-02-08 06:16:00 +07:00
BlackMATov
5efd9ab2ae ensure that entity_chunks and entity_places have only array-parts 2026-02-06 17:36:09 +07:00
BlackMATov
b7419eec5d do not clear array part of builder component table 2026-02-05 15:30:50 +07:00
BlackMATov
287f03ef87 enable the debug mode for all tests 2026-02-03 06:12:29 +07:00
BlackMATov
260f841a3b fix some package usage 2026-02-03 06:11:58 +07:00
BlackMATov
d1105c15ad non-shrinking version of garbage collection 2026-02-02 20:46:50 +07:00
BlackMATov
a1440f26df size hint for some internal list functions 2026-02-02 17:32:07 +07:00
43 changed files with 2194 additions and 527 deletions

View File

@@ -1,4 +1,4 @@
name: lua5.1
name: lua5.1.5
on: [push, pull_request]
@@ -8,14 +8,15 @@ jobs:
strategy:
fail-fast: false
matrix:
lua_version: ["5.1"]
lua_version: ["5.1.5"]
operating_system: ["ubuntu-latest", "macos-latest", "windows-latest"]
name: ${{matrix.operating_system}}-${{matrix.lua_version}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: ilammy/msvc-dev-cmd@v1
- uses: leafo/gh-actions-lua@v12
with:
luaVersion: ${{matrix.lua_version}}
- run: |
lua -v
lua ./develop/all.lua

View File

@@ -1,4 +1,4 @@
name: lua5.2
name: lua5.2.4
on: [push, pull_request]
@@ -8,14 +8,15 @@ jobs:
strategy:
fail-fast: false
matrix:
lua_version: ["5.2"]
lua_version: ["5.2.4"]
operating_system: ["ubuntu-latest", "macos-latest", "windows-latest"]
name: ${{matrix.operating_system}}-${{matrix.lua_version}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: ilammy/msvc-dev-cmd@v1
- uses: leafo/gh-actions-lua@v12
with:
luaVersion: ${{matrix.lua_version}}
- run: |
lua -v
lua ./develop/all.lua

View File

@@ -1,4 +1,4 @@
name: lua5.3
name: lua5.3.6
on: [push, pull_request]
@@ -8,14 +8,15 @@ jobs:
strategy:
fail-fast: false
matrix:
lua_version: ["5.3"]
lua_version: ["5.3.6"]
operating_system: ["ubuntu-latest", "macos-latest", "windows-latest"]
name: ${{matrix.operating_system}}-${{matrix.lua_version}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: ilammy/msvc-dev-cmd@v1
- uses: leafo/gh-actions-lua@v12
with:
luaVersion: ${{matrix.lua_version}}
- run: |
lua -v
lua ./develop/all.lua

View File

@@ -1,4 +1,4 @@
name: lua5.4
name: lua5.4.8
on: [push, pull_request]
@@ -8,14 +8,15 @@ jobs:
strategy:
fail-fast: false
matrix:
lua_version: ["5.4"]
lua_version: ["5.4.8"]
operating_system: ["ubuntu-latest", "macos-latest", "windows-latest"]
name: ${{matrix.operating_system}}-${{matrix.lua_version}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: ilammy/msvc-dev-cmd@v1
- uses: leafo/gh-actions-lua@v12
with:
luaVersion: ${{matrix.lua_version}}
- run: |
lua -v
lua ./develop/all.lua

22
.github/workflows/lua5.5.0.yml vendored Normal file
View File

@@ -0,0 +1,22 @@
name: lua5.5.0
on: [push, pull_request]
jobs:
build:
runs-on: ${{matrix.operating_system}}
strategy:
fail-fast: false
matrix:
lua_version: ["5.5.0"]
operating_system: ["ubuntu-latest", "macos-latest", "windows-latest"]
name: ${{matrix.operating_system}}-${{matrix.lua_version}}
steps:
- uses: actions/checkout@v6
- uses: ilammy/msvc-dev-cmd@v1
- uses: leafo/gh-actions-lua@v12
with:
luaVersion: ${{matrix.lua_version}}
- run: |
lua -v
lua ./develop/all.lua

View File

@@ -1,21 +0,0 @@
name: luajit
on: [push, pull_request]
jobs:
build:
runs-on: ${{matrix.operating_system}}
strategy:
fail-fast: false
matrix:
lua_version: ["luajit"]
operating_system: ["ubuntu-latest", "macos-latest", "windows-latest"]
name: ${{matrix.operating_system}}-${{matrix.lua_version}}
steps:
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
- uses: leafo/gh-actions-lua@v12
with:
luaVersion: ${{matrix.lua_version}}
- run: |
lua ./develop/all.lua

22
.github/workflows/luajit2.1.yml vendored Normal file
View File

@@ -0,0 +1,22 @@
name: luajit2.1
on: [push, pull_request]
jobs:
build:
runs-on: ${{matrix.operating_system}}
strategy:
fail-fast: false
matrix:
lua_version: ["luajit-2.1"]
operating_system: ["ubuntu-latest", "macos-latest", "windows-latest"]
name: ${{matrix.operating_system}}-${{matrix.lua_version}}
steps:
- uses: actions/checkout@v6
- uses: ilammy/msvc-dev-cmd@v1
- uses: leafo/gh-actions-lua@v12
with:
luaVersion: ${{matrix.lua_version}}
- run: |
lua -v
lua ./develop/all.lua

322
README.md
View File

@@ -2,25 +2,35 @@
> Evolved ECS (Entity-Component-System) for Lua
[![lua5.1][badge.lua5.1]][lua5.1]
[![lua5.4][badge.lua5.4]][lua5.4]
[![luajit][badge.luajit]][luajit]
[![lua5.1.5][badge.lua5.1.5]][lua5.1.5]
[![lua5.2.4][badge.lua5.2.4]][lua5.2.4]
[![lua5.3.6][badge.lua5.3.6]][lua5.3.6]
[![lua5.4.8][badge.lua5.4.8]][lua5.4.8]
[![lua5.5.0][badge.lua5.5.0]][lua5.5.0]
[![luajit2.1][badge.luajit2.1]][luajit2.1]
[![license][badge.license]][license]
[badge.lua5.1]: https://img.shields.io/github/actions/workflow/status/BlackMATov/evolved.lua/.github/workflows/lua5.1.yml?label=Lua%205.1
[badge.lua5.4]: https://img.shields.io/github/actions/workflow/status/BlackMATov/evolved.lua/.github/workflows/lua5.4.yml?label=Lua%205.4
[badge.luajit]: https://img.shields.io/github/actions/workflow/status/BlackMATov/evolved.lua/.github/workflows/luajit.yml?label=LuaJIT
[badge.lua5.1.5]: https://img.shields.io/github/actions/workflow/status/BlackMATov/evolved.lua/.github/workflows/lua5.1.5.yml?label=Lua%205.1
[badge.lua5.2.4]: https://img.shields.io/github/actions/workflow/status/BlackMATov/evolved.lua/.github/workflows/lua5.2.4.yml?label=Lua%205.2
[badge.lua5.3.6]: https://img.shields.io/github/actions/workflow/status/BlackMATov/evolved.lua/.github/workflows/lua5.3.6.yml?label=Lua%205.3
[badge.lua5.4.8]: https://img.shields.io/github/actions/workflow/status/BlackMATov/evolved.lua/.github/workflows/lua5.4.8.yml?label=Lua%205.4
[badge.lua5.5.0]: https://img.shields.io/github/actions/workflow/status/BlackMATov/evolved.lua/.github/workflows/lua5.5.0.yml?label=Lua%205.5
[badge.luajit2.1]: https://img.shields.io/github/actions/workflow/status/BlackMATov/evolved.lua/.github/workflows/luajit2.1.yml?label=LuaJIT%202.1
[badge.license]: https://img.shields.io/badge/license-MIT-blue
[lua5.1]: https://github.com/BlackMATov/evolved.lua/actions?query=workflow%3Alua5.1
[lua5.4]: https://github.com/BlackMATov/evolved.lua/actions?query=workflow%3Alua5.4
[luajit]: https://github.com/BlackMATov/evolved.lua/actions?query=workflow%3Aluajit
[lua5.1.5]: https://github.com/BlackMATov/evolved.lua/actions?query=workflow%3Alua5.1.5
[lua5.2.4]: https://github.com/BlackMATov/evolved.lua/actions?query=workflow%3Alua5.2.4
[lua5.3.6]: https://github.com/BlackMATov/evolved.lua/actions?query=workflow%3Alua5.3.6
[lua5.4.8]: https://github.com/BlackMATov/evolved.lua/actions?query=workflow%3Alua5.4.8
[lua5.5.0]: https://github.com/BlackMATov/evolved.lua/actions?query=workflow%3Alua5.5.0
[luajit2.1]: https://github.com/BlackMATov/evolved.lua/actions?query=workflow%3Aluajit2.1
[license]: https://en.wikipedia.org/wiki/MIT_License
[evolved]: https://github.com/BlackMATov/evolved.lua
- [Introduction](#introduction)
- [Performance](#performance)
- [Benchmarks](#benchmarks)
- [Simplicity](#simplicity)
- [Flexibility](#flexibility)
- [Installation](#installation)
@@ -45,7 +55,8 @@
- [Batch Operations](#batch-operations)
- [Systems](#systems)
- [Processing Payloads](#processing-payloads)
- [Predefined Traits](#predefined-traits)
- [Predefined Fragments](#predefined-fragments)
- [Entity Names](#entity-names)
- [Fragment Tags](#fragment-tags)
- [Fragment Hooks](#fragment-hooks)
- [Unique Fragments](#unique-fragments)
@@ -55,6 +66,8 @@
- [Fragment Requirements](#fragment-requirements)
- [Destruction Policies](#destruction-policies)
- [Custom Component Storages](#custom-component-storages)
- [Error Handling](#error-handling)
- [Garbage Collection](#garbage-collection)
- [Cheat Sheet](#cheat-sheet)
- [Aliases](#aliases)
- [Predefs](#predefs)
@@ -63,6 +76,8 @@
- [Chunk](#chunk)
- [Builder](#builder)
- [Changelog](#changelog)
- [v1.11.0](#v1110)
- [v1.10.0](#v1100)
- [v1.9.0](#v190)
- [v1.8.0](#v180)
- [v1.7.0](#v170)
@@ -85,6 +100,10 @@ This library is designed to be fast. Many techniques are employed to achieve thi
Not all the optimizations I want to implement are done yet, but I will be working on them. However, I can already say that the library is fast enough for most use cases.
#### Benchmarks
The library contains some micro-benchmarks for internal use in the [develop/benchmarks](./develop/benchmarks/) directory, but they are not comprehensive and are not intended for comparison with other ECS libraries. I don't like cross-library benchmarks, as they are often biased and not representative of real-world performance. However, you can look at benchmarks from independent third-party authors, for example, [these](https://github.com/jeffzi/lua-ecs-benchmark) nice benchmarks by [@jeffzi](https://github.com/jeffzi) that cover most libraries, including `evolved.lua`.
### Simplicity
I have tried to keep the [API](#cheat-sheet) as simple and intuitive as possible. I also keep the number of functions under control. All the functions are self-explanatory and easy to use. After reading the [Overview](#overview) section, you should be able to use the library without any problems.
@@ -488,6 +507,7 @@ When you need to spawn multiple entities with identical fragments, use `multi_sp
---@param component_mapper? evolved.component_mapper
---@return evolved.entity[] entity_list
---@return integer entity_count
---@nodiscard
function evolved.multi_spawn(entity_count, component_table, component_mapper) end
---@param entity_count integer
@@ -496,6 +516,7 @@ function evolved.multi_spawn(entity_count, component_table, component_mapper) en
---@param component_mapper? evolved.component_mapper
---@return evolved.entity[] entity_list
---@return integer entity_count
---@nodiscard
function evolved.multi_clone(entity_count, prefab, component_table, component_mapper) end
```
@@ -526,6 +547,36 @@ end)
Of course, you can use `evolved.multi_clone` in the same way. Builders can also be used for multi-entity spawning and cloning by calling the corresponding methods on the builder object.
Also, for all `multi_` functions, the library provides [`_nr`](#evolvedmulti_spawn_nr) and [`_to`](#evolvedmulti_spawn_to) suffix variants that allow you to perform these operations without returning the list of spawned entities or by copying the spawned entities to your own table, which can be more efficient because it avoids the overhead of allocating and returning a new table.
```lua
local evolved = require 'evolved'
local position_x, position_y = evolved.id(2)
do
-- we don't interest in the list of spawned entities,
-- so we use the _nr variant of the multi_spawn function
evolved.multi_spawn_nr(100, {
[position_x] = 0,
[position_y] = 0,
})
end
do
-- store spawned entities in our own table starting at index 1,
-- so we use the _to variant of the multi_spawn function
local entity_list = {}
evolved.multi_spawn_to(entity_list, 1, 100, {
[position_x] = 0,
[position_y] = 0,
})
end
```
### Access Operations
The library provides all the necessary functions to access entities and their components. I'm not going to cover all the accessor functions here, because they are pretty straightforward and self-explanatory. You can check the [API Reference](#api-reference) for all of them. Here are some of the most important ones:
@@ -980,7 +1031,42 @@ evolved.process_with(physics_system, delta_time)
`delta_time` in this example is passed as a processing payload to the system's execution callback. Payloads can be of any type and can be multiple values. Also, payloads are passed to prologue and epilogue callbacks if they are defined. Every subsystem in a group will receive the same payload when the group is processed with [`evolved.process_with`](#evolvedprocess_with).
### Predefined Traits
### Predefined Fragments
#### Entity Names
The library provides a way to assign names to any id using the [`evolved.NAME`](#evolvedname) fragment. This is useful for debugging and development purposes, as it allows you to identify entities or fragments by their names instead of their identifiers. The name of an entity can be retrieved using the [`evolved.name`](#evolvedname-1) function.
```lua
local evolved = require 'evolved'
local player = evolved.builder()
:name('Player')
:build()
assert(evolved.name(player) == 'Player')
```
Names are not unique, so multiple entities can have the same name. Also, the name of an entity can be changed at any time by setting a new name using the [`evolved.NAME`](#evolvedname) fragment as a usual component.
You can find entities by their names using the [`evolved.lookup`](#evolvedlookup) and [`evolved.multi_lookup`](#evolvedmulti_lookup) functions. The [`evolved.lookup`](#evolvedlookup) function returns the first entity with the specified name, while the [`evolved.multi_lookup`](#evolvedmulti_lookup) function returns a list of all entities with the specified name.
```lua
local evolved = require 'evolved'
local player1 = evolved.builder()
:name('Player')
:build()
local player2 = evolved.builder()
:name('Player')
:build()
assert(evolved.lookup('Player') == player1)
local player_list, player_count = evolved.multi_lookup('Player')
assert(player_count == 2 and player_list[1] == player1 and player_list[2] == player2)
```
#### Fragment Tags
@@ -1346,6 +1432,42 @@ evolved.builder()
evolved.process_with(MOVEMENT_SYSTEM, 0.016)
```
### Error Handling
Since systems perform processing in a deferred scope, any errors that occur during processing can leave the library in an inconsistent state. To handle this, the library runs a protected call for each system and catches any errors that occur. By default, the library will collect the error message and the current stack trace and rethrow the error with this information. It is safe to catch errors, but it can be inconvenient to use with a debugger, because debuggers usually break on the rethrow instead of the place where the error happened. To make it easier to debug errors in systems, the library provides a way to set a custom error handler that will be called when an error occurs during system processing. For example, you can set an error handler that breaks into the debugger:
```lua
-- we use Local Lua Debugger in this example
local debugger = require 'lldebugger'
debugger.start()
local evolved = require 'evolved'
evolved.error_handler(function(message)
debugger.requestBreak()
return debug.traceback(message)
end)
```
This way, when an error occurs during system processing, the error handler will be called, which will break into the debugger, allowing you to inspect the state of the program at the moment of the error. After you continue execution in the debugger, the error will be rethrown with the original message and stack trace.
### Garbage Collection
While using the library, some internal data structures can become obsolete and should be cleaned up to free memory. For example, empty chunks that no longer contain entities can be removed. Component storages can also have unused capacity that can be shrunk to save memory. The library provides a function to control this garbage collection process.
```lua
---@param no_shrink? boolean
function evolved.collect_garbage(no_shrink) end
```
By default, [`evolved.collect_garbage`](#evolvedcollect_garbage) cleans up obsolete data structures and shrinks component storages to fit their current size. If you pass `true`, it only cleans up obsolete data structures and skips shrinking. This avoids the overhead of resizing storages, which can be expensive.
Call this function periodically to keep memory usage under control. It is best to call it between levels or during loading screens when performance is not critical. Also, call Lua's built-in garbage collector afterward to ensure all unused memory is freed.
```lua
evolved.collect_garbage()
collectgarbage('collect')
```
## Cheat Sheet
### Aliases
@@ -1444,9 +1566,13 @@ cancel :: boolean
spawn :: component_table?, component_mapper? -> entity
multi_spawn :: integer, component_table?, component_mapper? -> entity[], integer
multi_spawn_nr :: integer, component_table?, component_mapper? -> ()
multi_spawn_to :: entity[], integer, integer, component_table?, component_mapper? -> ()
clone :: entity, component_table?, component_mapper? -> entity
multi_clone :: integer, entity, component_table?, component_mapper? -> entity[], integer
multi_clone_nr :: integer, entity, component_table?, component_mapper? -> ()
multi_clone_to :: entity[], integer, integer, entity, component_table?, component_mapper? -> ()
alive :: entity -> boolean
alive_all :: entity... -> boolean
@@ -1477,11 +1603,16 @@ execute :: query -> {execute_state? -> chunk?, entity[]?, integer?}, execute_sta
locate :: entity -> chunk?, integer
lookup :: string -> entity?
multi_lookup :: string -> entity[], integer
multi_lookup_to :: entity[], integer, string -> integer
process :: system... -> ()
process_with :: system, ... -> ()
debug_mode :: boolean -> ()
collect_garbage :: ()
error_handler :: {string -> string}? -> ()
collect_garbage :: boolean? -> ()
```
### Classes
@@ -1510,12 +1641,18 @@ builder :: builder
builder_mt:build :: entity?, component_mapper? -> entity
builder_mt:multi_build :: integer, entity?, component_mapper? -> entity[], integer
builder_mt:multi_build_nr :: integer, entity?, component_mapper? -> ()
builder_mt:multi_build_to :: entity[], integer, integer, entity?, component_mapper? -> ()
builder_mt:spawn :: component_mapper? -> entity
builder_mt:multi_spawn :: integer, component_mapper? -> entity[], integer
builder_mt:multi_spawn_nr :: integer, component_mapper? -> ()
builder_mt:multi_spawn_to :: entity[], integer, integer, component_mapper? -> ()
builder_mt:clone :: entity, component_mapper? -> entity
builder_mt:multi_clone :: integer, entity, component_mapper? -> entity[], integer
builder_mt:multi_clone_nr :: integer, entity, component_mapper? -> ()
builder_mt:multi_clone_to :: entity[], integer, integer, entity, component_mapper? -> ()
builder_mt:has :: fragment -> boolean
builder_mt:has_all :: fragment... -> boolean
@@ -1566,6 +1703,18 @@ builder_mt:destruction_policy :: id -> builder
## Changelog
### v1.11.0
- Slightly improved performance of modifying operations for fragments with [`ON_INSERT`](#evolvedon_insert) and [`ON_REMOVE`](#evolvedon_remove) hooks
- Slightly improved performance of queries with [`EXPLICIT`](#evolvedexplicit) fragments
- Added the new [`evolved.error_handler`](#evolvederror_handler) function that allows setting a custom error handler for better system processing debugging experience
### v1.10.0
- Added the new [`evolved.lookup`](#evolvedlookup) and [`evolved.multi_lookup`](#evolvedmulti_lookup) functions that allow finding ids by their names
- Added a non-shrinking version of the [`evolved.collect_garbage`](#evolvedcollect_garbage) function that only collects garbage without shrinking storages
- Added [`_nr`](#evolvedmulti_spawn_nr) and [`_to`](#evolvedmulti_spawn_to) variants of the [`evolved.multi_spawn`](#evolvedmulti_spawn) and [`evolved.multi_clone`](#evolvedmulti_clone) functions that provide more efficient ways to spawn or clone entities in some cases
### v1.9.0
- Performance improvements of the [`evolved.destroy`](#evolveddestroy) and [`evolved.batch_destroy`](#evolvedbatch_destroy) functions
@@ -1771,9 +1920,31 @@ function evolved.spawn(component_table, component_mapper) end
---@param component_mapper? evolved.component_mapper
---@return evolved.entity[] entity_list
---@return integer entity_count
---@nodiscard
function evolved.multi_spawn(entity_count, component_table, component_mapper) end
```
### `evolved.multi_spawn_nr`
```lua
---@param entity_count integer
---@param component_table? evolved.component_table
---@param component_mapper? evolved.component_mapper
function evolved.multi_spawn_nr(entity_count, component_table, component_mapper) end
```
### `evolved.multi_spawn_to`
```lua
---@param out_entity_list evolved.entity[]
---@param out_entity_first integer
---@param entity_count integer
---@param component_table? evolved.component_table
---@param component_mapper? evolved.component_mapper
function evolved.multi_spawn_to(out_entity_list, out_entity_first,
entity_count, component_table, component_mapper) end
```
### `evolved.clone`
```lua
@@ -1793,9 +1964,33 @@ function evolved.clone(prefab, component_table, component_mapper) end
---@param component_mapper? evolved.component_mapper
---@return evolved.entity[] entity_list
---@return integer entity_count
---@nodiscard
function evolved.multi_clone(entity_count, prefab, component_table, component_mapper) end
```
### `evolved.multi_clone_nr`
```lua
---@param entity_count integer
---@param prefab evolved.entity
---@param component_table? evolved.component_table
---@param component_mapper? evolved.component_mapper
function evolved.multi_clone_nr(entity_count, prefab, component_table, component_mapper) end
```
### `evolved.multi_clone_to`
```lua
---@param out_entity_list evolved.entity[]
---@param out_entity_first integer
---@param entity_count integer
---@param prefab evolved.entity
---@param component_table? evolved.component_table
---@param component_mapper? evolved.component_mapper
function evolved.multi_clone_to(out_entity_list, out_entity_first,
entity_count, prefab, component_table, component_mapper) end
```
### `evolved.alive`
```lua
@@ -1982,6 +2177,35 @@ function evolved.execute(query) end
function evolved.locate(entity) end
```
### `evolved.lookup`
```lua
---@param name string
---@return evolved.entity? entity
---@nodiscard
function evolved.lookup(name) end
```
### `evolved.multi_lookup`
```lua
---@param name string
---@return evolved.entity[] entity_list
---@return integer entity_count
---@nodiscard
function evolved.multi_lookup(name) end
```
### `evolved.multi_lookup_to`
```lua
---@param out_entity_list evolved.entity[]
---@param out_entity_first integer
---@param name string
---@return integer entity_count
function evolved.multi_lookup_to(out_entity_list, out_entity_first, name) end
```
### `evolved.process`
```lua
@@ -2004,10 +2228,18 @@ function evolved.process_with(system, ...) end
function evolved.debug_mode(yesno) end
```
### `evolved.error_handler`
```lua
---@param handler? fun(message: string): string
function evolved.error_handler(handler) end
```
### `evolved.collect_garbage`
```lua
function evolved.collect_garbage() end
---@param no_shrink? boolean
function evolved.collect_garbage(no_shrink) end
```
## Classes
@@ -2123,9 +2355,31 @@ function evolved.builder_mt:build(prefab, component_mapper) end
---@param component_mapper? evolved.component_mapper
---@return evolved.entity[] entity_list
---@return integer entity_count
---@nodiscard
function evolved.builder_mt:multi_build(entity_count, prefab, component_mapper) end
```
### `evolved.builder_mt:multi_build_nr`
```lua
---@param entity_count integer
---@param prefab? evolved.entity
---@param component_mapper? evolved.component_mapper
function evolved.builder_mt:multi_build_nr(entity_count, prefab, component_mapper) end
```
### `evolved.builder_mt:multi_build_to`
```lua
---@param out_entity_list evolved.entity[]
---@param out_entity_first integer
---@param entity_count integer
---@param prefab? evolved.entity
---@param component_mapper? evolved.component_mapper
function evolved.builder_mt:multi_build_to(out_entity_list, out_entity_first,
entity_count, prefab, component_mapper) end
```
#### `evolved.builder_mt:spawn`
```lua
@@ -2141,9 +2395,29 @@ function evolved.builder_mt:spawn(component_mapper) end
---@param component_mapper? evolved.component_mapper
---@return evolved.entity[] entity_list
---@return integer entity_count
---@nodiscard
function evolved.builder_mt:multi_spawn(entity_count, component_mapper) end
```
#### `evolved.builder_mt:multi_spawn_nr`
```lua
---@param entity_count integer
---@param component_mapper? evolved.component_mapper
function evolved.builder_mt:multi_spawn_nr(entity_count, component_mapper) end
```
#### `evolved.builder_mt:multi_spawn_to`
```lua
---@param out_entity_list evolved.entity[]
---@param out_entity_first integer
---@param entity_count integer
---@param component_mapper? evolved.component_mapper
function evolved.builder_mt:multi_spawn_to(out_entity_list, out_entity_first,
entity_count, component_mapper) end
```
#### `evolved.builder_mt:clone`
```lua
@@ -2161,9 +2435,31 @@ function evolved.builder_mt:clone(prefab, component_mapper) end
---@param component_mapper? evolved.component_mapper
---@return evolved.entity[] entity_list
---@return integer entity_count
---@nodiscard
function evolved.builder_mt:multi_clone(entity_count, prefab, component_mapper) end
```
#### `evolved.builder_mt:multi_clone_nr`
```lua
---@param entity_count integer
---@param prefab evolved.entity
---@param component_mapper? evolved.component_mapper
function evolved.builder_mt:multi_clone_nr(entity_count, prefab, component_mapper) end
```
#### `evolved.builder_mt:multi_clone_to`
```lua
---@param out_entity_list evolved.entity[]
---@param out_entity_first integer
---@param entity_count integer
---@param prefab evolved.entity
---@param component_mapper? evolved.component_mapper
function evolved.builder_mt:multi_clone_to(out_entity_list, out_entity_first,
entity_count, prefab, component_mapper) end
```
#### `evolved.builder_mt:has`
```lua

View File

@@ -9,7 +9,6 @@
## Thoughts
- We should have a way to not copy components on deferred spawn/clone
- Having a light version of the gargabe collector can be useful for some use-cases
- Basic default component value as true looks awful, should we use something else?
## Known Issues

View File

@@ -1,9 +1,11 @@
require 'develop.testing.build_tests'
require 'develop.testing.cached_hooks_tests'
require 'develop.testing.cancel_tests'
require 'develop.testing.clone_tests'
require 'develop.testing.depth_tests'
require 'develop.testing.destroy_tests'
require 'develop.testing.locate_tests'
require 'develop.testing.lookup_tests'
require 'develop.testing.main_tests'
require 'develop.testing.mappers_tests'
require 'develop.testing.multi_spawn_tests'

View File

@@ -307,11 +307,11 @@ print '----------------------------------------'
basics.describe_bench(
string.format('Clone Benchmarks: Multi Clone | %d entities with 1 component', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [F1] = true }
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.batch_destroy(QF1)
end)
@@ -319,12 +319,12 @@ basics.describe_bench(
basics.describe_bench(
string.format('Clone Benchmarks: Multi Defer Clone | %d entities with 1 component', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [F1] = true }
evo.defer()
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.commit()
evo.batch_destroy(QF1)
@@ -333,11 +333,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Clone Benchmarks: Multi Clone With Defaults | %d entities with 1 component', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [D1] = true }
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.batch_destroy(QD1)
end)
@@ -345,11 +345,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Clone Benchmarks: Multi Clone | %d entities with 3 components', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [F1] = true, [F2] = true, [F3] = true }
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.batch_destroy(QF1)
end)
@@ -357,12 +357,12 @@ basics.describe_bench(
basics.describe_bench(
string.format('Clone Benchmarks: Multi Defer Clone | %d entities with 3 components', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [F1] = true, [F2] = true, [F3] = true }
evo.defer()
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.commit()
evo.batch_destroy(QF1)
@@ -371,11 +371,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Clone Benchmarks: Multi Clone With Defaults | %d entities with 3 components', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [D1] = true, [D2] = true, [D3] = true }
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.batch_destroy(QD1)
end)
@@ -383,11 +383,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Clone Benchmarks: Multi Clone | %d entities with 5 components', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [F1] = true, [F2] = true, [F3] = true, [F4] = true, [F5] = true }
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.batch_destroy(QF1)
end)
@@ -395,12 +395,12 @@ basics.describe_bench(
basics.describe_bench(
string.format('Clone Benchmarks: Multi Defer Clone | %d entities with 5 components', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [F1] = true, [F2] = true, [F3] = true, [F4] = true, [F5] = true }
evo.defer()
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.commit()
evo.batch_destroy(QF1)
@@ -409,11 +409,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Clone Benchmarks: Multi Clone With Defaults | %d entities with 5 components', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [D1] = true, [D2] = true, [D3] = true, [D4] = true, [D5] = true }
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.batch_destroy(QD1)
end)
@@ -423,11 +423,11 @@ print '----------------------------------------'
basics.describe_bench(
string.format('Clone Benchmarks: Multi Clone | %d entities with 1 required component', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [RF1] = true }
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.batch_destroy(QF1)
end)
@@ -435,12 +435,12 @@ basics.describe_bench(
basics.describe_bench(
string.format('Clone Benchmarks: Multi Defer Clone | %d entities with 1 required component', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [RF1] = true }
evo.defer()
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.commit()
evo.batch_destroy(QF1)
@@ -449,11 +449,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Clone Benchmarks: Multi Clone With Defaults | %d entities with 1 required component', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [RD1] = true }
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.batch_destroy(QD1)
end)
@@ -461,11 +461,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Clone Benchmarks: Multi Clone | %d entities with 3 required components', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [RF123] = true }
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.batch_destroy(QF1)
end)
@@ -473,12 +473,12 @@ basics.describe_bench(
basics.describe_bench(
string.format('Clone Benchmarks: Multi Defer Clone | %d entities with 3 required components', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [RF123] = true }
evo.defer()
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.commit()
evo.batch_destroy(QF1)
@@ -487,11 +487,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Clone Benchmarks: Multi Clone With Defaults | %d entities with 3 required components', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [RD123] = true }
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.batch_destroy(QD1)
end)
@@ -499,11 +499,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Clone Benchmarks: Multi Clone | %d entities with 5 required components', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [RF12345] = true }
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.batch_destroy(QF1)
end)
@@ -511,12 +511,12 @@ basics.describe_bench(
basics.describe_bench(
string.format('Clone Benchmarks: Multi Defer Clone | %d entities with 5 required components', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [RF12345] = true }
evo.defer()
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.commit()
evo.batch_destroy(QF1)
@@ -525,11 +525,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Clone Benchmarks: Multi Clone With Defaults | %d entities with 5 required components', N),
function()
local multi_clone = evo.multi_clone
local multi_clone_nr = evo.multi_clone_nr
local prefab = evo.spawn { [RD12345] = true }
multi_clone(N, prefab)
multi_clone_nr(N, prefab)
evo.batch_destroy(QD1)
end)

View File

@@ -54,7 +54,7 @@ basics.describe_bench(string.format('Common Benchmarks: Evolved Entity Cycle | %
local prefab_a = evo.builder():prefab():set(world):set(a, 0):spawn()
local prefab_b = evo.builder():prefab():set(world):set(b, 0):spawn()
evo.multi_clone(N, prefab_a)
evo.multi_clone_nr(N, prefab_a)
evo.builder()
:set(world):group(world):query(query_a)
@@ -129,10 +129,10 @@ basics.describe_bench(string.format('Common Benchmarks: Evolved Simple Iteration
local query_cd = evo.builder():set(world):include(c, d):spawn()
local query_ce = evo.builder():set(world):include(c, e):spawn()
evo.multi_spawn(N, { [world] = true, [a] = 0, [b] = 0 })
evo.multi_spawn(N, { [world] = true, [a] = 0, [b] = 0, [c] = 0 })
evo.multi_spawn(N, { [world] = true, [a] = 0, [b] = 0, [c] = 0, [d] = 0 })
evo.multi_spawn(N, { [world] = true, [a] = 0, [b] = 0, [c] = 0, [e] = 0 })
evo.multi_spawn_nr(N, { [world] = true, [a] = 0, [b] = 0 })
evo.multi_spawn_nr(N, { [world] = true, [a] = 0, [b] = 0, [c] = 0 })
evo.multi_spawn_nr(N, { [world] = true, [a] = 0, [b] = 0, [c] = 0, [d] = 0 })
evo.multi_spawn_nr(N, { [world] = true, [a] = 0, [b] = 0, [c] = 0, [e] = 0 })
evo.builder()
:set(world):group(world):query(query_ab)
@@ -223,7 +223,7 @@ basics.describe_bench(string.format('Common Benchmarks: Evolved Packed Iteration
local query_d = evo.builder():set(world):include(d):spawn()
local query_e = evo.builder():set(world):include(e):spawn()
evo.multi_spawn(N, { [world] = true, [a] = 0, [b] = 0, [c] = 0, [d] = 0, [e] = 0 })
evo.multi_spawn_nr(N, { [world] = true, [a] = 0, [b] = 0, [c] = 0, [d] = 0, [e] = 0 })
evo.builder()
:set(world):group(world):query(query_a)
@@ -317,7 +317,7 @@ basics.describe_bench(string.format('Common Benchmarks: Evolved Fragmented Itera
local query_z = evo.builder():set(world):include(chars[#chars]):spawn()
for i = 1, #chars do
evo.multi_spawn(N, { [world] = true, [chars[i]] = i, [data] = i })
evo.multi_spawn_nr(N, { [world] = true, [chars[i]] = i, [data] = i })
end
evo.builder()

View File

@@ -20,7 +20,7 @@ basics.describe_bench(string.format('Process Benchmarks: Evolved AoS Processing
local pf = evo.builder():set(wf):spawn()
local vf = evo.builder():set(wf):spawn()
evo.multi_spawn(N, {
evo.multi_spawn_nr(N, {
[wf] = true,
[pf] = { x = 0, y = 0, z = 0, w = 0 },
[vf] = { x = 0, y = 0, z = 0, w = 0 },
@@ -67,7 +67,7 @@ basics.describe_bench(string.format('Process Benchmarks: Evolved SoA Processing
local vzf = evo.builder():set(wf):spawn()
local vwf = evo.builder():set(wf):spawn()
evo.multi_spawn(N, {
evo.multi_spawn_nr(N, {
[wf] = true,
[pxf] = 0,
[pyf] = 0,

View File

@@ -536,11 +536,11 @@ print '----------------------------------------'
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Spawn | %d entities with 1 component', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [F1] = true }
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.batch_destroy(QF1)
end)
@@ -548,12 +548,12 @@ basics.describe_bench(
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Defer Spawn | %d entities with 1 component', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [F1] = true }
evo.defer()
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.commit()
evo.batch_destroy(QF1)
@@ -562,11 +562,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Spawn With Defaults | %d entities with 1 component', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [D1] = true }
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.batch_destroy(QD1)
end)
@@ -574,11 +574,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Spawn | %d entities with 3 components', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [F1] = true, [F2] = true, [F3] = true }
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.batch_destroy(QF1)
end)
@@ -586,12 +586,12 @@ basics.describe_bench(
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Defer Spawn | %d entities with 3 components', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [F1] = true, [F2] = true, [F3] = true }
evo.defer()
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.commit()
evo.batch_destroy(QF1)
@@ -600,11 +600,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Spawn With Defaults | %d entities with 3 components', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [D1] = true, [D2] = true, [D3] = true }
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.batch_destroy(QD1)
end)
@@ -612,11 +612,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Spawn | %d entities with 5 components', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [F1] = true, [F2] = true, [F3] = true, [F4] = true, [F5] = true }
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.batch_destroy(QF1)
end)
@@ -624,12 +624,12 @@ basics.describe_bench(
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Defer Spawn | %d entities with 5 components', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [F1] = true, [F2] = true, [F3] = true, [F4] = true, [F5] = true }
evo.defer()
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.commit()
evo.batch_destroy(QF1)
@@ -638,11 +638,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Spawn With Defaults | %d entities with 5 components', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [D1] = true, [D2] = true, [D3] = true, [D4] = true, [D5] = true }
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.batch_destroy(QD1)
end)
@@ -652,11 +652,11 @@ print '----------------------------------------'
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Spawn | %d entities with 1 required component', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [F1] = true }
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.batch_destroy(QF1)
end)
@@ -664,12 +664,12 @@ basics.describe_bench(
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Defer Spawn | %d entities with 1 required component', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [F1] = true }
evo.defer()
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.commit()
evo.batch_destroy(QF1)
@@ -678,11 +678,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Spawn With Defaults | %d entities with 1 required component', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [D1] = true }
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.batch_destroy(QD1)
end)
@@ -690,11 +690,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Spawn | %d entities with 3 required components', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [RF123] = true }
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.batch_destroy(QF1)
end)
@@ -702,12 +702,12 @@ basics.describe_bench(
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Defer Spawn | %d entities with 3 required components', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [RF123] = true }
evo.defer()
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.commit()
evo.batch_destroy(QF1)
@@ -716,11 +716,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Spawn With Defaults | %d entities with 3 required components', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [RD123] = true }
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.batch_destroy(QD1)
end)
@@ -728,11 +728,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Spawn | %d entities with 5 required components', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [RF12345] = true }
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.batch_destroy(QF1)
end)
@@ -740,12 +740,12 @@ basics.describe_bench(
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Defer Spawn | %d entities with 5 required components', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [RF12345] = true }
evo.defer()
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.commit()
evo.batch_destroy(QF1)
@@ -754,11 +754,11 @@ basics.describe_bench(
basics.describe_bench(
string.format('Spawn Benchmarks: Multi Spawn With Defaults | %d entities with 5 required components', N),
function()
local multi_spawn = evo.multi_spawn
local multi_spawn_nr = evo.multi_spawn_nr
local components = { [RD12345] = true }
multi_spawn(N, components)
multi_spawn_nr(N, components)
evo.batch_destroy(QD1)
end)

View File

@@ -118,11 +118,11 @@ end
---
if math.random(1, 2) == 1 then
evo.collect_garbage()
evo.collect_garbage(math.random(1, 2) == 1)
end
evo.destroy(__table_unpack(all_entity_list))
if math.random(1, 2) == 1 then
evo.collect_garbage()
evo.collect_garbage(math.random(1, 2) == 1)
end

View File

@@ -124,11 +124,11 @@ end
---
if math.random(1, 2) == 1 then
evo.collect_garbage()
evo.collect_garbage(math.random(1, 2) == 1)
end
evo.destroy(__table_unpack(all_entity_list))
if math.random(1, 2) == 1 then
evo.collect_garbage()
evo.collect_garbage(math.random(1, 2) == 1)
end

View File

@@ -296,7 +296,7 @@ end
---
if math.random(1, 2) == 1 then
evo.collect_garbage()
evo.collect_garbage(math.random(1, 2) == 1)
end
evo.destroy(__table_unpack(all_query_list))
@@ -304,5 +304,5 @@ evo.destroy(__table_unpack(all_entity_list))
evo.destroy(__table_unpack(all_fragment_list))
if math.random(1, 2) == 1 then
evo.collect_garbage()
evo.collect_garbage(math.random(1, 2) == 1)
end

View File

@@ -78,11 +78,11 @@ end
---
if math.random(1, 2) == 1 then
evo.collect_garbage()
evo.collect_garbage(math.random(1, 2) == 1)
end
evo.destroy(__table_unpack(all_entity_list))
if math.random(1, 2) == 1 then
evo.collect_garbage()
evo.collect_garbage(math.random(1, 2) == 1)
end

View File

@@ -115,17 +115,17 @@ end
if math.random(1, 2) == 1 then
evo.destroy(__table_unpack(all_entity_list))
if math.random(1, 2) == 1 then
evo.collect_garbage()
evo.collect_garbage(math.random(1, 2) == 1)
end
evo.destroy(__table_unpack(all_fragment_list))
else
evo.destroy(__table_unpack(all_fragment_list))
if math.random(1, 2) == 1 then
evo.collect_garbage()
evo.collect_garbage(math.random(1, 2) == 1)
end
evo.destroy(__table_unpack(all_entity_list))
end
if math.random(1, 2) == 1 then
evo.collect_garbage()
evo.collect_garbage(math.random(1, 2) == 1)
end

View File

@@ -64,11 +64,11 @@ end
---
if math.random(1, 2) == 1 then
evo.collect_garbage()
evo.collect_garbage(math.random(1, 2) == 1)
end
evo.destroy(__table_unpack(all_entity_list))
if math.random(1, 2) == 1 then
evo.collect_garbage()
evo.collect_garbage(math.random(1, 2) == 1)
end

View File

@@ -1,5 +1,7 @@
local evo = require 'evolved'
evo.debug_mode(true)
do
local f1, f2 = evo.id(2)

View File

@@ -0,0 +1,203 @@
local evo = require 'evolved'
evo.debug_mode(true)
do
local f1, f2 = evo.id(2)
local insert_hook_calls = 0
if f1 < f2 then
evo.set(f1, evo.ON_INSERT, function()
insert_hook_calls = insert_hook_calls + 1
end)
else
evo.set(f2, evo.ON_INSERT, function()
insert_hook_calls = insert_hook_calls + 1
end)
end
do
insert_hook_calls = 0
local e = evo.spawn { [f1] = 42, [f2] = 'hello' }
assert(insert_hook_calls == 1)
evo.destroy(e)
end
evo.remove(f1, evo.ON_INSERT)
evo.remove(f2, evo.ON_INSERT)
do
insert_hook_calls = 0
local e = evo.spawn { [f1] = 42, [f2] = 'hello' }
assert(insert_hook_calls == 0)
evo.destroy(e)
end
if f1 < f2 then
evo.set(f1, evo.ON_INSERT, function()
insert_hook_calls = insert_hook_calls + 2
end)
else
evo.set(f2, evo.ON_INSERT, function()
insert_hook_calls = insert_hook_calls + 2
end)
end
do
insert_hook_calls = 0
local e = evo.spawn { [f1] = 42, [f2] = 'hello' }
assert(insert_hook_calls == 2)
evo.destroy(e)
end
end
do
local f1, f2 = evo.id(2)
local insert_hook_calls = 0
if f1 > f2 then
evo.set(f1, evo.ON_INSERT, function()
insert_hook_calls = insert_hook_calls + 1
end)
else
evo.set(f2, evo.ON_INSERT, function()
insert_hook_calls = insert_hook_calls + 1
end)
end
do
insert_hook_calls = 0
local e = evo.spawn { [f1] = 42, [f2] = 'hello' }
assert(insert_hook_calls == 1)
evo.destroy(e)
end
evo.remove(f1, evo.ON_INSERT)
evo.remove(f2, evo.ON_INSERT)
do
insert_hook_calls = 0
local e = evo.spawn { [f1] = 42, [f2] = 'hello' }
assert(insert_hook_calls == 0)
evo.destroy(e)
end
if f1 > f2 then
evo.set(f1, evo.ON_INSERT, function()
insert_hook_calls = insert_hook_calls + 2
end)
else
evo.set(f2, evo.ON_INSERT, function()
insert_hook_calls = insert_hook_calls + 2
end)
end
do
insert_hook_calls = 0
local e = evo.spawn { [f1] = 42, [f2] = 'hello' }
assert(insert_hook_calls == 2)
evo.destroy(e)
end
end
do
local f1, f2 = evo.id(2)
local remove_hook_calls = 0
if f1 < f2 then
evo.set(f1, evo.ON_REMOVE, function()
remove_hook_calls = remove_hook_calls + 1
end)
else
evo.set(f2, evo.ON_REMOVE, function()
remove_hook_calls = remove_hook_calls + 1
end)
end
do
remove_hook_calls = 0
local e = evo.spawn { [f1] = 42, [f2] = 'hello' }
evo.destroy(e)
assert(remove_hook_calls == 1)
end
evo.remove(f1, evo.ON_REMOVE)
evo.remove(f2, evo.ON_REMOVE)
do
remove_hook_calls = 0
local e = evo.spawn { [f1] = 42, [f2] = 'hello' }
evo.destroy(e)
assert(remove_hook_calls == 0)
end
if f1 < f2 then
evo.set(f1, evo.ON_REMOVE, function()
remove_hook_calls = remove_hook_calls + 2
end)
else
evo.set(f2, evo.ON_REMOVE, function()
remove_hook_calls = remove_hook_calls + 2
end)
end
do
remove_hook_calls = 0
local e = evo.spawn { [f1] = 42, [f2] = 'hello' }
evo.destroy(e)
assert(remove_hook_calls == 2)
end
end
do
local f1, f2 = evo.id(2)
local remove_hook_calls = 0
if f1 > f2 then
evo.set(f1, evo.ON_REMOVE, function()
remove_hook_calls = remove_hook_calls + 1
end)
else
evo.set(f2, evo.ON_REMOVE, function()
remove_hook_calls = remove_hook_calls + 1
end)
end
do
remove_hook_calls = 0
local e = evo.spawn { [f1] = 42, [f2] = 'hello' }
evo.destroy(e)
assert(remove_hook_calls == 1)
end
evo.remove(f1, evo.ON_REMOVE)
evo.remove(f2, evo.ON_REMOVE)
do
remove_hook_calls = 0
local e = evo.spawn { [f1] = 42, [f2] = 'hello' }
evo.destroy(e)
assert(remove_hook_calls == 0)
end
if f1 > f2 then
evo.set(f1, evo.ON_REMOVE, function()
remove_hook_calls = remove_hook_calls + 2
end)
else
evo.set(f2, evo.ON_REMOVE, function()
remove_hook_calls = remove_hook_calls + 2
end)
end
do
remove_hook_calls = 0
local e = evo.spawn { [f1] = 42, [f2] = 'hello' }
evo.destroy(e)
assert(remove_hook_calls == 2)
end
end

View File

@@ -1,5 +1,7 @@
local evo = require 'evolved'
evo.debug_mode(true)
do
assert(evo.defer())
assert(evo.cancel())

View File

@@ -1,5 +1,7 @@
local evo = require 'evolved'
evo.debug_mode(true)
do
do
local p = evo.spawn()
@@ -395,3 +397,165 @@ do
end
end
end
do
local f1, f2 = evo.id(2)
local p = evo.spawn { [f1] = 42, [f2] = 'hello' }
do
local entity_list, entity_count = {}, 2
evo.multi_clone_to(entity_list, 1, entity_count, p)
assert(evo.has_all(entity_list[1], f1, f2))
assert(evo.has_all(entity_list[2], f1, f2))
assert(evo.get(entity_list[1], f1) == 42 and evo.get(entity_list[1], f2) == 'hello')
assert(evo.get(entity_list[2], f1) == 42 and evo.get(entity_list[2], f2) == 'hello')
end
do
local entity_list, entity_count = {}, 2
evo.multi_clone_to(entity_list, 2, entity_count, p)
assert(evo.has_all(entity_list[2], f1, f2))
assert(evo.has_all(entity_list[3], f1, f2))
assert(evo.get(entity_list[2], f1) == 42 and evo.get(entity_list[2], f2) == 'hello')
assert(evo.get(entity_list[3], f1) == 42 and evo.get(entity_list[3], f2) == 'hello')
end
do
local entity_list, entity_count = {}, 2
evo.defer()
evo.multi_clone_to(entity_list, 1, entity_count, p)
assert(entity_list[1] and entity_list[2])
assert(evo.empty_all(entity_list[1], entity_list[2]))
evo.commit()
assert(evo.has_all(entity_list[1], f1, f2))
assert(evo.has_all(entity_list[2], f1, f2))
assert(evo.get(entity_list[1], f1) == 42 and evo.get(entity_list[1], f2) == 'hello')
assert(evo.get(entity_list[2], f1) == 42 and evo.get(entity_list[2], f2) == 'hello')
end
do
local entity_list, entity_count = {}, 2
evo.defer()
evo.multi_clone_to(entity_list, 2, entity_count, p)
assert(entity_list[2] and entity_list[3])
assert(evo.empty_all(entity_list[2], entity_list[3]))
evo.commit()
assert(evo.has_all(entity_list[2], f1, f2))
assert(evo.has_all(entity_list[3], f1, f2))
assert(evo.get(entity_list[2], f1) == 42 and evo.get(entity_list[2], f2) == 'hello')
assert(evo.get(entity_list[3], f1) == 42 and evo.get(entity_list[3], f2) == 'hello')
end
end
do
local f1, f2 = evo.id(2)
local q12 = evo.builder():include(f1, f2):build()
local p = evo.spawn { [f1] = 42, [f2] = 'hello' }
do
assert(select('#', evo.multi_clone_nr(2, p)) == 0)
do
local entity_count = 0
for chunk in evo.execute(q12) do
local _, chunk_entity_count = chunk:entities()
entity_count = entity_count + chunk_entity_count
end
assert(entity_count == 3)
end
end
do
local b = evo.builder():set(f1, 42):set(f2, 'hello')
assert(select('#', b:multi_clone_nr(2, p)) == 0)
do
local entity_count = 0
for chunk in evo.execute(q12) do
local _, chunk_entity_count = chunk:entities()
entity_count = entity_count + chunk_entity_count
end
assert(entity_count == 5)
end
end
do
local b = evo.builder():set(f1, 42):set(f2, 'hello')
assert(select('#', b:multi_build_nr(2, p)) == 0)
do
local entity_count = 0
for chunk in evo.execute(q12) do
local _, chunk_entity_count = chunk:entities()
entity_count = entity_count + chunk_entity_count
end
assert(entity_count == 7)
end
end
end
do
local f1, f2 = evo.id(2)
local q12 = evo.builder():include(f1, f2):build()
local p = evo.spawn { [f1] = 42, [f2] = 'hello' }
do
local entity_list = {}
assert(select('#', evo.multi_clone_to(entity_list, 1, 2, p)) == 0)
do
local entity_count = 0
for chunk in evo.execute(q12) do
local _, chunk_entity_count = chunk:entities()
entity_count = entity_count + chunk_entity_count
end
assert(entity_count == 3)
end
end
do
local b = evo.builder():set(f1, 42):set(f2, 'hello')
local entity_list = {}
assert(select('#', b:multi_clone_to(entity_list, 1, 2, p)) == 0)
do
local entity_count = 0
for chunk in evo.execute(q12) do
local _, chunk_entity_count = chunk:entities()
entity_count = entity_count + chunk_entity_count
end
assert(entity_count == 5)
end
end
do
local b = evo.builder():set(f1, 42):set(f2, 'hello')
local entity_list = {}
assert(select('#', b:multi_build_to(entity_list, 1, 2, p)) == 0)
do
local entity_count = 0
for chunk in evo.execute(q12) do
local _, chunk_entity_count = chunk:entities()
entity_count = entity_count + chunk_entity_count
end
assert(entity_count == 7)
end
end
end

View File

@@ -1,5 +1,7 @@
local evo = require 'evolved'
evo.debug_mode(true)
do
assert(evo.depth() == 0)

View File

@@ -1,5 +1,7 @@
local evo = require 'evolved'
evo.debug_mode(true)
do
local e = evo.id()
assert(evo.alive(e))

View File

@@ -1,5 +1,7 @@
local evo = require 'evolved'
evo.debug_mode(true)
do
local e1, e2, f1, f2 = evo.id(4)

View File

@@ -0,0 +1,195 @@
local evo = require 'evolved'
evo.debug_mode(true)
do
local e1, e2, e3 = evo.id(3)
do
assert(evo.lookup('lookup_hello') == nil)
assert(evo.lookup('lookup_world') == nil)
do
local entity_list, entity_count = evo.multi_lookup('lookup_hello')
assert(entity_list and #entity_list == 0 and entity_count == 0)
end
do
local entity_list, entity_count = evo.multi_lookup('lookup_world')
assert(entity_list and #entity_list == 0 and entity_count == 0)
end
end
evo.set(e1, evo.NAME, 'lookup_hello')
do
assert(evo.lookup('lookup_hello') == e1)
assert(evo.lookup('lookup_world') == nil)
do
local entity_list, entity_count = evo.multi_lookup('lookup_hello')
assert(entity_list and #entity_list == 1 and entity_count == 1)
assert(entity_list[1] == e1)
end
do
local entity_list, entity_count = evo.multi_lookup('lookup_world')
assert(entity_list and #entity_list == 0 and entity_count == 0)
end
end
evo.set(e2, evo.NAME, 'lookup_hello')
evo.set(e3, evo.NAME, 'lookup_hello')
do
assert(evo.lookup('lookup_hello') == e1)
assert(evo.lookup('lookup_world') == nil)
do
local entity_list, entity_count = evo.multi_lookup('lookup_hello')
assert(entity_list and #entity_list == 3 and entity_count == 3)
assert(entity_list[1] == e1 and entity_list[2] == e2 and entity_list[3] == e3)
end
end
evo.set(e2, evo.NAME, 'lookup_world')
do
assert(evo.lookup('lookup_hello') == e1)
assert(evo.lookup('lookup_world') == e2)
do
local entity_list, entity_count = evo.multi_lookup('lookup_hello')
assert(entity_list and #entity_list == 2 and entity_count == 2)
assert(entity_list[1] == e1 and entity_list[2] == e3)
end
do
local entity_list, entity_count = evo.multi_lookup('lookup_world')
assert(entity_list and #entity_list == 1 and entity_count == 1)
assert(entity_list[1] == e2)
end
end
evo.set(e3, evo.NAME, 'lookup_world')
do
assert(evo.lookup('lookup_hello') == e1)
assert(evo.lookup('lookup_world') == e2)
do
local entity_list, entity_count = evo.multi_lookup('lookup_hello')
assert(entity_list and #entity_list == 1 and entity_count == 1)
assert(entity_list[1] == e1)
end
do
local entity_list, entity_count = evo.multi_lookup('lookup_world')
assert(entity_list and #entity_list == 2 and entity_count == 2)
assert(entity_list[1] == e2 or entity_list[1] == e3)
end
end
evo.remove(e1, evo.NAME)
do
assert(evo.lookup('lookup_hello') == nil)
assert(evo.lookup('lookup_world') == e2)
do
local entity_list, entity_count = evo.multi_lookup('lookup_hello')
assert(entity_list and #entity_list == 0 and entity_count == 0)
end
do
local entity_list, entity_count = evo.multi_lookup('lookup_world')
assert(entity_list and #entity_list == 2 and entity_count == 2)
assert(entity_list[1] == e2 or entity_list[1] == e3)
end
end
end
do
local e1, e2, e3 = evo.id(3)
evo.set(e1, evo.NAME, 'lookup_e')
do
local entity_list, entity_count = evo.multi_lookup('lookup_e')
assert(entity_list and #entity_list == 1 and entity_count == 1)
assert(entity_list[1] == e1)
end
evo.set(e2, evo.NAME, 'lookup_e')
do
local entity_list, entity_count = evo.multi_lookup('lookup_e')
assert(entity_list and #entity_list == 2 and entity_count == 2)
assert(entity_list[1] == e1 and entity_list[2] == e2)
end
evo.set(e3, evo.NAME, 'lookup_e')
do
local entity_list, entity_count = evo.multi_lookup('lookup_e')
assert(entity_list and #entity_list == 3 and entity_count == 3)
assert(entity_list[1] == e1 and entity_list[2] == e2 and entity_list[3] == e3)
end
evo.clear(e1, e2, e3)
do
local entity_list, entity_count = evo.multi_lookup('lookup_e')
assert(entity_list and #entity_list == 0 and entity_count == 0)
end
evo.set(e3, evo.NAME, 'lookup_e')
do
local entity_list, entity_count = evo.multi_lookup('lookup_e')
assert(entity_list and #entity_list == 1 and entity_count == 1)
assert(entity_list[1] == e3)
end
evo.set(e2, evo.NAME, 'lookup_e')
do
local entity_list, entity_count = evo.multi_lookup('lookup_e')
assert(entity_list and #entity_list == 2 and entity_count == 2)
assert(entity_list[1] == e3 and entity_list[2] == e2)
end
evo.set(e1, evo.NAME, 'lookup_e')
do
local entity_list, entity_count = evo.multi_lookup('lookup_e')
assert(entity_list and #entity_list == 3 and entity_count == 3)
assert(entity_list[1] == e3 and entity_list[2] == e2 and entity_list[3] == e1)
end
evo.destroy(e3, e2, e1)
do
local entity_list, entity_count = evo.multi_lookup('lookup_e')
assert(entity_list and #entity_list == 0 and entity_count == 0)
end
end
do
local e1, e2 = evo.id(2)
evo.set(e1, evo.NAME, 'lookup_e')
evo.set(e2, evo.NAME, 'lookup_e')
do
local entity_list = {}
local entity_count = evo.multi_lookup_to(entity_list, 1, 'lookup_e')
assert(entity_count == 2 and entity_list[1] == e1 and entity_list[2] == e2)
end
do
local entity_list = {}
local entity_count = evo.multi_lookup_to(entity_list, 2, 'lookup_e')
assert(entity_count == 2 and entity_list[2] == e1 and entity_list[3] == e2)
end
end

View File

@@ -2928,8 +2928,8 @@ do
last_insert_entity, last_insert_component = 0, 0
local e = evo.spawn({ [f2] = 21, [f1] = true })
assert(set_count == 2 and insert_count == 2)
assert(last_set_entity == e and last_set_component == 21)
assert(last_insert_entity == e and last_insert_component == 21)
assert(last_set_entity == e and (last_set_component == 21 or last_set_component == true))
assert(last_insert_entity == e and (last_insert_component == 21 or last_insert_component == true))
end
do
@@ -2948,8 +2948,8 @@ do
last_insert_entity, last_insert_component = 0, 0
local e = evo.spawn({ [f3] = 33, [f2] = 22 })
assert(set_count == 2 and insert_count == 2)
assert(last_set_entity == e and last_set_component == nil)
assert(last_insert_entity == e and last_insert_component == nil)
assert(last_set_entity == e and (last_set_component == nil or last_set_component == 22))
assert(last_insert_entity == e and (last_insert_component == nil or last_insert_component == 22))
end
end

View File

@@ -1,5 +1,7 @@
local evo = require 'evolved'
evo.debug_mode(true)
do
local f1, f2 = evo.id(2)

View File

@@ -1,5 +1,7 @@
local evo = require 'evolved'
evo.debug_mode(true)
do
local entity_list
@@ -605,3 +607,164 @@ do
end
end
end
do
local f1, f2 = evo.id(2)
do
local entity_list, entity_count = {}, 2
evo.multi_spawn_to(entity_list, 1, entity_count, { [f1] = 42, [f2] = "hello" })
assert(evo.has_all(entity_list[1], f1, f2))
assert(evo.has_all(entity_list[2], f1, f2))
assert(evo.get(entity_list[1], f1) == 42 and evo.get(entity_list[1], f2) == "hello")
assert(evo.get(entity_list[2], f1) == 42 and evo.get(entity_list[2], f2) == "hello")
end
do
local entity_list, entity_count = {}, 2
evo.multi_spawn_to(entity_list, 2, entity_count, { [f1] = 42, [f2] = "hello" })
assert(evo.has_all(entity_list[2], f1, f2))
assert(evo.has_all(entity_list[3], f1, f2))
assert(evo.get(entity_list[2], f1) == 42 and evo.get(entity_list[2], f2) == "hello")
assert(evo.get(entity_list[3], f1) == 42 and evo.get(entity_list[3], f2) == "hello")
end
do
local entity_list, entity_count = {}, 2
evo.defer()
evo.multi_spawn_to(entity_list, 1, entity_count, { [f1] = 42, [f2] = "hello" })
assert(entity_list[1] and entity_list[2])
assert(evo.empty_all(entity_list[1], entity_list[2]))
evo.commit()
assert(evo.has_all(entity_list[1], f1, f2))
assert(evo.has_all(entity_list[2], f1, f2))
assert(evo.get(entity_list[1], f1) == 42 and evo.get(entity_list[1], f2) == "hello")
assert(evo.get(entity_list[2], f1) == 42 and evo.get(entity_list[2], f2) == "hello")
end
do
local entity_list, entity_count = {}, 2
evo.defer()
evo.multi_spawn_to(entity_list, 2, entity_count, { [f1] = 42, [f2] = "hello" })
assert(entity_list[2] and entity_list[3])
assert(evo.empty_all(entity_list[2], entity_list[3]))
evo.commit()
assert(evo.has_all(entity_list[2], f1, f2))
assert(evo.has_all(entity_list[3], f1, f2))
assert(evo.get(entity_list[2], f1) == 42 and evo.get(entity_list[2], f2) == "hello")
assert(evo.get(entity_list[3], f1) == 42 and evo.get(entity_list[3], f2) == "hello")
end
end
do
local f1, f2 = evo.id(2)
local q12 = evo.builder():include(f1, f2):spawn()
do
assert(select('#', evo.multi_spawn_nr(2, { [f1] = 42, [f2] = "hello" })) == 0)
do
local entity_count = 0
for chunk in evo.execute(q12) do
local _, chunk_entity_count = chunk:entities()
entity_count = entity_count + chunk_entity_count
end
assert(entity_count == 2)
end
end
do
local b = evo.builder():set(f1, 42):set(f2, "hello")
assert(select('#', b:multi_spawn_nr(2)) == 0)
do
local entity_count = 0
for chunk in evo.execute(q12) do
local _, chunk_entity_count = chunk:entities()
entity_count = entity_count + chunk_entity_count
end
assert(entity_count == 4)
end
end
do
local b = evo.builder():set(f1, 42):set(f2, "hello")
assert(select('#', b:multi_build_nr(2)) == 0)
do
local entity_count = 0
for chunk in evo.execute(q12) do
local _, chunk_entity_count = chunk:entities()
entity_count = entity_count + chunk_entity_count
end
assert(entity_count == 6)
end
end
end
do
local f1, f2 = evo.id(2)
local q12 = evo.builder():include(f1, f2):spawn()
do
local entity_list = {}
assert(select('#', evo.multi_spawn_to(entity_list, 1, 2, { [f1] = 42, [f2] = "hello" })) == 0)
do
local entity_count = 0
for chunk in evo.execute(q12) do
local _, chunk_entity_count = chunk:entities()
entity_count = entity_count + chunk_entity_count
end
assert(entity_count == 2)
end
end
do
local b = evo.builder():set(f1, 42):set(f2, "hello")
local entity_list = {}
assert(select('#', b:multi_spawn_to(entity_list, 1, 2)) == 0)
do
local entity_count = 0
for chunk in evo.execute(q12) do
local _, chunk_entity_count = chunk:entities()
entity_count = entity_count + chunk_entity_count
end
assert(entity_count == 4)
end
end
do
local b = evo.builder():set(f1, 42):set(f2, "hello")
local entity_list = {}
assert(select('#', b:multi_build_to(entity_list, 1, 2)) == 0)
do
local entity_count = 0
for chunk in evo.execute(q12) do
local _, chunk_entity_count = chunk:entities()
entity_count = entity_count + chunk_entity_count
end
assert(entity_count == 6)
end
end
end

View File

@@ -1,5 +1,7 @@
local evo = require 'evolved'
evo.debug_mode(true)
do
local id = evo.id()

View File

@@ -1,5 +1,7 @@
local evo = require 'evolved'
evo.debug_mode(true)
do
local f = evo.id()
local e = evo.builder():set(f, 42):spawn()

View File

@@ -1,10 +1,18 @@
local evo = require 'evolved'
evo.debug_mode(true)
---@type ffilib?
local ffi = (function()
local ffi_loader = package and package.preload and package.preload['ffi']
local ffi = ffi_loader and ffi_loader()
return ffi
if package and package.loaded then
local loaded_ffi = package.loaded.ffi
if loaded_ffi then return loaded_ffi end
end
if package and package.preload then
local ffi_loader = package.preload.ffi
if ffi_loader then return ffi_loader() end
end
end)()
if not ffi then

View File

@@ -1,5 +1,7 @@
local evo = require 'evolved'
evo.debug_mode(true)
do
local f1, f2 = evo.id(2)
evo.set(f1, evo.REQUIRES)

View File

@@ -1,5 +1,7 @@
local evo = require 'evolved'
evo.debug_mode(true)
do
do
local e = evo.spawn()

View File

@@ -1,5 +1,7 @@
local evo = require 'evolved'
evo.debug_mode(true)
do
local f1, f2, f3 = evo.id(3)

View File

@@ -40,6 +40,18 @@
prefab?: Entity,
component_mapper?: function(Chunk, integer, integer)): { Entity }, integer
multi_build_nr: function(self: Builder,
entity_count: integer,
prefab?: Entity,
component_mapper?: function(Chunk, integer, integer))
multi_build_to: function(self: Builder,
out_entity_list: { Entity },
out_entity_first: integer,
entity_count: integer,
prefab?: Entity,
component_mapper?: function(Chunk, integer, integer))
spawn: function(self: Builder,
component_mapper?: function(Chunk, integer)): Entity
@@ -47,6 +59,16 @@
entity_count: integer,
component_mapper?: function(Chunk, integer, integer)): { Entity }, integer
multi_spawn_nr: function(self: Builder,
entity_count: integer,
component_mapper?: function(Chunk, integer, integer))
multi_spawn_to: function(self: Builder,
out_entity_list: { Entity },
out_entity_first: integer,
entity_count: integer,
component_mapper?: function(Chunk, integer, integer))
clone: function(self: Builder,
prefab: Entity,
component_mapper?: function(Chunk, integer)): Entity
@@ -56,6 +78,18 @@
prefab: Entity,
component_mapper?: function(Chunk, integer, integer)): { Entity }, integer
multi_clone_nr: function(self: Builder,
entity_count: integer,
prefab: Entity,
component_mapper?: function(Chunk, integer, integer))
multi_clone_to: function(self: Builder,
out_entity_list: { Entity },
out_entity_first: integer,
entity_count: integer,
prefab: Entity,
component_mapper?: function(Chunk, integer, integer))
has: function(self: Builder, fragment: Fragment): boolean
has_all: function(self: Builder, ...: Fragment): boolean
has_any: function(self: Builder, ...: Fragment): boolean
@@ -164,6 +198,18 @@
component_table?: { Fragment: any },
component_mapper?: function(Chunk, integer, integer)): { Entity }, integer
multi_spawn_nr: function(
entity_count: integer,
component_table?: { Fragment: any },
component_mapper?: function(Chunk, integer, integer))
multi_spawn_to: function(
out_entity_list: { Entity },
out_entity_first: integer,
entity_count: integer,
component_table?: { Fragment: any },
component_mapper?: function(Chunk, integer, integer))
clone: function(
prefab: Entity,
component_table?: { Fragment: any },
@@ -175,6 +221,20 @@
component_table?: { Fragment: any },
component_mapper?: function(Chunk, integer, integer)): { Entity }, integer
multi_clone_nr: function(
entity_count: integer,
prefab: Entity,
component_table?: { Fragment: any },
component_mapper?: function(Chunk, integer, integer))
multi_clone_to: function(
out_entity_list: { Entity },
out_entity_first: integer,
entity_count: integer,
prefab: Entity,
component_table?: { Fragment: any },
component_mapper?: function(Chunk, integer, integer))
alive: function(entity: Entity): boolean
alive_all: function(...: Entity): boolean
alive_any: function(...: Entity): boolean
@@ -208,11 +268,16 @@
locate: function(entity: Entity): Chunk | nil, integer
lookup: function(name: string): Entity | nil
multi_lookup: function(name: string): { Entity }, integer
multi_lookup_to: function(out_entity_list: { Entity }, out_entity_first: integer, name: string): integer
process: function(...: System)
process_with: function(system: System, ...: any)
debug_mode: function(yesno: boolean)
collect_garbage: function()
error_handler: function(handler?: function(message: string): string)
collect_garbage: function(no_shrink?: boolean)
chunk: function(fragment: Fragment, ...: Fragment): Chunk, { Entity }, integer
builder: function(): Builder

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,12 @@
if os.getenv('LOCAL_LUA_DEBUGGER_VSCODE') == '1' then
require('lldebugger').start()
local debugger = require 'lldebugger'
debugger.start()
local evolved = require 'evolved'
evolved.error_handler(function(err)
debugger.requestBreak()
return debug.traceback(err)
end)
end
---@type love.conf

View File

@@ -52,7 +52,7 @@ evolved.builder()
:name('SYSTEMS.STARTUP')
:group(STAGES.ON_SETUP)
:prologue(function()
evolved.multi_clone(500, PREFABS.CIRCLE, nil, function(chunk, b_place, e_place)
evolved.multi_clone_nr(500, PREFABS.CIRCLE, nil, function(chunk, b_place, e_place)
local screen_width, screen_height = love.graphics.getDimensions()
---@type number[], number[]

View File

@@ -0,0 +1,34 @@
rockspec_format = "3.0"
package = "evolved.lua"
version = "1.10.0-0"
source = {
url = "git://github.com/BlackMATov/evolved.lua",
tag = "v1.10.0",
}
description = {
homepage = "https://github.com/BlackMATov/evolved.lua",
summary = "Evolved ECS (Entity-Component-System) for Lua",
detailed = [[
`evolved.lua` is a fast and flexible ECS (Entity-Component-System) library for Lua.
It is designed to be simple and easy to use, while providing all the features needed to create complex systems with blazing performance.
]],
license = "MIT",
labels = {
"ecs",
"entity",
"entities",
"component",
"components",
"entity-component",
"entity-component-system",
},
}
dependencies = {
"lua >= 5.1",
}
build = {
type = "builtin",
modules = {
evolved = "evolved.lua",
}
}

View File

@@ -0,0 +1,34 @@
rockspec_format = "3.0"
package = "evolved.lua"
version = "1.11.0-0"
source = {
url = "git://github.com/BlackMATov/evolved.lua",
tag = "v1.11.0",
}
description = {
homepage = "https://github.com/BlackMATov/evolved.lua",
summary = "Evolved ECS (Entity-Component-System) for Lua",
detailed = [[
`evolved.lua` is a fast and flexible ECS (Entity-Component-System) library for Lua.
It is designed to be simple and easy to use, while providing all the features needed to create complex systems with blazing performance.
]],
license = "MIT",
labels = {
"ecs",
"entity",
"entities",
"component",
"components",
"entity-component",
"entity-component-system",
},
}
dependencies = {
"lua >= 5.1",
}
build = {
type = "builtin",
modules = {
evolved = "evolved.lua",
}
}