Documentation ¶
Index ¶
- func AddComp(w *World, e Entity, c Component)
- func DelComp(w *World, e Entity, c Component)
- func DelEntity(w *World, e Entity)
- func GetComp[C any](w *World, e Entity, c Component) (data *C)
- func HasComp(w *World, e Entity, c Component) bool
- func SetComp[C any](w *World, e Entity, c Component, data C)
- func Type(w *World, e Entity, nameComp Component) string
- type Archetype
- type ArchetypeEdge
- type CachedQuery
- type Component
- type ComponentMeta
- type Entity
- type EntityRecord
- type Filter
- type IDManager
- type Storage
- type Table
- type Types
- type World
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DelComp ¶
DelComp removes the Component of an Entity. If the Entity doesn't have the Component, nothing will happen.
func GetComp ¶
GetComp gets the data of a Component of an Entity. If the Entity doesn't have the Component, nil will be returned.
Types ¶
type ArchetypeEdge ¶
type ArchetypeEdge struct {
// contains filtered or unexported fields
}
type CachedQuery ¶
type CachedQuery struct {
// contains filtered or unexported fields
}
CachedQuery is cached filter
func (*CachedQuery) Free ¶
func (q *CachedQuery) Free(w *World)
func (*CachedQuery) Run ¶
func (q *CachedQuery) Run(h func(entities []Entity, data []any))
type Component ¶
type Component struct{ Entity }
A Component is a type of which instances can be added and removed to entities. Each component can be added only once to an entity.
--flecs.dev
func NewComponent ¶
NewComponent creates a new Component in the World. The data type associated with the Component will be bind when the first data is set.
type ComponentMeta ¶
type Entity ¶
type Entity uint64
An Entity is a unique thing in the world, and is represented by a 64-bit id. Entities can be created and deleted. If an entity is deleted, it is no longer considered "alive".
A world can contain up to 4 billion alive entities. Entity identifiers contain a few bits that make it possible to check whether an entity is alive or not.
--flecs.dev
type EntityRecord ¶
type Types ¶
type Types []ComponentMeta
Types is list of Components. It's sorted and able to be hashed. Allowing us to find the archetype by the hash of its type.
type World ¶
type World struct { IDManager // The default archetype for newly created entities, which contains no Components. Zero *Archetype // All entities in the World, including Components. // Records their archetype's pointer and the index of the Comps belonging to the entity. Entities map[Entity]*EntityRecord // All archetypes in the World. // The key of the map is the hash of the archetype's Types. // And the value is the archetype's pointer. Archetypes map[uint64]*Archetype // This field stores maps for each component. // Each map contains a list of archetypes that have the component. // And the component's corresponding Storage index in the archetype. // // We can check if an archetype has a component by looking up the map. // // For any Component c and archetype a: // col, ok := Components[c][a] // If ok == true, then archetype a has component c, otherwise it doesn't. // And if col == -1, archetype a has component c but doesn't contain any data, // otherwise the col is the index of the component's Storage in the archetype. Components map[Component]map[*Archetype]int // For high performance, we cache the queries. // But these caches will get outdated when new archetypes are created. // We register all queries created here, and update them when new archetypes are created. Queries Table[*CachedQuery] // contains filtered or unexported fields }
The World is the container for all ECS data. It stores the entities and their Components, does queries and runs systems.
--flecs.dev