mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Provide better error messages
This commit is contained in:
parent
12287b12ef
commit
cc13870fd9
1 changed files with 7 additions and 2 deletions
|
@ -198,7 +198,7 @@ export type World = typeof(World.new())
|
|||
|
||||
local function ensureArchetype(world: World, types, prev)
|
||||
if #types < 1 then
|
||||
|
||||
return world.ROOT_ARCHETYPE
|
||||
end
|
||||
local ty = hash(types)
|
||||
local archetype = world.archetypeIndex[ty]
|
||||
|
@ -350,17 +350,22 @@ local function noop(): any
|
|||
end
|
||||
end
|
||||
|
||||
local NO_POOLS = "No components provided"
|
||||
|
||||
local function getSmallestMap(componentIndex, components)
|
||||
local s: any
|
||||
|
||||
for i, componentId in components do
|
||||
local map = componentIndex[componentId]
|
||||
if not map then
|
||||
error(tostring(componentId).." has not been added to any entity")
|
||||
end
|
||||
if s == nil or map.size < s.size then
|
||||
s = map
|
||||
end
|
||||
end
|
||||
|
||||
return s and s.sparse or nil
|
||||
return if s then s.sparse else error(NO_POOLS)
|
||||
end
|
||||
|
||||
function World.query(world: World, ...: i53): any
|
||||
|
|
Loading…
Reference in a new issue