INNER CODE UNIT · Go
newComponentType
yohamta0/donburi-ecs · component.go:157
func newComponentType[T any](s T, defaultVal interface{}) *ComponentType[T] {
typ := reflect.TypeOf(s)
componentType := &ComponentType[T]{
id: nextComponentTypeId,
typ: typ,
name: typ.Name(),
defaultVal: defaultVal,
}
componentType.query = NewQuery(filter.Contains(componentType))
if defaultVal != nil {
componentType.validateDefaultVal()
}
nextComponentTypeId++
globalComponentTypes = append(globalComponentTypes, componentType)
return componentType
}
// AllComponentTypes returns all IComponentTypes created at that point in time.