mirror of
https://github.com/bloeys/nmage.git
synced 2025-12-29 13:28:20 +00:00
Change Entity->BaseEntity + Add Entity interface
This commit is contained in:
@ -13,14 +13,27 @@ const (
|
||||
IndexBitMask = 0x00_00_FFFF_FFFF_FFFF
|
||||
)
|
||||
|
||||
type Entity interface {
|
||||
baseEntity()
|
||||
GetHandle() EntityHandle
|
||||
}
|
||||
|
||||
type EntityHandle uint64
|
||||
|
||||
type Entity struct {
|
||||
var _ Entity = &BaseEntity{}
|
||||
|
||||
type BaseEntity struct {
|
||||
// Byte 1: Generation; Byte 2: Flags; Bytes 3-8: Index
|
||||
ID EntityHandle
|
||||
}
|
||||
|
||||
func (e *Entity) HasFlag(ef EntityFlag) bool {
|
||||
func (be BaseEntity) baseEntity() {}
|
||||
|
||||
func (be BaseEntity) GetHandle() EntityHandle {
|
||||
return be.ID
|
||||
}
|
||||
|
||||
func (e *BaseEntity) HasFlag(ef EntityFlag) bool {
|
||||
return GetFlags(e.ID)&ef > 0
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user