mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 09:30:03 +00:00
Remove hard coded behaviour
This commit is contained in:
parent
7d48063d20
commit
33192b7a6f
1 changed files with 18 additions and 76 deletions
92
lib/init.lua
92
lib/init.lua
|
@ -338,8 +338,6 @@ function World.query(world: World, ...: i53): (() -> (number, ...any)) | () -> (
|
||||||
local queryLength = #components
|
local queryLength = #components
|
||||||
local firstArchetypeMap = getSmallestMap(world.componentIndex, components)
|
local firstArchetypeMap = getSmallestMap(world.componentIndex, components)
|
||||||
|
|
||||||
local a, b, c, d, e, f, g, h = ...
|
|
||||||
|
|
||||||
if not firstArchetypeMap then
|
if not firstArchetypeMap then
|
||||||
return noop()
|
return noop()
|
||||||
end
|
end
|
||||||
|
@ -349,81 +347,25 @@ function World.query(world: World, ...: i53): (() -> (number, ...any)) | () -> (
|
||||||
local columns = archetype.columns
|
local columns = archetype.columns
|
||||||
local archetypeRecords = archetype.records
|
local archetypeRecords = archetype.records
|
||||||
local indices = {}
|
local indices = {}
|
||||||
if queryLength == 1 then
|
|
||||||
indices = {
|
|
||||||
columns[archetypeRecords[a]],
|
|
||||||
}
|
|
||||||
elseif queryLength == 2 then
|
|
||||||
indices = {
|
|
||||||
columns[archetypeRecords[a]],
|
|
||||||
columns[archetypeRecords[b]]
|
|
||||||
}
|
|
||||||
elseif queryLength == 3 then
|
|
||||||
indices = {
|
|
||||||
columns[archetypeRecords[a]],
|
|
||||||
columns[archetypeRecords[b]],
|
|
||||||
columns[archetypeRecords[c]]
|
|
||||||
}
|
|
||||||
elseif queryLength == 4 then
|
|
||||||
indices = {
|
|
||||||
columns[archetypeRecords[a]],
|
|
||||||
columns[archetypeRecords[b]],
|
|
||||||
columns[archetypeRecords[c]],
|
|
||||||
columns[archetypeRecords[d]]
|
|
||||||
}
|
|
||||||
elseif queryLength == 5 then
|
|
||||||
indices = {
|
|
||||||
columns[archetypeRecords[a]],
|
|
||||||
columns[archetypeRecords[b]],
|
|
||||||
columns[archetypeRecords[c]],
|
|
||||||
columns[archetypeRecords[d]],
|
|
||||||
columns[archetypeRecords[e]]
|
|
||||||
}
|
|
||||||
elseif queryLength == 6 then
|
|
||||||
indices = {
|
|
||||||
columns[archetypeRecords[a]],
|
|
||||||
columns[archetypeRecords[b]],
|
|
||||||
columns[archetypeRecords[c]],
|
|
||||||
columns[archetypeRecords[d]],
|
|
||||||
columns[archetypeRecords[e]],
|
|
||||||
columns[archetypeRecords[f]],
|
|
||||||
}
|
|
||||||
elseif queryLength == 7 then
|
|
||||||
indices = {
|
|
||||||
columns[archetypeRecords[a]],
|
|
||||||
columns[archetypeRecords[b]],
|
|
||||||
columns[archetypeRecords[c]],
|
|
||||||
columns[archetypeRecords[d]],
|
|
||||||
columns[archetypeRecords[e]],
|
|
||||||
columns[archetypeRecords[f]],
|
|
||||||
columns[archetypeRecords[g]],
|
|
||||||
}
|
|
||||||
elseif queryLength == 8 then
|
|
||||||
indices = {
|
|
||||||
columns[archetypeRecords[a]],
|
|
||||||
columns[archetypeRecords[b]],
|
|
||||||
columns[archetypeRecords[c]],
|
|
||||||
columns[archetypeRecords[d]],
|
|
||||||
columns[archetypeRecords[e]],
|
|
||||||
columns[archetypeRecords[f]],
|
|
||||||
columns[archetypeRecords[g]],
|
|
||||||
}
|
|
||||||
else
|
|
||||||
for i, componentId in components do
|
|
||||||
indices[i] = columns[archetypeRecords[componentId]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local i = 0
|
local skip = false
|
||||||
for _ in indices do
|
for i, componentId in components do
|
||||||
i += 1
|
local data = columns[archetypeRecords[componentId]]
|
||||||
end
|
if not data then
|
||||||
if queryLength == i then
|
skip = true
|
||||||
table.insert(compatibleArchetypes, {
|
break
|
||||||
archetype = archetype,
|
end
|
||||||
indices = indices
|
indices[i] = data
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if skip then
|
||||||
|
continue
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(compatibleArchetypes, {
|
||||||
|
archetype = archetype,
|
||||||
|
indices = indices
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local lastArchetype, compatibleArchetype = next(compatibleArchetypes)
|
local lastArchetype, compatibleArchetype = next(compatibleArchetypes)
|
||||||
|
|
Loading…
Reference in a new issue