Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultManager = NewInMemoryRepository()
DefaultManager ...
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component interface {
Mask() uint64
}
Component contains only the data (no behaviour at all). The Name() method must be implemented, because the inMemoryRepository uses it to filter the entities by component names.
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.
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.