Project-Rekt / engine

Game Engine - Currently on version MASON
https://project-rekt.github.io/engine/index.html
Apache License 2.0
1 stars 3 forks source link

Develop and Implement Redux for global state management #7

Closed Squishy123 closed 4 years ago

Squishy123 commented 4 years ago

Develop and Implement Redux for global state management

Let's have a discussion about the possible implementations for global state management in the game engine.

First off why do we need global state?

Consider a stage with multiple actor objects in it. Suppose one of your actors manages a scoreboard, and another needs to manipulate the number of points on the scoreboard.

Both actors would need a reference to the scoreboard object(assuming the scoreboard itself is an actor). How could you pass a reference to these actors at init time? They would have to expect a value in the constructor.

This would be easily done for a 1-level property(prop) drill, but for nth-levels, this would be an extremely inefficient and annoying task.

It would be easier to have a global state object, that actors could subscribe to. When the state is manipulated, the actors would exhibit the changes.

Proposal

Lucklily, redux is an excellent library to manage global state. The only question is how to best implement redux patterns for game engines(which is not done prevalently)

Squishy123 commented 4 years ago

We can actually probably build everything off svelte - they have a good store management system

Squishy123 commented 4 years ago

On the main repo, we can use svelte store for this.