ecs

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QueryEntitiesByComponentId

func QueryEntitiesByComponentId[T any](world *World, id ComponentId) []*T

func QueryEntity

func QueryEntity[C any](world *World, entity Entity) *C

Types

type Component

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

Component 组件是一个数据结构,它包含了一些数据

type ComponentId

type ComponentId = int

type Entity

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

Entity 仅包含一个实体的唯一标识

func (Entity) GetArchetypeIndex

func (e Entity) GetArchetypeIndex() int

func (Entity) GetId

func (e Entity) GetId() EntityId

type EntityId

type EntityId = int

type World

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

func NewWorld

func NewWorld() World

NewWorld 创建一个新的世界

func (*World) ComponentId

func (w *World) ComponentId(t reflect.Type) ComponentId

ComponentId 返回一个组件的 Id,如果组件未注册,则注册它

func (*World) CreateEntity

func (w *World) CreateEntity(componentId ComponentId, componentIds ...ComponentId) Entity

CreateEntity 创建一个新的实体

Jump to

Keyboard shortcuts

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