miniplex icon indicating copy to clipboard operation
miniplex copied to clipboard

Future Packages

Open hmans opened this issue 2 years ago • 2 comments

Drafting ideas for future packages we could provide.

miniplex-kit

Provides a collection of components and systems that are useful in many projects:

  • Entity age
  • Cooldowns/Timeouts
  • Auto destroy entities
  • Intervals

miniplex-fiber

Provides extra glue for use in react-three-fiber:

  • World Inspector UI
  • System Runner that integrates with r3f's upcoming useUpdate and provides some debugging UI

hmans avatar Jun 08 '22 13:06 hmans

How do you see miniplex-kit working? I'm interested in understanding how entity age/cooldowns/intervals would work in an ECS (miniplex is the first I've used so I don't have all the context around them). If I wanted to implement them in miniplex today I suppose I'd store delta every tick and then act on it when appropriate. What are you thinking?

itsdouges avatar Oct 12 '22 11:10 itsdouges

I typically build my systems as functions that receive a deltatime as their argument, and mount them in a react-three-fiber useFrame somewhere, passing on the deltatime argument the callback receives to the system. One thing I've done a bunch of times is to give entities optional age: number and maxAge: number properties, and implementing a LifetimeSystem that accumulates the received deltatime values on age, and queues the entity for destruction if age >= maxAge.

Things like these could be packaged into separate libraries (like eg. miniplex-kit.) The challenge here is that the more generic you want to make these implementations, the harder it is to "get them right". A library like this that targets R3F games specifically will probably look and feel entirely different from one that tries to be usable in "any" project.

hmans avatar Oct 12 '22 11:10 hmans