Documentation ¶
Index ¶
- type Component
- type ComponentType
- type Entity
- type EntityAddedEvent
- type EntityRemovedEvent
- type Event
- type EventHandler
- type EventType
- type FindEntitiesWithComponentResult
- type FindEntitiesWithComponentsResult
- type LogicSystem
- type Point
- type Rect
- type RenderSystem
- type World
- func (w *World) AddEntity(e Entity) *World
- func (w *World) AddEventHandler(e EventHandler)
- func (w *World) AddLogicSystem(s LogicSystem)
- func (w *World) AddRenderSystem(s RenderSystem)
- func (w World) FindEntitiesWithComponent(requestedComponent ComponentType) []FindEntitiesWithComponentResult
- func (w World) FindEntitiesWithComponents(requestedComponents ...ComponentType) []FindEntitiesWithComponentsResult
- func (w *World) FireEvent(e Event)
- func (w *World) GetEntities() []Entity
- func (w *World) RemoveEntity(idToRemove int)
- func (w *World) Tick(screen *ebiten.Image) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component interface {
ComponentType() ComponentType
}
Component represents a component in the world, which will be attached to an entity. Component must return a particular ComponentType, which will be used to query the world for components of a particular type (instead of doing something like using reflection).
type ComponentType ¶
type ComponentType int
ComponentType should be created for each component, so it can be used for querying for components in place of reflection.
type Entity ¶
Entity is a game entity.
func NewEntity ¶
NewEntity creates a new entity of a particular name. Names are purely informational and no uniqueness is enforced.
func (*Entity) AddComponent ¶
AddComponent adds a component to an entity.
func (*Entity) GetComponent ¶
func (e *Entity) GetComponent(componentType ComponentType) Component
GetComponent returns the first component of a requested ComponentType belonging to the entity, or nil if no such components were found.
func (*Entity) GetComponents ¶
GetComponents returns all components belonging to the entity.
type EntityAddedEvent ¶
type EntityAddedEvent struct {
Entity Entity
}
func (EntityAddedEvent) EventType ¶
func (EntityAddedEvent) EventType() EventType
type EntityRemovedEvent ¶
type EntityRemovedEvent struct {
Entity Entity
}
func (EntityRemovedEvent) EventType ¶
func (EntityRemovedEvent) EventType() EventType
type Event ¶
type Event interface {
EventType() EventType
}
Event is something emitted by or queried for by a system. Events have types and may extend with additional data that can be used by consuming systems.
type EventHandler ¶
EventHandlers will be called to handle any fired events of the particular type they're interested in.
type EventType ¶
type EventType int
EventType is the type of event -- we need this to avoid generics and reflection, though to be honest reflection might be good enough depending how fast it is.
type FindEntitiesWithComponentsResult ¶
type FindEntitiesWithComponentsResult struct { Entity Entity RequestedComponents map[ComponentType]Component }
type LogicSystem ¶
LogicSystem is a system which applies logic. These are run before render systems.
type Rect ¶
type Rect struct {
// contains filtered or unexported fields
}
func (Rect) Intersects ¶
check if a rect overlaps another rect
type RenderSystem ¶
RenderSystem is a system which performs some kind of screen rendering. These are run last.
type World ¶
func (*World) AddEventHandler ¶
func (w *World) AddEventHandler(e EventHandler)
func (*World) AddLogicSystem ¶
func (w *World) AddLogicSystem(s LogicSystem)
func (*World) AddRenderSystem ¶
func (w *World) AddRenderSystem(s RenderSystem)
func (World) FindEntitiesWithComponent ¶
func (w World) FindEntitiesWithComponent(requestedComponent ComponentType) []FindEntitiesWithComponentResult
FindEntitiesWithComponent finds ALL entities that have the requested component attached.
func (World) FindEntitiesWithComponents ¶
func (w World) FindEntitiesWithComponents(requestedComponents ...ComponentType) []FindEntitiesWithComponentsResult
FindEntitiesWithComponents finds ALL entities that have ALL the requested components attached.
func (*World) GetEntities ¶
GetEntities returns all entities in the world.
func (*World) RemoveEntity ¶
RemoveEntity removes an entity from the world.