INNER CODE UNIT · Go
GetComponents
yohamta0/donburi-ecs · entry.go:29
func GetComponents(e *Entry) []any {
var instances []any
for _, c := range e.World.StorageAccessor().Archetypes[e.loc.Archetype].ComponentTypes() {
instances = append(instances, reflect.Indirect(
reflect.NewAt(c.Typ(), e.Component(c))).Interface(),
)
}
return instances
}
// Add adds the component to the entry.
func Add[T any](e *Entry, c component.IComponentType, component *T) {
e.AddComponent(c, unsafe.Pointer(component))
}
// Set sets the comopnent of the entry.
func Set[T any](e *Entry, c component.IComponentType, component *T) {
e.SetComponent(c, unsafe.Pointer(component))