Skip to content
Closed
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
14 changes: 13 additions & 1 deletion ecs/internal/generate/query.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ func (q *Query{{.}}{{$genericsShort}}) Close() {
q.world.unlockSafe(q.lock)
}

// IsClosed reports whether the query was closed.
//
// A query is considered closed after iteration finishes or Close()
// is called manually. Internally, this is represented by the cursor's
// table index being set to a value less than -1.
//
// Closed queries cannot be iterated and should not be reused.
// Create a new query instead.
func (q *Query{{.}}{{$genericsShort}}) IsClosed() bool {
return q.cursor.table < -1
}

func (q *Query{{.}}{{$genericsShort}}) nextTableOrArchetype() bool {
if q.cache != nil {
return q.nextTable(q.cache.tables.tables)
Expand All @@ -155,7 +167,7 @@ func (q *Query{{.}}{{$genericsShort}}) nextArchetype() bool {
for q.cursor.archetype < maxArchIndex {
q.cursor.archetype++
archetype := &q.world.storage.archetypes[archetypes[q.cursor.archetype]]

if !q.filter.matches(&archetype.mask) {
continue
}
Expand Down
108 changes: 108 additions & 0 deletions ecs/query_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.