mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2025-12-16 22:19:25 +07:00
Merge branch 'dev'
This commit is contained in:
@@ -99,6 +99,7 @@ entity_builder:build :: entity, boolean
|
|||||||
```
|
```
|
||||||
fragment :: fragment_builder
|
fragment :: fragment_builder
|
||||||
fragment_builder:tag :: fragment_builder
|
fragment_builder:tag :: fragment_builder
|
||||||
|
fragment_builder:single :: component -> fragment_builder
|
||||||
fragment_builder:default :: component -> fragment_builder
|
fragment_builder:default :: component -> fragment_builder
|
||||||
fragment_builder:construct :: {any... -> component} -> fragment_builder
|
fragment_builder:construct :: {any... -> component} -> fragment_builder
|
||||||
fragment_builder:on_set :: {entity, fragment, component, component?} -> fragment_builder
|
fragment_builder:on_set :: {entity, fragment, component, component?} -> fragment_builder
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
## Backlog
|
## Backlog
|
||||||
|
|
||||||
- try to keep entity_chunks/places tables as arrays
|
- INDEX fragment trait
|
||||||
|
- phase/pipeline addon
|
||||||
|
|
||||||
## After first release
|
## After first release
|
||||||
|
|
||||||
@@ -10,3 +11,5 @@
|
|||||||
- add REQUIRES fragment trait
|
- add REQUIRES fragment trait
|
||||||
- use compact prefix-tree for chunks
|
- use compact prefix-tree for chunks
|
||||||
- set/assign/insert/remove/clear/destroy for lists
|
- set/assign/insert/remove/clear/destroy for lists
|
||||||
|
- optional ffi component storages
|
||||||
|
- keep entity_chunks/places tables as arrays
|
||||||
|
|||||||
@@ -6508,3 +6508,20 @@ do
|
|||||||
assert(evo.select(c3, f3)[3] == 3 and evo.select(c3, f3)[4] == 33)
|
assert(evo.select(c3, f3)[3] == 3 and evo.select(c3, f3)[4] == 33)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
do
|
||||||
|
local f = evo.fragment():default():build()
|
||||||
|
assert(not evo.has(f, evo.DEFAULT))
|
||||||
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
local f = evo.fragment():single():build()
|
||||||
|
assert(not evo.has(f, f))
|
||||||
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
local f = evo.fragment():single(42):build()
|
||||||
|
assert(evo.has(f, f) and evo.get(f, f) == 42)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
41
evolved.lua
41
evolved.lua
@@ -5044,7 +5044,7 @@ function evolved.batch_set(query, fragment, ...)
|
|||||||
end
|
end
|
||||||
__defer_commit()
|
__defer_commit()
|
||||||
|
|
||||||
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list, true)
|
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list)
|
||||||
return set_count, false
|
return set_count, false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -5079,7 +5079,7 @@ function evolved.batch_assign(query, fragment, ...)
|
|||||||
end
|
end
|
||||||
__defer_commit()
|
__defer_commit()
|
||||||
|
|
||||||
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list, true)
|
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list)
|
||||||
return assigned_count, false
|
return assigned_count, false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -5114,7 +5114,7 @@ function evolved.batch_insert(query, fragment, ...)
|
|||||||
end
|
end
|
||||||
__defer_commit()
|
__defer_commit()
|
||||||
|
|
||||||
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list, true)
|
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list)
|
||||||
return inserted_count, false
|
return inserted_count, false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -5148,7 +5148,7 @@ function evolved.batch_remove(query, ...)
|
|||||||
end
|
end
|
||||||
__defer_commit()
|
__defer_commit()
|
||||||
|
|
||||||
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list, true)
|
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list)
|
||||||
return removed_count, false
|
return removed_count, false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -5181,7 +5181,7 @@ function evolved.batch_clear(query)
|
|||||||
end
|
end
|
||||||
__defer_commit()
|
__defer_commit()
|
||||||
|
|
||||||
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list, true)
|
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list)
|
||||||
return cleared_count, false
|
return cleared_count, false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -5214,7 +5214,7 @@ function evolved.batch_destroy(query)
|
|||||||
end
|
end
|
||||||
__defer_commit()
|
__defer_commit()
|
||||||
|
|
||||||
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list, true)
|
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list)
|
||||||
return destroyed_count, false
|
return destroyed_count, false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -5253,7 +5253,7 @@ function evolved.batch_multi_set(query, fragments, components)
|
|||||||
end
|
end
|
||||||
__defer_commit()
|
__defer_commit()
|
||||||
|
|
||||||
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list, true)
|
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list)
|
||||||
return set_count, false
|
return set_count, false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -5292,7 +5292,7 @@ function evolved.batch_multi_assign(query, fragments, components)
|
|||||||
end
|
end
|
||||||
__defer_commit()
|
__defer_commit()
|
||||||
|
|
||||||
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list, true)
|
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list)
|
||||||
return assigned_count, false
|
return assigned_count, false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -5331,7 +5331,7 @@ function evolved.batch_multi_insert(query, fragments, components)
|
|||||||
end
|
end
|
||||||
__defer_commit()
|
__defer_commit()
|
||||||
|
|
||||||
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list, true)
|
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list)
|
||||||
return inserted_count, false
|
return inserted_count, false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -5365,7 +5365,7 @@ function evolved.batch_multi_remove(query, fragments)
|
|||||||
end
|
end
|
||||||
__defer_commit()
|
__defer_commit()
|
||||||
|
|
||||||
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list, true)
|
__release_table(__TABLE_POOL_TAG__CHUNK_STACK, chunk_list)
|
||||||
return removed_count, false
|
return removed_count, false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -5696,6 +5696,7 @@ end
|
|||||||
|
|
||||||
---@class (evact) evolved.__fragment_builder
|
---@class (evact) evolved.__fragment_builder
|
||||||
---@field package __tag boolean
|
---@field package __tag boolean
|
||||||
|
---@field package __single? evolved.component
|
||||||
---@field package __default? evolved.component
|
---@field package __default? evolved.component
|
||||||
---@field package __construct? fun(...): evolved.component
|
---@field package __construct? fun(...): evolved.component
|
||||||
---@field package __on_set? evolved.set_hook
|
---@field package __on_set? evolved.set_hook
|
||||||
@@ -5713,6 +5714,7 @@ function evolved.fragment()
|
|||||||
---@type evolved.__fragment_builder
|
---@type evolved.__fragment_builder
|
||||||
local builder = {
|
local builder = {
|
||||||
__tag = false,
|
__tag = false,
|
||||||
|
__single = nil,
|
||||||
__default = nil,
|
__default = nil,
|
||||||
__construct = nil,
|
__construct = nil,
|
||||||
__on_set = nil,
|
__on_set = nil,
|
||||||
@@ -5730,6 +5732,13 @@ function evolved_fragment_builder:tag()
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param single evolved.component
|
||||||
|
---@return evolved.fragment_builder builder
|
||||||
|
function evolved_fragment_builder:single(single)
|
||||||
|
self.__single = single
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
---@param default evolved.component
|
---@param default evolved.component
|
||||||
---@return evolved.fragment_builder builder
|
---@return evolved.fragment_builder builder
|
||||||
function evolved_fragment_builder:default(default)
|
function evolved_fragment_builder:default(default)
|
||||||
@@ -5776,6 +5785,7 @@ end
|
|||||||
---@return boolean is_deferred
|
---@return boolean is_deferred
|
||||||
function evolved_fragment_builder:build()
|
function evolved_fragment_builder:build()
|
||||||
local tag = self.__tag
|
local tag = self.__tag
|
||||||
|
local single = self.__single
|
||||||
local default = self.__default
|
local default = self.__default
|
||||||
local construct = self.__construct
|
local construct = self.__construct
|
||||||
|
|
||||||
@@ -5785,6 +5795,7 @@ function evolved_fragment_builder:build()
|
|||||||
local on_remove = self.__on_remove
|
local on_remove = self.__on_remove
|
||||||
|
|
||||||
self.__tag = false
|
self.__tag = false
|
||||||
|
self.__single = nil
|
||||||
self.__default = nil
|
self.__default = nil
|
||||||
self.__construct = nil
|
self.__construct = nil
|
||||||
|
|
||||||
@@ -5793,6 +5804,8 @@ function evolved_fragment_builder:build()
|
|||||||
self.__on_insert = nil
|
self.__on_insert = nil
|
||||||
self.__on_remove = nil
|
self.__on_remove = nil
|
||||||
|
|
||||||
|
local fragment = evolved.id()
|
||||||
|
|
||||||
local fragment_list = __acquire_table(__TABLE_POOL_TAG__FRAGMENT_LIST)
|
local fragment_list = __acquire_table(__TABLE_POOL_TAG__FRAGMENT_LIST)
|
||||||
local component_list = __acquire_table(__TABLE_POOL_TAG__COMPONENT_LIST)
|
local component_list = __acquire_table(__TABLE_POOL_TAG__COMPONENT_LIST)
|
||||||
local component_count = 0
|
local component_count = 0
|
||||||
@@ -5803,6 +5816,12 @@ function evolved_fragment_builder:build()
|
|||||||
component_list[component_count] = true
|
component_list[component_count] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if single ~= nil then
|
||||||
|
component_count = component_count + 1
|
||||||
|
fragment_list[component_count] = fragment
|
||||||
|
component_list[component_count] = single
|
||||||
|
end
|
||||||
|
|
||||||
if default ~= nil then
|
if default ~= nil then
|
||||||
component_count = component_count + 1
|
component_count = component_count + 1
|
||||||
fragment_list[component_count] = evolved.DEFAULT
|
fragment_list[component_count] = evolved.DEFAULT
|
||||||
@@ -5843,7 +5862,7 @@ function evolved_fragment_builder:build()
|
|||||||
return evolved.id(), false
|
return evolved.id(), false
|
||||||
end
|
end
|
||||||
|
|
||||||
local fragment, is_deferred = evolved.spawn_with(fragment_list, component_list)
|
local _, is_deferred = evolved.multi_set(fragment, fragment_list, component_list)
|
||||||
|
|
||||||
__release_table(__TABLE_POOL_TAG__FRAGMENT_LIST, fragment_list)
|
__release_table(__TABLE_POOL_TAG__FRAGMENT_LIST, fragment_list)
|
||||||
__release_table(__TABLE_POOL_TAG__COMPONENT_LIST, component_list)
|
__release_table(__TABLE_POOL_TAG__COMPONENT_LIST, component_list)
|
||||||
|
|||||||
Reference in New Issue
Block a user