ecs

package
v0.0.0-...-2c29d88 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddComponents

func AddComponents(r *Registry, eID EntityID, components ...Component) error

func Destroy

func Destroy(r *Registry, eID EntityID) error

func Process

func Process(r *Registry, dt time.Duration)

func RegisterSystems

func RegisterSystems(r *Registry, systems ...System)

func RemoveComponents

func RemoveComponents(r *Registry, eID EntityID, cIDs ...ComponentID) error

func UnregisterSystems

func UnregisterSystems(r *Registry, sIDs ...SystemID)

Types

type Component

type Component interface {
	ID() ComponentID
}

type ComponentID

type ComponentID uint16

type EntityID

type EntityID uint32
const InvalidEntityID EntityID = 0

func NewEntity

func NewEntity(r *Registry, component Component, components ...Component) (EntityID, error)

type OperativeSets

type OperativeSets map[EntityID]map[ComponentID]Component

type Registry

type Registry struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry() *Registry

func NewRegistryWithConfig

func NewRegistryWithConfig(c RegistryConfig) *Registry

func (*Registry) AddComponentsToEntity

func (r *Registry) AddComponentsToEntity(eID EntityID, cs ...Component) error

func (*Registry) GetComponentsFromEntity

func (r *Registry) GetComponentsFromEntity(eID EntityID, cIDs ...ComponentID) (entityComponentMap, error)

func (*Registry) QueryEntities

func (r *Registry) QueryEntities(qm SystemQueryMode, incl, excl []ComponentID) componentEntitySet

func (*Registry) RegisterEntity

func (r *Registry) RegisterEntity(cs ...Component) (EntityID, error)

func (*Registry) RemoveComponentsFromEntity

func (r *Registry) RemoveComponentsFromEntity(eID EntityID, cIDs ...ComponentID) (bool, error)

func (*Registry) UnregisterEntity

func (r *Registry) UnregisterEntity(eID EntityID) error

type RegistryConfig

type RegistryConfig struct {
	InitialEntityCapacity     int
	InitialComponentsCapacity int
	InitialSystemsCapacity    int
}

type System

type System interface {
	ID() SystemID
	QueryMode() SystemQueryMode
	IncludeTypes() []ComponentID
	ExcludeTypes() []ComponentID
	Process(dt time.Duration, operativeSets OperativeSets)
}

type SystemID

type SystemID uint16

type SystemQueryMode

type SystemQueryMode int
const (
	Exclusive SystemQueryMode = iota
	Inclusive
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL