Documentation ¶
Index ¶
- func EntityWithComponents(components ...Component) func(e *BaseEntity)
- type BaseEntity
- type Component
- type ComponentID
- type Entity
- type Priority
- type System
- type World
- func (w *World) AddEntities(entity ...Entity)
- func (w *World) AddSystem(systems ...System) error
- func (w *World) Init() error
- func (w *World) RemoveEntity(entity Entity) bool
- func (w *World) Update(dt float64) error
- func (w *World) WithComponents(ids []ComponentID, f func(components []Component, all bool))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EntityWithComponents ¶
func EntityWithComponents(components ...Component) func(e *BaseEntity)
EntityWithComponents is option to initialize entity with components.
Types ¶
type BaseEntity ¶
type BaseEntity struct {
// contains filtered or unexported fields
}
BaseEntity is basically implemented entity.
func NewBaseEntity ¶
func NewBaseEntity(options ...func(e *BaseEntity)) *BaseEntity
NewBaseEntity returns generated base entity with given options.
func (*BaseEntity) AddComponents ¶
func (e *BaseEntity) AddComponents(c ...Component)
func (*BaseEntity) Clone ¶
func (e *BaseEntity) Clone() Entity
func (*BaseEntity) Components ¶
func (e *BaseEntity) Components(ids []ComponentID) (components []Component, isAll bool)
func (*BaseEntity) RemoveComponent ¶
func (e *BaseEntity) RemoveComponent(component Component) (removed bool)
func (*BaseEntity) String ¶
func (e *BaseEntity) String() string
type Component ¶
type Component interface { ID() ComponentID Clone() Component }
type ComponentID ¶
type ComponentID uint64
type Entity ¶
type Entity interface { // AddComponents adds components to entity. AddComponents(c ...Component) // Components returns components that matching with argument. // if all components has found, isAll will be true. Components(ids []ComponentID) (components []Component, isAll bool) // RemoveComponent removes component from entity. RemoveComponent(component Component) (removed bool) // Clone clones entity with all component, values. Clone() Entity String() string }
Entity is identified object that can have components.
type World ¶
type World struct {
// contains filtered or unexported fields
}
World is game scene that contains entities and systems.
func (*World) AddEntities ¶
AddEntities adds entities to world.
func (*World) RemoveEntity ¶
RemoveEntity removes entity from world.
func (*World) WithComponents ¶
func (w *World) WithComponents(ids []ComponentID, f func(components []Component, all bool))
WithComponents finds all components that matching with given ids, and callback with its array.
Click to show internal directories.
Click to hide internal directories.