Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Ark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ include("batch.jl")
#include("docs.jl") # doctest setup

export World
export is_alive, new_entity!, new_entities!, copy_entity!
export is_alive, new_entity!, new_entities!, collect_entities, collect_entities!, copy_entity!
export remove_entity!, zero_entity, is_locked, reset!
export get_components, set_components!, has_components
export add_components!, remove_components!
Expand Down
18 changes: 18 additions & 0 deletions src/query.jl
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,24 @@ function count_entities(q::Query)
count
end

function collect_entities!(q::Query, all_entities::AbstractVector{Entity})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the Julia style guide, the mutated arg should be the first one.

count = count_entities(q)
resize!(all_entities, count)
offset = 1
for archetype in q._archetypes
if isempty(archetype.entities)
continue
end
if _contains_all(archetype.mask, q._mask) &&
!(q._has_excluded && _contains_any(archetype.mask, q._exclude_mask))
e = archetype.entities
unsafe_copyto!(all_entities, offset, e, 1, length(e))
offset += length(e)
end
end
return all_entities
end

"""
close!(q::Query)

Expand Down
Loading