Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultRepository = NewInMemoryRepository()
DefaultRepository is initialized by NewInMemoryRepository().
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component interface {
Mask() uint64
}
Component contains only the data (no behavior). The Name() method must be implemented, because the inMemoryRepository uses it to filter the entities by component name.
type ComponentWithName ¶
ComponentWithName is used by FilterByNames to enable more than 64 Components (if needed).
type Entity ¶
type Entity struct {
Components []Component `json:"components"`
Id string `json:"id"`
Masked uint64 `json:"masked"`
}
Entity is simply a composition of one or more Components with an Id.
func NewEntity ¶
func NewEntity() *Entity
NewEntity creates a new entity and pre-calculates the component maskSlice.
func (*Entity) WithComponents ¶ added in v0.8.0
type Repository ¶
type Repository interface {
Add(entities ...*Entity)
Entities() (entities []*Entity)
FilterByMask(mask uint64) (entities []*Entity)
FilterByNames(names ...string) (entities []*Entity)
Get(id string) (entity *Entity)
Remove(entity *Entity)
}
Repository handles the access to each entity.
func NewInMemoryRepository ¶
func NewInMemoryRepository() Repository
NewInMemoryRepository creates a new inMemoryRepository and returns its address.
Click to show internal directories.
Click to hide internal directories.