NateTheGreatt / bitECS

Flexible, minimal, data-oriented ECS library for Typescript
Mozilla Public License 2.0
944 stars 84 forks source link

🐞 Fix component typedefs. #22

Closed SupremeTechnopriest closed 3 years ago

SupremeTechnopriest commented 3 years ago

This PR adds a union type to make working with components easier. It also exports the rest of the types.

export type Component = IComponent | ComponentType<ISchema>

Now you can use the Component type and all possible component types are supported.

SupremeTechnopriest commented 3 years ago

Usage example:

import { Component, defineComponent } from 'bitecs'

const components: Map<string, Component> = new Map()
components.set('GameObject', defineComponent())
components.set('Transform', defineComponent({ x: 'f32', y: 'f32, z: 'f32' }))
NateTheGreatt commented 3 years ago

tyty 🙏