Skip to content

Commit

Permalink
Add valid component checks
Browse files Browse the repository at this point in the history
  • Loading branch information
memorycode committed Nov 23, 2024
1 parent 1216f89 commit 52ec4d8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/World.luau
Original file line number Diff line number Diff line change
Expand Up @@ -560,14 +560,28 @@ function World:get(entityId: EntityId, ...: Component)
local a, b, c, d = ...
local length = select("#", ...)
if length == 1 then
assertValidComponent(a, 1)

return field(entityRecord, archetype, idToIndex, a)
elseif length == 2 then
assertValidComponent(a, 1)
assertValidComponent(b, 2)

return field(entityRecord, archetype, idToIndex, a), field(entityRecord, archetype, idToIndex, b)
elseif length == 3 then
assertValidComponent(a, 1)
assertValidComponent(b, 2)
assertValidComponent(c, 3)

return field(entityRecord, archetype, idToIndex, a),
field(entityRecord, archetype, idToIndex, b),
field(entityRecord, archetype, idToIndex, c)
elseif length == 4 then
assertValidComponent(a, 1)
assertValidComponent(b, 2)
assertValidComponent(c, 3)
assertValidComponent(d, 4)

return field(entityRecord, archetype, idToIndex, a),
field(entityRecord, archetype, idToIndex, b),
field(entityRecord, archetype, idToIndex, c),
Expand Down

0 comments on commit 52ec4d8

Please sign in to comment.