ecs

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComponentId

type ComponentId = uint32

ComponentId 组件 ID

type ComponentType

type ComponentType = reflect.Type

ComponentType 组件类型

type Entity

type Entity uint64

func (Entity) String

func (id Entity) String() string

type Lifecycle

type Lifecycle uint8
const (
	OnInit    Lifecycle = iota // 初始化启动阶段
	OnRunning                  // 运行阶段
)

type Query

type Query interface {
	Evaluate(mask *toolkit.DynamicBitSet) bool
	String() string
}

func And

func And(query ...Query) Query

And 当实体组件同时满足所有条件时,条件成立

func Equal

func Equal(componentIds ...ComponentId) Query

Equal 当实体组件完全等于 componentIds 中的所有 ComponentId 时,条件成立

func In

func In(componentIds ...ComponentId) Query

In 当实体组件包含 componentIds 中的所有 ComponentId 时,条件成立

func NotIn

func NotIn(componentIds ...ComponentId) Query

NotIn 当实体组件不包含 componentIds 中的所有 ComponentId 时,条件成立

func Or

func Or(query ...Query) Query

Or 当实体组件满足 l 或 r 两个条件时,条件成立

type Result

type Result struct {
	// contains filtered or unexported fields
}

func (*Result) Count

func (r *Result) Count() int

func (*Result) Each

func (r *Result) Each(handler func(entity Entity) bool)

func (*Result) Entities

func (r *Result) Entities() []Entity

func (*Result) Get

func (r *Result) Get(entity Entity, componentId ComponentId) any

func (*Result) Iterator

func (r *Result) Iterator() ResultIterator

type ResultIterator

type ResultIterator struct {
	// contains filtered or unexported fields
}

func (*ResultIterator) Entity

func (r *ResultIterator) Entity() Entity

func (*ResultIterator) Get

func (r *ResultIterator) Get(componentId ComponentId) any

func (*ResultIterator) Next

func (r *ResultIterator) Next() bool

func (*ResultIterator) Reset

func (r *ResultIterator) Reset()

type Storage

type Storage = storage.Storage[entityId, ComponentId]

type System

type System interface {
	OnLifecycle(world World, lifecycle Lifecycle)

	OnUpdate(world World)
}

type World

type World interface {
	Alive(entity Entity) bool

	Get(entity Entity, componentId ComponentId) any

	Query(query Query) *Result

	QueryF(query Query, handler func(result *Result))

	RegComponent(component any) ComponentId

	Spawn(componentIds ...ComponentId) Entity

	Spawns(count int, componentIds ...ComponentId) []Entity

	Annihilate(entity Entity)

	Annihilates(entities []Entity)

	Update()

	SetSleep(d time.Duration)

	SetTimeScale(scale float64)

	TimeScale() float64

	DeltaTime() time.Duration

	Pause()

	Resume()
}

func NewWorld

func NewWorld(systems ...System) World

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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