mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 01:20:04 +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)
|
local function ensureArchetype(world: World, types, prev)
|
||||||
if #types < 1 then
|
if #types < 1 then
|
||||||
|
return world.ROOT_ARCHETYPE
|
||||||
end
|
end
|
||||||
local ty = hash(types)
|
local ty = hash(types)
|
||||||
local archetype = world.archetypeIndex[ty]
|
local archetype = world.archetypeIndex[ty]
|
||||||
|
@ -350,17 +350,22 @@ local function noop(): any
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local NO_POOLS = "No components provided"
|
||||||
|
|
||||||
local function getSmallestMap(componentIndex, components)
|
local function getSmallestMap(componentIndex, components)
|
||||||
local s: any
|
local s: any
|
||||||
|
|
||||||
for i, componentId in components do
|
for i, componentId in components do
|
||||||
local map = componentIndex[componentId]
|
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
|
if s == nil or map.size < s.size then
|
||||||
s = map
|
s = map
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return s and s.sparse or nil
|
return if s then s.sparse else error(NO_POOLS)
|
||||||
end
|
end
|
||||||
|
|
||||||
function World.query(world: World, ...: i53): any
|
function World.query(world: World, ...: i53): any
|
||||||
|
|
Loading…
Reference in a new issue