Player Input - worldscapes/engine GitHub Wiki

Any application application goal is processing data. In case of games, we present some world to player and let him interact with it by doing input operations. As result of such operations we get Events which can be used further in Simulation.

The question is: how do we conviniently pass Events to Simulation so Engine user can access them without trouble?

From Engine perspective, we do not read player input directly. It should be mapped to PlayerActions outside before being passed to Engine.

From Simulation perspective, Actions are used inside of Rules. To be available to Rules, Action can be stored inside of world state and accessed as part of Query.

Components are picked over Resource to store Actions because Resources will have to contain Action activations for all players at once and can complicate Query optimization. To allow Component usage Simulation should allow one Entity to have several Components of the same type (it's temporary possible to attach several Components of several type, but Store will only return first Component found).

Rule can need certain types of PlayerActions. Actions can be accessed as part of to Player Entity. In case when Action is needed it can be easily requested inside of EntityRequest and used.

It's important that one Player can accept Actions even from several Connections, allowing it to be controlled from several devices potentially or by multpile players.

To simplify working with Actions Engine provides special ActionTools which simpifies working PlayerAction Components.

Path

Actions are generated on Client-side outside of Engine. Engine Client takes them and puts into Network Client. There they are wrapped into PlayerInputMessage which is used to transoport it to Network Server. Here it's unpacked and passed to Engine Server and to Server Simulation. Here Command created to attach Actions to apropriate Entity. After Simulation tick another Command is passed to clear used Actions.