11import macros, sequtils, options, tables
22import tupleDirective, tools, commonVars, archetype, componentDef, worldEnum, systemGen
3- import ../ runtime/ [world, archetypeStore, directives]
3+ import ../ runtime/ [world, archetypeStore, directives], ../ util / bits
44
55let entityId {.compileTime .} = ident (" entityId" )
66
@@ -30,10 +30,6 @@ proc buildArchetypeLookup(
3030proc worldFields (name: string , dir: TupleDirective ): seq [WorldField ] =
3131 @ [ (name, nnkBracketExpr.newTree (bindSym (" Lookup" ), dir.asTupleType)) ]
3232
33- proc canCreateFrom (lookup: TupleDirective , archetype: Archetype [ComponentDef ]): bool =
34- # # Returns whether a lookup can be created from an archetype
35- lookup.items.toSeq.allIt (it in archetype)
36-
3733proc generate (details: GenerateContext , arg: SystemArg , name: string , lookup: TupleDirective ): NimNode =
3834 # # Generates the code for instantiating queries
3935
@@ -51,7 +47,7 @@ proc generate(details: GenerateContext, arg: SystemArg, name: string, lookup: Tu
5147 # Create a case statement where each branch is one of the archetypes
5248 var needsElse = false
5349 for (ofBranch, archetype) in archetypeCases (details):
54- if lookup. canCreateFrom (archetype ):
50+ if archetype.bitset. matches (lookup.filter ):
5551 cases.add (nnkOfBranch.newTree (ofBranch, details.buildArchetypeLookup (lookup, archetype)))
5652 else :
5753 needsElse = true
0 commit comments