JaimeGensler / thyseus

An archetypal Entity Component System, built entirely in Typescript
MIT License
74 stars 3 forks source link

[FEAT] SystemBuilder API #64

Open JaimeGensler opened 11 months ago

JaimeGensler commented 11 months ago

Describe the problem this feature solves

We need to provide a way of defining systems that doesn't rely on the transformer or on handwriting system properties.

I accidentally committed some of the toying around with this I did so could be a good starting point 🤷

Describe the solution you'd like to see

A systembuilder is probably the ideal way to handle this. For example:

const mySystem = system()
  .query([Position, Velocity])
  .res(Time)
  .build((query, time) => { /* ... */ })

Must be well typed and extensible - probably configureable by providing an object to the system() function.

const mySystem = system({mySystemParam: MySystemParam })
  .mySystemParam() // Now defined and strongly typed
  .build()