package ecs
type UnsafeFilter struct {
filter
world *World
}
func NewUnsafeFilter (world *World , ids ...ID ) UnsafeFilter {
return UnsafeFilter {
world : world ,
filter : newFilter (ids ...),
}
}
func (f UnsafeFilter ) Without (ids ...ID ) UnsafeFilter {
if len (ids ) == 0 {
return f
}
f .filter = f .filter .Without (ids ...)
return f
}
func (f UnsafeFilter ) Exclusive () UnsafeFilter {
f .filter = f .filter .Exclusive ()
return f
}
func (f UnsafeFilter ) Query (relations ...Relation ) UnsafeQuery {
rel := relationSlice (relations ).ToRelationIDsForUnsafe (f .world , nil )
return UnsafeQuery {
world : f .world ,
filter : f .filter ,
relations : rel ,
lock : f .world .lockSafe (),
cursor : cursor {
archetype : -1 ,
table : -1 ,
index : 0 ,
maxIndex : -1 ,
},
}
}
type filter struct {
mask bitMask
without bitMask
cache cacheID
hasWithout bool
}
func newFilter(ids ...ID ) filter {
return filter {
mask : newMask (ids ...),
cache : maxCacheID ,
}
}
func (f *filter ) matches (mask *bitMask ) bool {
return mask .Contains (&f .mask ) && (!f .hasWithout || !mask .ContainsAny (&f .without ))
}
func (f filter ) Without (ids ...ID ) filter {
f .without = newMask (ids ...)
f .hasWithout = true
return f
}
func (f filter ) Exclusive () filter {
f .without = f .mask .Not ()
f .hasWithout = true
return f
}
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 .