nstgeorge / VEKTA

A space exploration game created in Processing 3 with orbital mechanics
MIT License
1 stars 1 forks source link

Promise-style "Action" system #101

Open rvanasa opened 3 years ago

rvanasa commented 3 years ago

Short Description

We want Promises.

More Details

The VEKTA codebase would benefit from Promise-like event chains which work similar to Unity's coroutines. While running, actions will be able to inject special draw/update logic into a SpaceObject without cluttering the original class file. For instance, this would be perfect for situations like the atmospheric re-entry effect as well as scripted dialog / animations.

Here's the proposed syntax for a dialog-like interaction:

playerShip.async()
    .then(() -> getPlayer().send("Hello"))
    .then(new DelayAction(1))
    .then(() -> getPlayer().send("World"));

Similar to JS Promises, it will be possible to "complete" or "cancel" an action for complex error handling.

Custom async actions will implement vekta.action.Action.