Source File
mask64.go
Belonging Package
github.com/mlange-42/ark/ecs
package ecsimport ()// maskTotalBits is the size of a [bitMask] in bits.// It is the maximum number of component types that may exist in any [World].const mask64TotalBits = 64// bitMask is a 64 bit bit-mask.type bitMask64 struct {bits uint64 // 64 bits of the mask}// newMask creates a new Mask from a list of IDs.// Matches all entities that have the respective components, and potentially further components.func newMask64( ...ID) bitMask64 {var bitMask64for , := range {.Set(.id)}return}// Get reports whether the bit at the given index [ID] is set.func ( *bitMask64) ( uint8) bool {:= uint64(1 << )return .bits& ==}// Set sets the state of the bit at the given index.func ( *bitMask64) ( uint8) {.bits |= (1 << )}// Clear sets the state of the bit at the given index.func ( *bitMask64) ( uint8) {.bits &= ^(1 << )}// Not returns the inversion of this mask.func ( *bitMask64) () bitMask64 {return bitMask64{bits: ^.bits,}}// OrI calculates the OR of this mask and other in-place.func ( *bitMask64) ( *bitMask64) {.bits |= .bits}// IsZero returns whether no bits are set in the mask.func ( *bitMask64) () bool {return .bits == 0}// Reset the mask setting all bits to false.func ( *bitMask64) () {.bits = 0}// Contains reports if the other mask is a subset of this mask.func ( *bitMask64) ( *bitMask64) bool {return .bits&.bits == .bits}// ContainsAny reports if any bit of the other mask is in this mask.func ( *bitMask64) ( *bitMask64) bool {return .bits&.bits != 0}// TotalBitsSet returns how many bits are set in this mask.func ( *bitMask64) () int {return bits.OnesCount64(.bits)}// Equals returns whether two masks are equal.func ( *bitMask64) ( *bitMask64) bool {return .bits == .bits}// toTypes converts a mask to a list of component IDs.func ( *bitMask64) ( *registry) []ID {if .bits == 0 {return nil}:= .TotalBitsSet():= make([]ID, ):= .Count():= 0for := range {:= ID{id: uint8()}if .Get(.id) {[] =++}}return}
![]() |
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. |