package ecs
import "unsafe"
type cursor struct {
archetype int32
table int32
index uintptr
maxIndex int64
}
type Query0 struct {
world *World
filter *filter
table *table
cache *cacheEntry
relations []relationID
tables []tableID
components []*componentStorage
cursor cursor
lock uint8
rareComp uint8
hasRareComp bool
}
func (q *Query0 ) Count () int {
if q .cache == nil {
if q .hasRareComp {
return countQuery (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ])
}
return countQuery (&q .world .storage , q .filter , q .relations , q .world .storage .allArchetypes )
}
return countQueryCache (&q .world .storage , q .cache , q .relations )
}
func (q *Query0 ) EntityAt (index int ) Entity {
if q .cache == nil {
if q .hasRareComp {
return entityAt (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ], uint32 (index ))
}
return entityAt (&q .world .storage , q .filter , q .relations , q .world .storage .allArchetypes , uint32 (index ))
}
return entityAtCache (&q .world .storage , q .cache , q .relations , uint32 (index ))
}
func (q *Query0 ) Close () {
if q .cursor .table < -1 {
return
}
q .cursor .archetype = -2
q .cursor .table = -2
q .tables = nil
q .table = nil
q .cache = nil
q .world .unlockSafe (q .lock )
}
func (q *Query0 ) nextTableOrArchetype () bool {
if q .cache != nil {
return q .nextTable (q .cache .tables .tables )
}
if q .cursor .archetype >= 0 && q .nextTable (q .tables ) {
return true
}
return q .nextArchetype ()
}
func (q *Query0 ) nextArchetype () bool {
q .tables = nil
var archetypes []archetypeID
if q .hasRareComp {
archetypes = q .world .storage .componentIndex [q .rareComp ]
} else {
archetypes = q .world .storage .allArchetypes
}
maxArchIndex := int32 (len (archetypes ) - 1 )
for q .cursor .archetype < maxArchIndex {
q .cursor .archetype ++
archetype := &q .world .storage .archetypes [archetypes [q .cursor .archetype ]]
if !q .filter .matches (&archetype .mask ) {
continue
}
if !archetype .HasRelations () {
table := &q .world .storage .tables [archetype .tables .tables [0 ]]
if table .len > 0 {
q .setTable (0 , table )
return true
}
continue
}
q .tables = archetype .GetTables (q .relations )
q .cursor .table = -1
if q .nextTable (q .tables ) {
return true
}
}
q .Close ()
return false
}
func (q *Query0 ) nextTable (tables []tableID ) bool {
maxTableIndex := int32 (len (tables ) - 1 )
for q .cursor .table < maxTableIndex {
q .cursor .table ++
table := &q .world .storage .tables [tables [q .cursor .table ]]
if table .len == 0 || !table .Matches (q .relations ) {
continue
}
q .setTable (q .cursor .table , table )
return true
}
if q .cache != nil {
q .Close ()
}
return false
}
func (q *Query0 ) setTable (index int32 , table *table ) {
q .cursor .table = index
q .table = table
q .cursor .index = 0
q .cursor .maxIndex = int64 (q .table .len - 1 )
}
type Query1 [A any ] struct {
world *World
filter *filter
table *table
cache *cacheEntry
columnA *column
columnPtrA unsafe .Pointer
itemSizeA uintptr
relations []relationID
tables []tableID
components []*componentStorage
cursor cursor
lock uint8
rareComp uint8
}
func (q *Query1 [A ]) GetRelation (index int ) Entity {
return q .components [index ].columns [q .table .id ].target
}
func (q *Query1 [A ]) Count () int {
if q .cache == nil {
return countQuery (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ])
}
return countQueryCache (&q .world .storage , q .cache , q .relations )
}
func (q *Query1 [A ]) EntityAt (index int ) Entity {
if q .cache == nil {
return entityAt (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ], uint32 (index ))
}
return entityAtCache (&q .world .storage , q .cache , q .relations , uint32 (index ))
}
func (q *Query1 [A ]) Close () {
if q .cursor .table < -1 {
return
}
q .cursor .archetype = -2
q .cursor .table = -2
q .tables = nil
q .table = nil
q .cache = nil
q .columnA = nil
q .columnPtrA = unsafe .Pointer (nilDummy )
q .itemSizeA = 0
q .world .unlockSafe (q .lock )
}
func (q *Query1 [A ]) nextTableOrArchetype () bool {
if q .cache != nil {
return q .nextTable (q .cache .tables .tables )
}
if q .cursor .archetype >= 0 && q .nextTable (q .tables ) {
return true
}
return q .nextArchetype ()
}
func (q *Query1 [A ]) nextArchetype () bool {
q .tables = nil
archetypes := q .world .storage .componentIndex [q .rareComp ]
maxArchIndex := int32 (len (archetypes ) - 1 )
for q .cursor .archetype < maxArchIndex {
q .cursor .archetype ++
archetype := &q .world .storage .archetypes [archetypes [q .cursor .archetype ]]
if !q .filter .matches (&archetype .mask ) {
continue
}
if !archetype .HasRelations () {
table := &q .world .storage .tables [archetype .tables .tables [0 ]]
if table .len > 0 {
q .setTable (0 , table )
return true
}
continue
}
q .tables = archetype .GetTables (q .relations )
q .cursor .table = -1
if q .nextTable (q .tables ) {
return true
}
}
q .Close ()
return false
}
func (q *Query1 [A ]) nextTable (tables []tableID ) bool {
maxTableIndex := int32 (len (tables ) - 1 )
for q .cursor .table < maxTableIndex {
q .cursor .table ++
table := &q .world .storage .tables [tables [q .cursor .table ]]
if table .len == 0 || !table .Matches (q .relations ) {
continue
}
q .setTable (q .cursor .table , table )
return true
}
if q .cache != nil {
q .Close ()
}
return false
}
func (q *Query1 [A ]) setTable (index int32 , table *table ) {
q .cursor .table = index
q .table = table
q .columnA = q .components [0 ].columns [q .table .id ]
q .columnPtrA = q .columnA .pointer
q .itemSizeA = q .columnA .itemSize
q .cursor .index = 0
q .cursor .maxIndex = int64 (q .table .len - 1 )
}
type Query2 [A any , B any ] struct {
world *World
filter *filter
table *table
cache *cacheEntry
columnA *column
columnPtrA unsafe .Pointer
itemSizeA uintptr
columnB *column
columnPtrB unsafe .Pointer
itemSizeB uintptr
relations []relationID
tables []tableID
components []*componentStorage
cursor cursor
lock uint8
rareComp uint8
}
func (q *Query2 [A , B ]) GetRelation (index int ) Entity {
return q .components [index ].columns [q .table .id ].target
}
func (q *Query2 [A , B ]) Count () int {
if q .cache == nil {
return countQuery (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ])
}
return countQueryCache (&q .world .storage , q .cache , q .relations )
}
func (q *Query2 [A , B ]) EntityAt (index int ) Entity {
if q .cache == nil {
return entityAt (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ], uint32 (index ))
}
return entityAtCache (&q .world .storage , q .cache , q .relations , uint32 (index ))
}
func (q *Query2 [A , B ]) Close () {
if q .cursor .table < -1 {
return
}
q .cursor .archetype = -2
q .cursor .table = -2
q .tables = nil
q .table = nil
q .cache = nil
q .columnA = nil
q .columnPtrA = unsafe .Pointer (nilDummy )
q .itemSizeA = 0
q .columnB = nil
q .columnPtrB = unsafe .Pointer (nilDummy )
q .itemSizeB = 0
q .world .unlockSafe (q .lock )
}
func (q *Query2 [A , B ]) nextTableOrArchetype () bool {
if q .cache != nil {
return q .nextTable (q .cache .tables .tables )
}
if q .cursor .archetype >= 0 && q .nextTable (q .tables ) {
return true
}
return q .nextArchetype ()
}
func (q *Query2 [A , B ]) nextArchetype () bool {
q .tables = nil
archetypes := q .world .storage .componentIndex [q .rareComp ]
maxArchIndex := int32 (len (archetypes ) - 1 )
for q .cursor .archetype < maxArchIndex {
q .cursor .archetype ++
archetype := &q .world .storage .archetypes [archetypes [q .cursor .archetype ]]
if !q .filter .matches (&archetype .mask ) {
continue
}
if !archetype .HasRelations () {
table := &q .world .storage .tables [archetype .tables .tables [0 ]]
if table .len > 0 {
q .setTable (0 , table )
return true
}
continue
}
q .tables = archetype .GetTables (q .relations )
q .cursor .table = -1
if q .nextTable (q .tables ) {
return true
}
}
q .Close ()
return false
}
func (q *Query2 [A , B ]) nextTable (tables []tableID ) bool {
maxTableIndex := int32 (len (tables ) - 1 )
for q .cursor .table < maxTableIndex {
q .cursor .table ++
table := &q .world .storage .tables [tables [q .cursor .table ]]
if table .len == 0 || !table .Matches (q .relations ) {
continue
}
q .setTable (q .cursor .table , table )
return true
}
if q .cache != nil {
q .Close ()
}
return false
}
func (q *Query2 [A , B ]) setTable (index int32 , table *table ) {
q .cursor .table = index
q .table = table
q .columnA = q .components [0 ].columns [q .table .id ]
q .columnPtrA = q .columnA .pointer
q .itemSizeA = q .columnA .itemSize
q .columnB = q .components [1 ].columns [q .table .id ]
q .columnPtrB = q .columnB .pointer
q .itemSizeB = q .columnB .itemSize
q .cursor .index = 0
q .cursor .maxIndex = int64 (q .table .len - 1 )
}
type Query3 [A any , B any , C any ] struct {
world *World
filter *filter
table *table
cache *cacheEntry
columnA *column
columnPtrA unsafe .Pointer
itemSizeA uintptr
columnB *column
columnPtrB unsafe .Pointer
itemSizeB uintptr
columnC *column
columnPtrC unsafe .Pointer
itemSizeC uintptr
relations []relationID
tables []tableID
components []*componentStorage
cursor cursor
lock uint8
rareComp uint8
}
func (q *Query3 [A , B , C ]) GetRelation (index int ) Entity {
return q .components [index ].columns [q .table .id ].target
}
func (q *Query3 [A , B , C ]) Count () int {
if q .cache == nil {
return countQuery (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ])
}
return countQueryCache (&q .world .storage , q .cache , q .relations )
}
func (q *Query3 [A , B , C ]) EntityAt (index int ) Entity {
if q .cache == nil {
return entityAt (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ], uint32 (index ))
}
return entityAtCache (&q .world .storage , q .cache , q .relations , uint32 (index ))
}
func (q *Query3 [A , B , C ]) Close () {
if q .cursor .table < -1 {
return
}
q .cursor .archetype = -2
q .cursor .table = -2
q .tables = nil
q .table = nil
q .cache = nil
q .columnA = nil
q .columnPtrA = unsafe .Pointer (nilDummy )
q .itemSizeA = 0
q .columnB = nil
q .columnPtrB = unsafe .Pointer (nilDummy )
q .itemSizeB = 0
q .columnC = nil
q .columnPtrC = unsafe .Pointer (nilDummy )
q .itemSizeC = 0
q .world .unlockSafe (q .lock )
}
func (q *Query3 [A , B , C ]) nextTableOrArchetype () bool {
if q .cache != nil {
return q .nextTable (q .cache .tables .tables )
}
if q .cursor .archetype >= 0 && q .nextTable (q .tables ) {
return true
}
return q .nextArchetype ()
}
func (q *Query3 [A , B , C ]) nextArchetype () bool {
q .tables = nil
archetypes := q .world .storage .componentIndex [q .rareComp ]
maxArchIndex := int32 (len (archetypes ) - 1 )
for q .cursor .archetype < maxArchIndex {
q .cursor .archetype ++
archetype := &q .world .storage .archetypes [archetypes [q .cursor .archetype ]]
if !q .filter .matches (&archetype .mask ) {
continue
}
if !archetype .HasRelations () {
table := &q .world .storage .tables [archetype .tables .tables [0 ]]
if table .len > 0 {
q .setTable (0 , table )
return true
}
continue
}
q .tables = archetype .GetTables (q .relations )
q .cursor .table = -1
if q .nextTable (q .tables ) {
return true
}
}
q .Close ()
return false
}
func (q *Query3 [A , B , C ]) nextTable (tables []tableID ) bool {
maxTableIndex := int32 (len (tables ) - 1 )
for q .cursor .table < maxTableIndex {
q .cursor .table ++
table := &q .world .storage .tables [tables [q .cursor .table ]]
if table .len == 0 || !table .Matches (q .relations ) {
continue
}
q .setTable (q .cursor .table , table )
return true
}
if q .cache != nil {
q .Close ()
}
return false
}
func (q *Query3 [A , B , C ]) setTable (index int32 , table *table ) {
q .cursor .table = index
q .table = table
q .columnA = q .components [0 ].columns [q .table .id ]
q .columnPtrA = q .columnA .pointer
q .itemSizeA = q .columnA .itemSize
q .columnB = q .components [1 ].columns [q .table .id ]
q .columnPtrB = q .columnB .pointer
q .itemSizeB = q .columnB .itemSize
q .columnC = q .components [2 ].columns [q .table .id ]
q .columnPtrC = q .columnC .pointer
q .itemSizeC = q .columnC .itemSize
q .cursor .index = 0
q .cursor .maxIndex = int64 (q .table .len - 1 )
}
type Query4 [A any , B any , C any , D any ] struct {
world *World
filter *filter
table *table
cache *cacheEntry
columnA *column
columnPtrA unsafe .Pointer
itemSizeA uintptr
columnB *column
columnPtrB unsafe .Pointer
itemSizeB uintptr
columnC *column
columnPtrC unsafe .Pointer
itemSizeC uintptr
columnD *column
columnPtrD unsafe .Pointer
itemSizeD uintptr
relations []relationID
tables []tableID
components []*componentStorage
cursor cursor
lock uint8
rareComp uint8
}
func (q *Query4 [A , B , C , D ]) GetRelation (index int ) Entity {
return q .components [index ].columns [q .table .id ].target
}
func (q *Query4 [A , B , C , D ]) Count () int {
if q .cache == nil {
return countQuery (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ])
}
return countQueryCache (&q .world .storage , q .cache , q .relations )
}
func (q *Query4 [A , B , C , D ]) EntityAt (index int ) Entity {
if q .cache == nil {
return entityAt (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ], uint32 (index ))
}
return entityAtCache (&q .world .storage , q .cache , q .relations , uint32 (index ))
}
func (q *Query4 [A , B , C , D ]) Close () {
if q .cursor .table < -1 {
return
}
q .cursor .archetype = -2
q .cursor .table = -2
q .tables = nil
q .table = nil
q .cache = nil
q .columnA = nil
q .columnPtrA = unsafe .Pointer (nilDummy )
q .itemSizeA = 0
q .columnB = nil
q .columnPtrB = unsafe .Pointer (nilDummy )
q .itemSizeB = 0
q .columnC = nil
q .columnPtrC = unsafe .Pointer (nilDummy )
q .itemSizeC = 0
q .columnD = nil
q .columnPtrD = unsafe .Pointer (nilDummy )
q .itemSizeD = 0
q .world .unlockSafe (q .lock )
}
func (q *Query4 [A , B , C , D ]) nextTableOrArchetype () bool {
if q .cache != nil {
return q .nextTable (q .cache .tables .tables )
}
if q .cursor .archetype >= 0 && q .nextTable (q .tables ) {
return true
}
return q .nextArchetype ()
}
func (q *Query4 [A , B , C , D ]) nextArchetype () bool {
q .tables = nil
archetypes := q .world .storage .componentIndex [q .rareComp ]
maxArchIndex := int32 (len (archetypes ) - 1 )
for q .cursor .archetype < maxArchIndex {
q .cursor .archetype ++
archetype := &q .world .storage .archetypes [archetypes [q .cursor .archetype ]]
if !q .filter .matches (&archetype .mask ) {
continue
}
if !archetype .HasRelations () {
table := &q .world .storage .tables [archetype .tables .tables [0 ]]
if table .len > 0 {
q .setTable (0 , table )
return true
}
continue
}
q .tables = archetype .GetTables (q .relations )
q .cursor .table = -1
if q .nextTable (q .tables ) {
return true
}
}
q .Close ()
return false
}
func (q *Query4 [A , B , C , D ]) nextTable (tables []tableID ) bool {
maxTableIndex := int32 (len (tables ) - 1 )
for q .cursor .table < maxTableIndex {
q .cursor .table ++
table := &q .world .storage .tables [tables [q .cursor .table ]]
if table .len == 0 || !table .Matches (q .relations ) {
continue
}
q .setTable (q .cursor .table , table )
return true
}
if q .cache != nil {
q .Close ()
}
return false
}
func (q *Query4 [A , B , C , D ]) setTable (index int32 , table *table ) {
q .cursor .table = index
q .table = table
q .columnA = q .components [0 ].columns [q .table .id ]
q .columnPtrA = q .columnA .pointer
q .itemSizeA = q .columnA .itemSize
q .columnB = q .components [1 ].columns [q .table .id ]
q .columnPtrB = q .columnB .pointer
q .itemSizeB = q .columnB .itemSize
q .columnC = q .components [2 ].columns [q .table .id ]
q .columnPtrC = q .columnC .pointer
q .itemSizeC = q .columnC .itemSize
q .columnD = q .components [3 ].columns [q .table .id ]
q .columnPtrD = q .columnD .pointer
q .itemSizeD = q .columnD .itemSize
q .cursor .index = 0
q .cursor .maxIndex = int64 (q .table .len - 1 )
}
type Query5 [A any , B any , C any , D any , E any ] struct {
world *World
filter *filter
table *table
cache *cacheEntry
columnA *column
columnPtrA unsafe .Pointer
itemSizeA uintptr
columnB *column
columnPtrB unsafe .Pointer
itemSizeB uintptr
columnC *column
columnPtrC unsafe .Pointer
itemSizeC uintptr
columnD *column
columnPtrD unsafe .Pointer
itemSizeD uintptr
columnE *column
columnPtrE unsafe .Pointer
itemSizeE uintptr
relations []relationID
tables []tableID
components []*componentStorage
cursor cursor
lock uint8
rareComp uint8
}
func (q *Query5 [A , B , C , D , E ]) GetRelation (index int ) Entity {
return q .components [index ].columns [q .table .id ].target
}
func (q *Query5 [A , B , C , D , E ]) Count () int {
if q .cache == nil {
return countQuery (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ])
}
return countQueryCache (&q .world .storage , q .cache , q .relations )
}
func (q *Query5 [A , B , C , D , E ]) EntityAt (index int ) Entity {
if q .cache == nil {
return entityAt (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ], uint32 (index ))
}
return entityAtCache (&q .world .storage , q .cache , q .relations , uint32 (index ))
}
func (q *Query5 [A , B , C , D , E ]) Close () {
if q .cursor .table < -1 {
return
}
q .cursor .archetype = -2
q .cursor .table = -2
q .tables = nil
q .table = nil
q .cache = nil
q .columnA = nil
q .columnPtrA = unsafe .Pointer (nilDummy )
q .itemSizeA = 0
q .columnB = nil
q .columnPtrB = unsafe .Pointer (nilDummy )
q .itemSizeB = 0
q .columnC = nil
q .columnPtrC = unsafe .Pointer (nilDummy )
q .itemSizeC = 0
q .columnD = nil
q .columnPtrD = unsafe .Pointer (nilDummy )
q .itemSizeD = 0
q .columnE = nil
q .columnPtrE = unsafe .Pointer (nilDummy )
q .itemSizeE = 0
q .world .unlockSafe (q .lock )
}
func (q *Query5 [A , B , C , D , E ]) nextTableOrArchetype () bool {
if q .cache != nil {
return q .nextTable (q .cache .tables .tables )
}
if q .cursor .archetype >= 0 && q .nextTable (q .tables ) {
return true
}
return q .nextArchetype ()
}
func (q *Query5 [A , B , C , D , E ]) nextArchetype () bool {
q .tables = nil
archetypes := q .world .storage .componentIndex [q .rareComp ]
maxArchIndex := int32 (len (archetypes ) - 1 )
for q .cursor .archetype < maxArchIndex {
q .cursor .archetype ++
archetype := &q .world .storage .archetypes [archetypes [q .cursor .archetype ]]
if !q .filter .matches (&archetype .mask ) {
continue
}
if !archetype .HasRelations () {
table := &q .world .storage .tables [archetype .tables .tables [0 ]]
if table .len > 0 {
q .setTable (0 , table )
return true
}
continue
}
q .tables = archetype .GetTables (q .relations )
q .cursor .table = -1
if q .nextTable (q .tables ) {
return true
}
}
q .Close ()
return false
}
func (q *Query5 [A , B , C , D , E ]) nextTable (tables []tableID ) bool {
maxTableIndex := int32 (len (tables ) - 1 )
for q .cursor .table < maxTableIndex {
q .cursor .table ++
table := &q .world .storage .tables [tables [q .cursor .table ]]
if table .len == 0 || !table .Matches (q .relations ) {
continue
}
q .setTable (q .cursor .table , table )
return true
}
if q .cache != nil {
q .Close ()
}
return false
}
func (q *Query5 [A , B , C , D , E ]) setTable (index int32 , table *table ) {
q .cursor .table = index
q .table = table
q .columnA = q .components [0 ].columns [q .table .id ]
q .columnPtrA = q .columnA .pointer
q .itemSizeA = q .columnA .itemSize
q .columnB = q .components [1 ].columns [q .table .id ]
q .columnPtrB = q .columnB .pointer
q .itemSizeB = q .columnB .itemSize
q .columnC = q .components [2 ].columns [q .table .id ]
q .columnPtrC = q .columnC .pointer
q .itemSizeC = q .columnC .itemSize
q .columnD = q .components [3 ].columns [q .table .id ]
q .columnPtrD = q .columnD .pointer
q .itemSizeD = q .columnD .itemSize
q .columnE = q .components [4 ].columns [q .table .id ]
q .columnPtrE = q .columnE .pointer
q .itemSizeE = q .columnE .itemSize
q .cursor .index = 0
q .cursor .maxIndex = int64 (q .table .len - 1 )
}
type Query6 [A any , B any , C any , D any , E any , F any ] struct {
world *World
filter *filter
table *table
cache *cacheEntry
columnA *column
columnPtrA unsafe .Pointer
itemSizeA uintptr
columnB *column
columnPtrB unsafe .Pointer
itemSizeB uintptr
columnC *column
columnPtrC unsafe .Pointer
itemSizeC uintptr
columnD *column
columnPtrD unsafe .Pointer
itemSizeD uintptr
columnE *column
columnPtrE unsafe .Pointer
itemSizeE uintptr
columnF *column
columnPtrF unsafe .Pointer
itemSizeF uintptr
relations []relationID
tables []tableID
components []*componentStorage
cursor cursor
lock uint8
rareComp uint8
}
func (q *Query6 [A , B , C , D , E , F ]) GetRelation (index int ) Entity {
return q .components [index ].columns [q .table .id ].target
}
func (q *Query6 [A , B , C , D , E , F ]) Count () int {
if q .cache == nil {
return countQuery (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ])
}
return countQueryCache (&q .world .storage , q .cache , q .relations )
}
func (q *Query6 [A , B , C , D , E , F ]) EntityAt (index int ) Entity {
if q .cache == nil {
return entityAt (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ], uint32 (index ))
}
return entityAtCache (&q .world .storage , q .cache , q .relations , uint32 (index ))
}
func (q *Query6 [A , B , C , D , E , F ]) Close () {
if q .cursor .table < -1 {
return
}
q .cursor .archetype = -2
q .cursor .table = -2
q .tables = nil
q .table = nil
q .cache = nil
q .columnA = nil
q .columnPtrA = unsafe .Pointer (nilDummy )
q .itemSizeA = 0
q .columnB = nil
q .columnPtrB = unsafe .Pointer (nilDummy )
q .itemSizeB = 0
q .columnC = nil
q .columnPtrC = unsafe .Pointer (nilDummy )
q .itemSizeC = 0
q .columnD = nil
q .columnPtrD = unsafe .Pointer (nilDummy )
q .itemSizeD = 0
q .columnE = nil
q .columnPtrE = unsafe .Pointer (nilDummy )
q .itemSizeE = 0
q .columnF = nil
q .columnPtrF = unsafe .Pointer (nilDummy )
q .itemSizeF = 0
q .world .unlockSafe (q .lock )
}
func (q *Query6 [A , B , C , D , E , F ]) nextTableOrArchetype () bool {
if q .cache != nil {
return q .nextTable (q .cache .tables .tables )
}
if q .cursor .archetype >= 0 && q .nextTable (q .tables ) {
return true
}
return q .nextArchetype ()
}
func (q *Query6 [A , B , C , D , E , F ]) nextArchetype () bool {
q .tables = nil
archetypes := q .world .storage .componentIndex [q .rareComp ]
maxArchIndex := int32 (len (archetypes ) - 1 )
for q .cursor .archetype < maxArchIndex {
q .cursor .archetype ++
archetype := &q .world .storage .archetypes [archetypes [q .cursor .archetype ]]
if !q .filter .matches (&archetype .mask ) {
continue
}
if !archetype .HasRelations () {
table := &q .world .storage .tables [archetype .tables .tables [0 ]]
if table .len > 0 {
q .setTable (0 , table )
return true
}
continue
}
q .tables = archetype .GetTables (q .relations )
q .cursor .table = -1
if q .nextTable (q .tables ) {
return true
}
}
q .Close ()
return false
}
func (q *Query6 [A , B , C , D , E , F ]) nextTable (tables []tableID ) bool {
maxTableIndex := int32 (len (tables ) - 1 )
for q .cursor .table < maxTableIndex {
q .cursor .table ++
table := &q .world .storage .tables [tables [q .cursor .table ]]
if table .len == 0 || !table .Matches (q .relations ) {
continue
}
q .setTable (q .cursor .table , table )
return true
}
if q .cache != nil {
q .Close ()
}
return false
}
func (q *Query6 [A , B , C , D , E , F ]) setTable (index int32 , table *table ) {
q .cursor .table = index
q .table = table
q .columnA = q .components [0 ].columns [q .table .id ]
q .columnPtrA = q .columnA .pointer
q .itemSizeA = q .columnA .itemSize
q .columnB = q .components [1 ].columns [q .table .id ]
q .columnPtrB = q .columnB .pointer
q .itemSizeB = q .columnB .itemSize
q .columnC = q .components [2 ].columns [q .table .id ]
q .columnPtrC = q .columnC .pointer
q .itemSizeC = q .columnC .itemSize
q .columnD = q .components [3 ].columns [q .table .id ]
q .columnPtrD = q .columnD .pointer
q .itemSizeD = q .columnD .itemSize
q .columnE = q .components [4 ].columns [q .table .id ]
q .columnPtrE = q .columnE .pointer
q .itemSizeE = q .columnE .itemSize
q .columnF = q .components [5 ].columns [q .table .id ]
q .columnPtrF = q .columnF .pointer
q .itemSizeF = q .columnF .itemSize
q .cursor .index = 0
q .cursor .maxIndex = int64 (q .table .len - 1 )
}
type Query7 [A any , B any , C any , D any , E any , F any , G any ] struct {
world *World
filter *filter
table *table
cache *cacheEntry
columnA *column
columnPtrA unsafe .Pointer
itemSizeA uintptr
columnB *column
columnPtrB unsafe .Pointer
itemSizeB uintptr
columnC *column
columnPtrC unsafe .Pointer
itemSizeC uintptr
columnD *column
columnPtrD unsafe .Pointer
itemSizeD uintptr
columnE *column
columnPtrE unsafe .Pointer
itemSizeE uintptr
columnF *column
columnPtrF unsafe .Pointer
itemSizeF uintptr
columnG *column
columnPtrG unsafe .Pointer
itemSizeG uintptr
relations []relationID
tables []tableID
components []*componentStorage
cursor cursor
lock uint8
rareComp uint8
}
func (q *Query7 [A , B , C , D , E , F , G ]) GetRelation (index int ) Entity {
return q .components [index ].columns [q .table .id ].target
}
func (q *Query7 [A , B , C , D , E , F , G ]) Count () int {
if q .cache == nil {
return countQuery (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ])
}
return countQueryCache (&q .world .storage , q .cache , q .relations )
}
func (q *Query7 [A , B , C , D , E , F , G ]) EntityAt (index int ) Entity {
if q .cache == nil {
return entityAt (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ], uint32 (index ))
}
return entityAtCache (&q .world .storage , q .cache , q .relations , uint32 (index ))
}
func (q *Query7 [A , B , C , D , E , F , G ]) Close () {
if q .cursor .table < -1 {
return
}
q .cursor .archetype = -2
q .cursor .table = -2
q .tables = nil
q .table = nil
q .cache = nil
q .columnA = nil
q .columnPtrA = unsafe .Pointer (nilDummy )
q .itemSizeA = 0
q .columnB = nil
q .columnPtrB = unsafe .Pointer (nilDummy )
q .itemSizeB = 0
q .columnC = nil
q .columnPtrC = unsafe .Pointer (nilDummy )
q .itemSizeC = 0
q .columnD = nil
q .columnPtrD = unsafe .Pointer (nilDummy )
q .itemSizeD = 0
q .columnE = nil
q .columnPtrE = unsafe .Pointer (nilDummy )
q .itemSizeE = 0
q .columnF = nil
q .columnPtrF = unsafe .Pointer (nilDummy )
q .itemSizeF = 0
q .columnG = nil
q .columnPtrG = unsafe .Pointer (nilDummy )
q .itemSizeG = 0
q .world .unlockSafe (q .lock )
}
func (q *Query7 [A , B , C , D , E , F , G ]) nextTableOrArchetype () bool {
if q .cache != nil {
return q .nextTable (q .cache .tables .tables )
}
if q .cursor .archetype >= 0 && q .nextTable (q .tables ) {
return true
}
return q .nextArchetype ()
}
func (q *Query7 [A , B , C , D , E , F , G ]) nextArchetype () bool {
q .tables = nil
archetypes := q .world .storage .componentIndex [q .rareComp ]
maxArchIndex := int32 (len (archetypes ) - 1 )
for q .cursor .archetype < maxArchIndex {
q .cursor .archetype ++
archetype := &q .world .storage .archetypes [archetypes [q .cursor .archetype ]]
if !q .filter .matches (&archetype .mask ) {
continue
}
if !archetype .HasRelations () {
table := &q .world .storage .tables [archetype .tables .tables [0 ]]
if table .len > 0 {
q .setTable (0 , table )
return true
}
continue
}
q .tables = archetype .GetTables (q .relations )
q .cursor .table = -1
if q .nextTable (q .tables ) {
return true
}
}
q .Close ()
return false
}
func (q *Query7 [A , B , C , D , E , F , G ]) nextTable (tables []tableID ) bool {
maxTableIndex := int32 (len (tables ) - 1 )
for q .cursor .table < maxTableIndex {
q .cursor .table ++
table := &q .world .storage .tables [tables [q .cursor .table ]]
if table .len == 0 || !table .Matches (q .relations ) {
continue
}
q .setTable (q .cursor .table , table )
return true
}
if q .cache != nil {
q .Close ()
}
return false
}
func (q *Query7 [A , B , C , D , E , F , G ]) setTable (index int32 , table *table ) {
q .cursor .table = index
q .table = table
q .columnA = q .components [0 ].columns [q .table .id ]
q .columnPtrA = q .columnA .pointer
q .itemSizeA = q .columnA .itemSize
q .columnB = q .components [1 ].columns [q .table .id ]
q .columnPtrB = q .columnB .pointer
q .itemSizeB = q .columnB .itemSize
q .columnC = q .components [2 ].columns [q .table .id ]
q .columnPtrC = q .columnC .pointer
q .itemSizeC = q .columnC .itemSize
q .columnD = q .components [3 ].columns [q .table .id ]
q .columnPtrD = q .columnD .pointer
q .itemSizeD = q .columnD .itemSize
q .columnE = q .components [4 ].columns [q .table .id ]
q .columnPtrE = q .columnE .pointer
q .itemSizeE = q .columnE .itemSize
q .columnF = q .components [5 ].columns [q .table .id ]
q .columnPtrF = q .columnF .pointer
q .itemSizeF = q .columnF .itemSize
q .columnG = q .components [6 ].columns [q .table .id ]
q .columnPtrG = q .columnG .pointer
q .itemSizeG = q .columnG .itemSize
q .cursor .index = 0
q .cursor .maxIndex = int64 (q .table .len - 1 )
}
type Query8 [A any , B any , C any , D any , E any , F any , G any , H any ] struct {
world *World
filter *filter
table *table
cache *cacheEntry
columnA *column
columnPtrA unsafe .Pointer
itemSizeA uintptr
columnB *column
columnPtrB unsafe .Pointer
itemSizeB uintptr
columnC *column
columnPtrC unsafe .Pointer
itemSizeC uintptr
columnD *column
columnPtrD unsafe .Pointer
itemSizeD uintptr
columnE *column
columnPtrE unsafe .Pointer
itemSizeE uintptr
columnF *column
columnPtrF unsafe .Pointer
itemSizeF uintptr
columnG *column
columnPtrG unsafe .Pointer
itemSizeG uintptr
columnH *column
columnPtrH unsafe .Pointer
itemSizeH uintptr
relations []relationID
tables []tableID
components []*componentStorage
cursor cursor
lock uint8
rareComp uint8
}
func (q *Query8 [A , B , C , D , E , F , G , H ]) GetRelation (index int ) Entity {
return q .components [index ].columns [q .table .id ].target
}
func (q *Query8 [A , B , C , D , E , F , G , H ]) Count () int {
if q .cache == nil {
return countQuery (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ])
}
return countQueryCache (&q .world .storage , q .cache , q .relations )
}
func (q *Query8 [A , B , C , D , E , F , G , H ]) EntityAt (index int ) Entity {
if q .cache == nil {
return entityAt (&q .world .storage , q .filter , q .relations , q .world .storage .componentIndex [q .rareComp ], uint32 (index ))
}
return entityAtCache (&q .world .storage , q .cache , q .relations , uint32 (index ))
}
func (q *Query8 [A , B , C , D , E , F , G , H ]) Close () {
if q .cursor .table < -1 {
return
}
q .cursor .archetype = -2
q .cursor .table = -2
q .tables = nil
q .table = nil
q .cache = nil
q .columnA = nil
q .columnPtrA = unsafe .Pointer (nilDummy )
q .itemSizeA = 0
q .columnB = nil
q .columnPtrB = unsafe .Pointer (nilDummy )
q .itemSizeB = 0
q .columnC = nil
q .columnPtrC = unsafe .Pointer (nilDummy )
q .itemSizeC = 0
q .columnD = nil
q .columnPtrD = unsafe .Pointer (nilDummy )
q .itemSizeD = 0
q .columnE = nil
q .columnPtrE = unsafe .Pointer (nilDummy )
q .itemSizeE = 0
q .columnF = nil
q .columnPtrF = unsafe .Pointer (nilDummy )
q .itemSizeF = 0
q .columnG = nil
q .columnPtrG = unsafe .Pointer (nilDummy )
q .itemSizeG = 0
q .columnH = nil
q .columnPtrH = unsafe .Pointer (nilDummy )
q .itemSizeH = 0
q .world .unlockSafe (q .lock )
}
func (q *Query8 [A , B , C , D , E , F , G , H ]) nextTableOrArchetype () bool {
if q .cache != nil {
return q .nextTable (q .cache .tables .tables )
}
if q .cursor .archetype >= 0 && q .nextTable (q .tables ) {
return true
}
return q .nextArchetype ()
}
func (q *Query8 [A , B , C , D , E , F , G , H ]) nextArchetype () bool {
q .tables = nil
archetypes := q .world .storage .componentIndex [q .rareComp ]
maxArchIndex := int32 (len (archetypes ) - 1 )
for q .cursor .archetype < maxArchIndex {
q .cursor .archetype ++
archetype := &q .world .storage .archetypes [archetypes [q .cursor .archetype ]]
if !q .filter .matches (&archetype .mask ) {
continue
}
if !archetype .HasRelations () {
table := &q .world .storage .tables [archetype .tables .tables [0 ]]
if table .len > 0 {
q .setTable (0 , table )
return true
}
continue
}
q .tables = archetype .GetTables (q .relations )
q .cursor .table = -1
if q .nextTable (q .tables ) {
return true
}
}
q .Close ()
return false
}
func (q *Query8 [A , B , C , D , E , F , G , H ]) nextTable (tables []tableID ) bool {
maxTableIndex := int32 (len (tables ) - 1 )
for q .cursor .table < maxTableIndex {
q .cursor .table ++
table := &q .world .storage .tables [tables [q .cursor .table ]]
if table .len == 0 || !table .Matches (q .relations ) {
continue
}
q .setTable (q .cursor .table , table )
return true
}
if q .cache != nil {
q .Close ()
}
return false
}
func (q *Query8 [A , B , C , D , E , F , G , H ]) setTable (index int32 , table *table ) {
q .cursor .table = index
q .table = table
q .columnA = q .components [0 ].columns [q .table .id ]
q .columnPtrA = q .columnA .pointer
q .itemSizeA = q .columnA .itemSize
q .columnB = q .components [1 ].columns [q .table .id ]
q .columnPtrB = q .columnB .pointer
q .itemSizeB = q .columnB .itemSize
q .columnC = q .components [2 ].columns [q .table .id ]
q .columnPtrC = q .columnC .pointer
q .itemSizeC = q .columnC .itemSize
q .columnD = q .components [3 ].columns [q .table .id ]
q .columnPtrD = q .columnD .pointer
q .itemSizeD = q .columnD .itemSize
q .columnE = q .components [4 ].columns [q .table .id ]
q .columnPtrE = q .columnE .pointer
q .itemSizeE = q .columnE .itemSize
q .columnF = q .components [5 ].columns [q .table .id ]
q .columnPtrF = q .columnF .pointer
q .itemSizeF = q .columnF .itemSize
q .columnG = q .components [6 ].columns [q .table .id ]
q .columnPtrG = q .columnG .pointer
q .itemSizeG = q .columnG .itemSize
q .columnH = q .components [7 ].columns [q .table .id ]
q .columnPtrH = q .columnH .pointer
q .itemSizeH = q .columnH .itemSize
q .cursor .index = 0
q .cursor .maxIndex = int64 (q .table .len - 1 )
}
The pages are generated with Golds v0.8.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .