Documentation
¶
Index ¶
- Constants
- Variables
- func AddComp[T Comp](e *Entity, c T)
- func DestroyComp[T Comp](e *Entity)
- func GetComp[T Comp](e *Entity) (out T)
- func GetGeneration(id EntityHandle) byte
- func GetIndex(id EntityHandle) uint64
- func HasComp[T Comp](e *Entity) bool
- type BaseComp
- type Comp
- type Entity
- type EntityFlag
- type EntityHandle
- type Registry
Constants ¶
View Source
const ( GenerationShiftBits = 64 - 8 FlagsShiftBits = 64 - 16 IndexBitMask = 0x00_00_FFFF_FFFF_FFFF )
Variables ¶
View Source
var ( // The number of slots required to be in the free list before the free list // is used for creating new entries FreeListUsageThreshold uint32 = 20 )
Functions ¶
func DestroyComp ¶ added in v0.14.0
DestroyComp calls Destroy on the component and then removes it from the entities component list
func GetGeneration ¶
func GetGeneration(id EntityHandle) byte
func GetIndex ¶
func GetIndex(id EntityHandle) uint64
Types ¶
type Entity ¶
type Entity struct { // Byte 1: Generation; Byte 2: Flags; Bytes 3-8: Index ID EntityHandle Comps []Comp }
func (*Entity) HasFlag ¶
func (e *Entity) HasFlag(ef EntityFlag) bool
func (*Entity) UpdateAllComps ¶ added in v0.14.0
func (e *Entity) UpdateAllComps()
type EntityFlag ¶
type EntityFlag byte
const ( EntityFlag_None EntityFlag = 0 EntityFlag_Alive EntityFlag = 1 << (iota - 1) )
func GetFlags ¶
func GetFlags(id EntityHandle) EntityFlag
type EntityHandle ¶ added in v0.14.0
type EntityHandle uint64
func NewEntityId ¶
func NewEntityId(generation byte, flags EntityFlag, index uint64) EntityHandle
type Registry ¶
type Registry struct { EntityCount uint64 Entities []Entity FreeList *freeListitem FreeListSize uint32 }
func NewRegistry ¶
func (*Registry) FreeEntity ¶
func (r *Registry) FreeEntity(id EntityHandle)
FreeEntity calls Destroy on all the entities components, resets the component list, resets the entity flags, then ads this entity to the free list
func (*Registry) GetEntity ¶
func (r *Registry) GetEntity(id EntityHandle) *Entity
Click to show internal directories.
Click to hide internal directories.