INNER CODE UNIT · Go

NewComponentType

yohamta0/donburi-ecs · component.go:20

func NewComponentType[T any](opts ...interface{}) *ComponentType[T] {
	var t T
	if len(opts) == 0 {
		return newComponentType(t, nil)
	}
	return newComponentType(t, opts[0])
}

// CompnentType represents a type of component. It is used to identify
// a component when getting or setting components of an entity.
type ComponentType[T any] struct {
	id         component.ComponentTypeId
	typ        reflect.Type
	name       string
	defaultVal interface{}
	query      *Query
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…