Implement UpdateAllComps

This commit is contained in:
bloeys
2022-12-06 06:19:38 +04:00
parent 855cbfaba3
commit a16654107b
2 changed files with 10 additions and 7 deletions

View File

@ -22,6 +22,16 @@ type Entity struct {
Comps []Comp
}
func (e *Entity) HasFlag(ef EntityFlag) bool {
return GetFlags(e.ID)&ef > 0
}
func (e *Entity) UpdateAllComps() {
for i := 0; i < len(e.Comps); i++ {
e.Comps[i].Update()
}
}
func GetGeneration(id EntityHandle) byte {
return byte(id >> GenerationShiftBits)
}
@ -34,10 +44,6 @@ func GetIndex(id EntityHandle) uint64 {
return uint64(id & IndexBitMask)
}
func (e *Entity) HasFlag(ef EntityFlag) bool {
return GetFlags(e.ID)&ef > 0
}
func NewEntityId(generation byte, flags EntityFlag, index uint64) EntityHandle {
return EntityHandle(index | (uint64(generation) << GenerationShiftBits) | (uint64(flags) << FlagsShiftBits))
}