Documentation
¶
Index ¶
- type Archetype
- func (archetype *Archetype) Entities() []entity.Entity
- func (archetype *Archetype) Layout() *Layout
- func (archetype *Archetype) LayoutMatches(components []*component.ComponentType) bool
- func (archetype *Archetype) PushEntity(entity entity.Entity)
- func (archetype *Archetype) SwapRemove(entity_index int) entity.Entity
- type ArchetypeIndex
- type ArchetypeIterator
- type ComponentIndex
- type Components
- func (cs *Components) Move(src ArchetypeIndex, dst ArchetypeIndex)
- func (cs *Components) PushComponents(components []*component.ComponentType, archetypeIndex ArchetypeIndex) ComponentIndex
- func (cs *Components) Remove(a *Archetype, ci ComponentIndex)
- func (cs *Components) Storage(c *component.ComponentType) *Storage
- type EntityIterator
- type Index
- type Layout
- type Location
- type LocationMap
- func (lm *LocationMap) Archetype(id entity.EntityId) ArchetypeIndex
- func (lm *LocationMap) Component(id entity.EntityId) ComponentIndex
- func (lm *LocationMap) Contains(id entity.EntityId) bool
- func (lm *LocationMap) Insert(id entity.EntityId, archetype ArchetypeIndex, component ComponentIndex)
- func (lm *LocationMap) Location(id entity.EntityId) *Location
- func (lm *LocationMap) Remove(id entity.EntityId)
- func (lm *LocationMap) Set(id entity.EntityId, loc *Location)
- type Storage
- func (cs *Storage) Component(archetypeIndex ArchetypeIndex, componentIndex ComponentIndex) unsafe.Pointer
- func (cs *Storage) Contains(archetypeIndex ArchetypeIndex, componentIndex ComponentIndex) bool
- func (cs *Storage) MoveComponent(source ArchetypeIndex, index ComponentIndex, dst ArchetypeIndex)
- func (cs *Storage) PushComponent(component *component.ComponentType, archetypeIndex ArchetypeIndex)
- func (cs *Storage) SetComponent(archetypeIndex ArchetypeIndex, componentIndex ComponentIndex, ...)
- func (cs *Storage) SwapRemove(archetypeIndex ArchetypeIndex, componentIndex ComponentIndex) unsafe.Pointer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Archetype ¶
type Archetype struct {
// contains filtered or unexported fields
}
Archetype is a collection of entities for a specific layout of components. This structure allows to quickly find entities based on their components.
func NewArchetype ¶
func NewArchetype(index ArchetypeIndex, layout *Layout) *Archetype
NewArchetype creates a new archetype.
func (*Archetype) Layout ¶
Layout is a collection of archetypes for a specific layout of components.
func (*Archetype) LayoutMatches ¶ added in v1.1.2
func (archetype *Archetype) LayoutMatches(components []*component.ComponentType) bool
LayoutMatches returns true if the given layout matches this archetype.
func (*Archetype) PushEntity ¶
PushEntity adds an entity to the archetype.
type ArchetypeIndex ¶
type ArchetypeIndex int
type ArchetypeIterator ¶ added in v1.1.2
type ArchetypeIterator struct {
// contains filtered or unexported fields
}
func (*ArchetypeIterator) HasNext ¶ added in v1.1.2
func (it *ArchetypeIterator) HasNext() bool
func (*ArchetypeIterator) Next ¶ added in v1.1.2
func (it *ArchetypeIterator) Next() ArchetypeIndex
type ComponentIndex ¶
type ComponentIndex int
ComponentIndex represents the index of component in a archetype.
type Components ¶
type Components struct {
// contains filtered or unexported fields
}
Components is a structure that stores data of components.
func NewComponents ¶
func NewComponents() *Components
NewComponents creates a new empty structure that stores data of components.
func (*Components) Move ¶ added in v1.2.8
func (cs *Components) Move(src ArchetypeIndex, dst ArchetypeIndex)
MoveComponent moves the pointer to data of the component in the archetype.
func (*Components) PushComponents ¶
func (cs *Components) PushComponents(components []*component.ComponentType, archetypeIndex ArchetypeIndex) ComponentIndex
PUshComponent stores the new data of the component in the archetype.
func (*Components) Remove ¶ added in v0.0.7
func (cs *Components) Remove(a *Archetype, ci ComponentIndex)
Remove removes the component from the storage.
func (*Components) Storage ¶
func (cs *Components) Storage(c *component.ComponentType) *Storage
Storage returns the pointer to data of the component in the archetype.
type EntityIterator ¶ added in v1.1.2
type EntityIterator struct {
// contains filtered or unexported fields
}
EntityIterator is an iterator for entity lists in archetypes.
func NewEntityIterator ¶ added in v1.1.2
func NewEntityIterator(current int, archetypes []*Archetype, indices []ArchetypeIndex) EntityIterator
EntityIterator is an iterator for entities.
func (*EntityIterator) HasNext ¶ added in v1.1.2
func (it *EntityIterator) HasNext() bool
HasNext returns true if there are more entity list to iterate over.
func (*EntityIterator) Next ¶ added in v1.1.2
func (it *EntityIterator) Next() []entity.Entity
Next returns the next entity list.
type Index ¶ added in v1.1.2
type Index struct {
// contains filtered or unexported fields
}
Index is a structure that indexes archetypes by their component types.
func (*Index) Search ¶ added in v1.1.2
func (idx *Index) Search(filter filter.LayoutFilter) *ArchetypeIterator
Search searches for archetypes that match the given filter.
func (*Index) SearchFrom ¶ added in v1.1.2
func (idx *Index) SearchFrom(f filter.LayoutFilter, start int) *ArchetypeIterator
SearchFrom searches for archetypes that match the given filter from the given index.
type Layout ¶ added in v1.1.2
type Layout struct {
// contains filtered or unexported fields
}
Layout represents a layout of components.
func NewLayout ¶ added in v1.1.2
func NewLayout(components []*component.ComponentType) *Layout
NewLayout creates a new entity layout.
func (*Layout) AddComponent ¶ added in v1.1.2
func (l *Layout) AddComponent(componentType *component.ComponentType)
AddComponent registers a component type to the layout.
func (*Layout) Components ¶ added in v1.1.2
func (l *Layout) Components() []*component.ComponentType
Components returns the components of the layout.
func (*Layout) HasComponent ¶ added in v1.1.2
func (l *Layout) HasComponent(componentType *component.ComponentType) bool
HasComponent returns true if the layout has the given component type.
type Location ¶ added in v1.1.2
type Location struct { Archetype ArchetypeIndex Component ComponentIndex Valid bool }
Location is a location of an entity in the storage.
func NewLocation ¶ added in v1.1.2
func NewLocation(archetype ArchetypeIndex, component ComponentIndex) *Location
NewLocation creates a new EntityLocation.
type LocationMap ¶
LocationMap is a storage of entity locations.
func (*LocationMap) Archetype ¶
func (lm *LocationMap) Archetype(id entity.EntityId) ArchetypeIndex
Archetype returns the archetype of the given entity id.
func (*LocationMap) Component ¶
func (lm *LocationMap) Component(id entity.EntityId) ComponentIndex
Component returns the component of the given entity id.
func (*LocationMap) Contains ¶
func (lm *LocationMap) Contains(id entity.EntityId) bool
Contains returns true if the storage contains the given entity id.
func (*LocationMap) Insert ¶
func (lm *LocationMap) Insert(id entity.EntityId, archetype ArchetypeIndex, component ComponentIndex)
Insert inserts the given entity id and archetype index to the storage.
func (*LocationMap) Location ¶
func (lm *LocationMap) Location(id entity.EntityId) *Location
Location returns the location of the given entity id.
func (*LocationMap) Remove ¶
func (lm *LocationMap) Remove(id entity.EntityId)
Remove removes the given entity id from the storage.
type Storage ¶ added in v1.1.2
type Storage struct {
// contains filtered or unexported fields
}
Storage is a structure that stores the pointer to data of each component. It stores the pointers in the two dimensional slice. First dimension is the archetype index. Second dimension is the component index. The component index is used to access the component data in the archetype.
func NewStorage ¶ added in v1.1.2
func NewStorage() *Storage
NewStorage creates a new empty structure that stores the pointer to data of each component.
func (*Storage) Component ¶ added in v1.1.2
func (cs *Storage) Component(archetypeIndex ArchetypeIndex, componentIndex ComponentIndex) unsafe.Pointer
Component returns the pointer to data of the component in the archetype.
func (*Storage) Contains ¶ added in v1.1.2
func (cs *Storage) Contains(archetypeIndex ArchetypeIndex, componentIndex ComponentIndex) bool
Contains returns true if the storage contains the component.
func (*Storage) MoveComponent ¶ added in v1.1.2
func (cs *Storage) MoveComponent(source ArchetypeIndex, index ComponentIndex, dst ArchetypeIndex)
MoveComponent moves the pointer to data of the component in the archetype.
func (*Storage) PushComponent ¶ added in v1.1.2
func (cs *Storage) PushComponent(component *component.ComponentType, archetypeIndex ArchetypeIndex)
PushComponent stores the new data of the component in the archetype.
func (*Storage) SetComponent ¶ added in v1.1.2
func (cs *Storage) SetComponent(archetypeIndex ArchetypeIndex, componentIndex ComponentIndex, component unsafe.Pointer)
SetComponent sets the pointer to data of the component in the archetype.
func (*Storage) SwapRemove ¶ added in v1.1.2
func (cs *Storage) SwapRemove(archetypeIndex ArchetypeIndex, componentIndex ComponentIndex) unsafe.Pointer
SwapRemove removes the pointer to data of the component in the archetype.