File tree Expand file tree Collapse file tree 2 files changed +22
-9
lines changed Expand file tree Collapse file tree 2 files changed +22
-9
lines changed Original file line number Diff line number Diff line change 813
813
end
814
814
end
815
815
816
- local function world_query_next (): any
816
+ local function world_query_iter_next (): any
817
817
local entityId = entities [i ]
818
818
while entityId == nil do
819
819
lastArchetype += 1
@@ -1048,9 +1048,17 @@ do
1048
1048
if not drain then
1049
1049
query_init (query )
1050
1050
end
1051
- return world_query_next
1051
+ return world_query_iter_next
1052
1052
end
1053
1053
1054
+ local function world_query_next ()
1055
+ if not drain then
1056
+ error ("Did you forget to call query:drain()?" )
1057
+ end
1058
+ return world_query_iter_next ()
1059
+ end
1060
+
1061
+
1054
1062
local it = {
1055
1063
__iter = world_query_iter ,
1056
1064
drain = world_query_drain ,
Original file line number Diff line number Diff line change @@ -296,14 +296,19 @@ TEST("world:query()", function()
296
296
world :set (eAB , A , true )
297
297
world :set (eAB , B , true )
298
298
299
- local q = world :query (A )
299
+ local q = world :query (A ): drain ()
300
300
301
- local e , data = q : next ()
301
+ local e , data = q . next ()
302
302
while e do
303
- if e ~= eA and e ~= eAB then
303
+ if e == eA then
304
+ CHECK (data )
305
+ elseif e == eAB then
306
+ CHECK (data )
307
+ else
304
308
CHECK (false )
305
309
end
306
- e , data = q :next ()
310
+
311
+ e , data = q .next ()
307
312
end
308
313
CHECK (true )
309
314
end
743
748
added = true
744
749
local q = world :query (T ):without (PreviousT ):drain ()
745
750
return function ()
746
- local id , data = q : next ()
751
+ local id , data = q . next ()
747
752
if not id then
748
753
return nil
749
754
end
762
767
local q = world :query (T , PreviousT ):drain ()
763
768
764
769
return function ()
765
- local id , new , old = q : next ()
770
+ local id , new , old = q . next ()
766
771
while true do
767
772
if not id then
768
773
return nil
788
793
789
794
local q = world :query (PreviousT ):without (T ):drain ()
790
795
return function ()
791
- local id = q : next ()
796
+ local id = q . next ()
792
797
if id then
793
798
world :remove (id , PreviousT )
794
799
end
You can’t perform that action at this time.
0 commit comments