store

package
v1.0.3-beta Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IManager

type IManager interface {
	TickStorage
	Reader
	Writer
	ToReadOnly() Reader
}

IManager represents all the methods required to track Component, Entity, and Archetype information which powers the ECS storage layer.

type Reader

type Reader interface {
	// One Component One Entity
	GetComponentForEntity(cType component.ComponentMetadata, id entity.ID) (any, error)
	GetComponentForEntityInRawJSON(cType component.ComponentMetadata, id entity.ID) (json.RawMessage, error)

	// Many Components One Entity
	GetComponentTypesForEntity(id entity.ID) ([]component.ComponentMetadata, error)

	// One Archetype Many Components
	GetComponentTypesForArchID(archID archetype.ID) []component.ComponentMetadata
	GetArchIDForComponents(components []component.ComponentMetadata) (archetype.ID, error)

	// One Archetype Many Entities
	GetEntitiesForArchID(archID archetype.ID) ([]entity.ID, error)

	// Misc
	SearchFrom(filter filter.ComponentFilter, start int) *storage.ArchetypeIterator
	ArchetypeCount() int
}

type TickStorage

type TickStorage interface {
	GetTickNumbers() (start, end uint64, err error)
	StartNextTick(txs []message.Message, queues *txpool.TxQueue) error
	FinalizeTick() error
	Recover(txs []message.Message) (*txpool.TxQueue, error)
}

type Writer

type Writer interface {
	// One Entity
	RemoveEntity(id entity.ID) error

	// Many Components
	CreateEntity(comps ...component.ComponentMetadata) (entity.ID, error)
	CreateManyEntities(num int, comps ...component.ComponentMetadata) ([]entity.ID, error)

	// One Component One Entity
	SetComponentForEntity(cType component.ComponentMetadata, id entity.ID, value any) error
	AddComponentToEntity(cType component.ComponentMetadata, id entity.ID) error
	RemoveComponentFromEntity(cType component.ComponentMetadata, id entity.ID) error

	// Misc
	InjectLogger(logger *ecslog.Logger)
	Close() error
	RegisterComponents([]component.ComponentMetadata) error
}

Jump to

Keyboard shortcuts

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