mirror of
https://github.com/Ukendio/jecs.git
synced 2026-03-18 00:44:32 +00:00
Explicit error message for double disconnect
This commit is contained in:
parent
7170dbf6a1
commit
19823453aa
5 changed files with 13 additions and 18 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@rbxts/jecs",
|
||||
"version": "0.10.4",
|
||||
"version": "0.11.0",
|
||||
"description": "Stupidly fast Entity Component System",
|
||||
"main": "src/jecs.luau",
|
||||
"repository": {
|
||||
|
|
|
|||
|
|
@ -3142,7 +3142,8 @@ local function world_new(DEBUG: boolean?)
|
|||
table.insert(listeners, fn)
|
||||
return function()
|
||||
local n = #listeners
|
||||
local i = table.find(listeners, fn)
|
||||
local i = table.find(listeners, fn::Listener<any>)
|
||||
assert(i, "Listener not found, maybe you tried to disconnect it twice")
|
||||
listeners[i] = listeners[n]
|
||||
listeners[n] = nil
|
||||
end
|
||||
|
|
@ -3187,7 +3188,8 @@ local function world_new(DEBUG: boolean?)
|
|||
table.insert(listeners, fn)
|
||||
return function()
|
||||
local n = #listeners
|
||||
local i = table.find(listeners, fn)
|
||||
local i = table.find(listeners, fn::Listener<any>)
|
||||
assert(i, "Listener not found, maybe you tried to disconnect it twice")
|
||||
listeners[i] = listeners[n]
|
||||
listeners[n] = nil
|
||||
end
|
||||
|
|
@ -3232,6 +3234,7 @@ local function world_new(DEBUG: boolean?)
|
|||
return function()
|
||||
local n = #listeners
|
||||
local i = table.find(listeners, fn::Listener<any>)
|
||||
assert(i, "Listener not found, maybe you tried to disconnect it twice")
|
||||
listeners[i] = listeners[n]
|
||||
listeners[n] = nil
|
||||
end
|
||||
|
|
@ -3339,14 +3342,7 @@ local function world_new(DEBUG: boolean?)
|
|||
local max_id = entity_index.max_id
|
||||
|
||||
if index > max_id then
|
||||
-- Pre-populate all intermediate IDs to keep sparse_array as an array
|
||||
for i = max_id + 1, index - 1 do
|
||||
-- if not sparse_array[i] then
|
||||
-- -- NOTE(marcus): We have to do this check to see if
|
||||
-- -- they exist first because world:range() may have
|
||||
-- -- pre-populated some slots already.
|
||||
-- end
|
||||
|
||||
sparse_array[i] = { dense = 0, row = 0, archetype = ROOT_ARCHETYPE }
|
||||
end
|
||||
entity_index.max_id = index
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ local mirror = require(ReplicatedStorage.mirror:Clone())
|
|||
return {
|
||||
ParameterGenerator = function()
|
||||
local ecs = jecs.world()
|
||||
ecs:range(1000, 20000)
|
||||
local mcs = mirror.World.new()
|
||||
return ecs, mcs
|
||||
end,
|
||||
|
|
@ -19,14 +18,14 @@ return {
|
|||
Mirror = function(_, ecs, mcs)
|
||||
for i = 1, 100 do
|
||||
|
||||
mcs:entity()
|
||||
local _e = mcs:entity()
|
||||
end
|
||||
end,
|
||||
|
||||
Jecs = function(_, ecs, mcs)
|
||||
for i = 1, 100 do
|
||||
|
||||
ecs:entity()
|
||||
local _e = ecs:entity()
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -178,15 +178,15 @@ TEST("migrating to real records", function()
|
|||
print(jecs.record(world, e1).row)
|
||||
world:add(e1, jecs.pair(jecs.ChildOf, e2))
|
||||
world:set(e1, jecs.Name, "hello")
|
||||
print(jecs.record(world, e1).row)
|
||||
print(world:get(e1, jecs.Name), world:has(e1, jecs.pair(jecs.ChildOf, jecs.Wildcard)))
|
||||
CHECK(jecs.record(world, e1).row~=0)
|
||||
CHECK(world:get(e1, jecs.Name)=="hello")
|
||||
CHECK(world:has(e1, jecs.pair(jecs.ChildOf, jecs.Wildcard)))
|
||||
end)
|
||||
|
||||
TEST("e2 is nil", function()
|
||||
local world = jecs.world(true)
|
||||
local e1 = world:entity(1000)
|
||||
print("-----")
|
||||
local e2 = world:entity()
|
||||
print("-----")
|
||||
|
||||
CHECK(e1 and world:contains(e1))
|
||||
CHECK(e2 and world:contains(e2))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "ukendio/jecs"
|
||||
version = "0.10.4"
|
||||
version = "0.11.0"
|
||||
registry = "https://github.com/UpliftGames/wally-index"
|
||||
realm = "shared"
|
||||
license = "MIT"
|
||||
|
|
|
|||
Loading…
Reference in a new issue