Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
memorycode committed Oct 4, 2024
1 parent 0b461d6 commit 9a61bed
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/World.luau
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ local function executeReplace(world: World, replaceCommand: ReplaceCommand)
world:_trackChanged(
component,
entityId,
if storageIndex then oldArchetype.storage[storageIndex][entityRecord.indexInArchetype] else nil,
if storageIndex then oldArchetype.fields[storageIndex][entityRecord.indexInArchetype] else nil,
componentInstance
)

Expand Down Expand Up @@ -698,6 +698,8 @@ function QueryResult.new(compatibleArchetypes, queryLength: number, componentIds
g = storage[componentIdToStorageIndex[G]]
h = storage[componentIdToStorageIndex[H]]
end

-- For anything longer, we do not cache.
end

local entityId: number
Expand Down Expand Up @@ -758,7 +760,13 @@ function QueryResult.new(compatibleArchetypes, queryLength: number, componentIds
g[entityIndex],
h[entityIndex]
else
error("Unimplemented Query Length")
local output = table.create(queryLength)
for index, componentId in componentIds do
output[index] =
currentArchetype.fields[currentArchetype.componentToStorageIndex[componentId]][entityIndex]
end

return unpack(output, 1, queryLength)
end
end

Expand Down Expand Up @@ -795,6 +803,8 @@ function QueryResult.new(compatibleArchetypes, queryLength: number, componentIds
end

currentArchetype = compatibleArchetypes[1]
currentEntities = currentArchetype.ownedEntities

cacheComponentStorages()
return query
end
Expand Down Expand Up @@ -829,11 +839,14 @@ function QueryResult.new(compatibleArchetypes, queryLength: number, componentIds
return entities
end

local function view() end

cacheComponentStorages()
return setmetatable({
next = nextEntity,
without = without,
snapshot = snapshot,
view = view,
}, {
__iter = iter,
__call = nextEntity,
Expand Down Expand Up @@ -1134,7 +1147,7 @@ function World.query(self: World, ...)
else
componentIds = table.create(queryLength)
for i = 1, queryLength do
componentIds[i] = select(i, ...)
componentIds[i] = #select(i, ...)
end
end

Expand Down

0 comments on commit 9a61bed

Please sign in to comment.