diff --git a/lib/init.lua b/lib/init.lua index a57ae9e..29396a5 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -654,59 +654,6 @@ function World.delete(world: World, entityId: i53) entityIndex[entityId] = nil end -function World.observer(world: World, ...) - local componentIds = {...} - local idsCount = #componentIds - local hooks = world.hooks - - return { - event = function(event) - local hook = hooks[event] - hooks[event] = nil - - local last, change - return function() - last, change = next(hook, last) - if not last then - return - end - - local matched = false - local ids = change.ids - - while not matched do - local skip = false - for _, id in ids do - if not table.find(componentIds, id) then - skip = true - break - end - end - - if skip then - last, change = next(hook, last) - ids = change.ids - continue - end - - matched = true - end - - local queryOutput = table.create(idsCount) - local row = change.offset - local archetype = change.archetype - local columns = archetype.columns - local archetypeRecords = archetype.records - for index, id in componentIds do - queryOutput[index] = columns[archetypeRecords[id]][row] - end - - return archetype.entities[row], unpack(queryOutput, 1, idsCount) - end - end; - } -end - function World.__iter(world: World): () -> (number?, unknown?) local entityIndex = world.entityIndex local last diff --git a/lib/init.spec.lua b/lib/init.spec.lua index 98f485b..553c9a4 100644 --- a/lib/init.spec.lua +++ b/lib/init.spec.lua @@ -176,22 +176,6 @@ return function() expect(added).to.equal(0) end) - it("track changes", function() - local Position = world:entity() - - local moving = world:entity() - world:set(moving, Position, Vector3.new(1, 2, 3)) - - local count = 0 - - for e, position in world:observer(Position).event(jecs.ON_ADD) do - count += 1 - expect(e).to.equal(moving) - expect(position).to.equal(Vector3.new(1, 2, 3)) - end - expect(count).to.equal(1) - end) - it("should query all matching entities", function() local world = jecs.World.new()