entity

package
v0.13.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GenerationShiftBits = 64 - 8
	FlagsShiftBits      = 64 - 16
	IndexBitMask        = 0x00_00_FFFF_FFFF_FFFF
)

Variables

This section is empty.

Functions

func AddComp

func AddComp(e *Entity, c Comp)

func GetAllCompOfType

func GetAllCompOfType[T Comp](e *Entity) (out []T)

func GetComp

func GetComp[T Comp](e *Entity) (out T)

func GetFlags

func GetFlags(id uint64) byte

func GetGeneration

func GetGeneration(id uint64) byte

func GetIndex

func GetIndex(id uint64) uint64

func NewEntityId

func NewEntityId(generation, flags byte, index uint64) uint64

Types

type Comp

type Comp interface {
	Name() string
}

type Entity

type Entity struct {

	// Byte 1: Generation; Byte 2: Flags; Bytes 3-8: Index
	ID    uint64
	Comps []Comp
}

func (*Entity) HasFlag

func (e *Entity) HasFlag(ef EntityFlag) bool

type EntityFlag

type EntityFlag byte
const (
	EntityFlag_Unknown EntityFlag = 0
	EntityFlag_Dead    EntityFlag = 1 << (iota - 1)
	EntityFlag_Alive
)

type Registry

type Registry struct {
	EntityCount uint64
	Entities    []Entity
	FreeList    *freeListitem
}

func NewRegistry

func NewRegistry(size uint32) *Registry

func (*Registry) FreeEntity

func (r *Registry) FreeEntity(id uint64)

func (*Registry) GetEntity

func (r *Registry) GetEntity(id uint64) *Entity

func (*Registry) NewEntity

func (r *Registry) NewEntity() *Entity

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL