Documentation
¶
Index ¶
- Variables
- type ComponentType
- type Entity
- type Entry
- func (e *Entry) AddComponent(ctype *component.ComponentType, components ...unsafe.Pointer)
- func (e *Entry) Archetype() *storage.Archetype
- func (e *Entry) Component(ctype *component.ComponentType) unsafe.Pointer
- func (e *Entry) Entity() Entity
- func (e *Entry) Id() entity.EntityId
- func (e *Entry) RemoveComponent(ctype *component.ComponentType)
- func (e *Entry) SetComponent(ctype *component.ComponentType, component unsafe.Pointer)
- type StorageAccessor
- type World
- type WorldId
Constants ¶
This section is empty.
Variables ¶
var NewComponentType = component.NewComponentType
NewComponentType creates a new component type. The function is used to create a new component of the type. It receives a function that returns a pointer to a new component.
var Null = entity.Null
Null represents a invalid entity which is zero.
Functions ¶
This section is empty.
Types ¶
type ComponentType ¶
type ComponentType = component.ComponentType
ComponentType represents a component type. It is used to add components to entities, and to filter entities based on their components. It contains a function that returns a pointer to a new component.
func NewTag ¶
func NewTag() *ComponentType
NewTag is an utility to create a tag component. Which is just an component that contains no data.
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry is a struct that contains an entity and a location in an archetype.
func (*Entry) AddComponent ¶
func (e *Entry) AddComponent(ctype *component.ComponentType, components ...unsafe.Pointer)
AddComponent adds the component to the entity.
func (*Entry) Component ¶
func (e *Entry) Component(ctype *component.ComponentType) unsafe.Pointer
Component returns the component.
func (*Entry) RemoveComponent ¶
func (e *Entry) RemoveComponent(ctype *component.ComponentType)
RemoveComponent removes the component from the entity.
func (*Entry) SetComponent ¶
func (e *Entry) SetComponent(ctype *component.ComponentType, component unsafe.Pointer)
SetComponent sets the component.
type StorageAccessor ¶
type StorageAccessor struct {
// Index is the search index for the world.
Index *storage.SearchIndex
// Components is the component storage for the world.
Components *storage.Components
// Archetypes is the archetype storage for the world.
Archetypes []*storage.Archetype
}
StorageAccessor is an accessor for the world's storage.
type World ¶
type World interface {
// Id returns the unique identifier for the world.
Id() WorldId
// Create creates a new entity with the specified components.
Create(components ...*component.ComponentType) Entity
// CreateMany creates a new entity with the specified components.
CreateMany(n int, components ...*component.ComponentType) []Entity
// Entry returns an entry for the specified entity.
Entry(entity Entity) *Entry
// Remove removes the specified entity.
Remove(entity Entity)
// Valid returns true if the specified entity is valid.
Valid(e Entity) bool
// Len returns the number of entities in the world.
Len() int
// StorageAccessor returns an accessor for the world's storage.
// It is used to access components and archetypes by queries.
StorageAccessor() StorageAccessor
}
World is a collection of entities and components.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
bunnymark
command
|
|
|
bunnymark_ecs
module
|
|
|
platformer
module
|
|
|
internal
|
|
Donburi
