mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2026-09-27 11:07:08 +07:00
create entity without multi inserts
This commit is contained in:
@@ -7,6 +7,12 @@ local fragments = {
|
||||
velocity = registry:entity(),
|
||||
}
|
||||
|
||||
do
|
||||
registry:entity(
|
||||
fragments.position,
|
||||
fragments.velocity)
|
||||
end
|
||||
|
||||
do
|
||||
local entity = registry:entity()
|
||||
entity:insert(fragments.position)
|
||||
|
||||
@@ -27,6 +27,31 @@ local function describe(name, func, ...)
|
||||
collectgarbage('restart')
|
||||
end
|
||||
|
||||
describe('entity:entity', function()
|
||||
for _ = 1, 500 do
|
||||
local registry = evolved.registry()
|
||||
|
||||
---@type evolved.entity[]
|
||||
local all_fragments = {}
|
||||
local all_fragment_count = math.random(1, 10)
|
||||
for i = 1, all_fragment_count do all_fragments[i] = registry:entity() end
|
||||
|
||||
for _ = 1, 100 do
|
||||
---@type evolved.entity[]
|
||||
local insert_fragments = {}
|
||||
local insert_fragment_count = math.random(1, 10)
|
||||
for i = 1, insert_fragment_count do insert_fragments[i] = all_fragments[math.random(1, all_fragment_count)] end
|
||||
|
||||
local e1 = registry:entity()
|
||||
for _, fragment in ipairs(insert_fragments) do e1:insert(fragment) end
|
||||
|
||||
local e2 = registry:entity(unpack(insert_fragments))
|
||||
|
||||
assert(e1.chunk == e2.chunk)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
describe('entity:chunk', function()
|
||||
for _ = 1, 500 do
|
||||
local registry = evolved.registry()
|
||||
|
||||
Reference in New Issue
Block a user