-
Notifications
You must be signed in to change notification settings - Fork 0
Server side
World layer contains game world state as single data structure. Its responsibility is to process and update it according to events that come from Event layer.
After World layer processed all events, world state snapshot goes to Presentational layer.
Except event processing, World layer can have recurring tasks to update world state with time. Those tasks can run and stop depending on world state.
This layer can be local for single-player games and remote for multiplayer.
World layer passes only updates to presentation layer, so it compares new state value after applying all changes with old state.
-
Scene entities organization World layer organized game entities by Entity-Component-System pattern
-
World persistence We can save game state server-side
-
Server-side aspects
- AI
- Physics
- User Input reactions
World layer keeps world state in a single structure. Structure is Record with Entities, each Entity is a set of Components handled by Systems.
Systems perform changes of world state. They are pure functions, that take world state and any needed extra data, and returns updated copy of it. Those functions can be closured by container functions to provide additional cache.
Since systems are pure functions, they can be easily covered with tests.
const engine = new ServerEngine({
// Network server implementation that will be used by Engine
networkServer: new NetworkServer(),
// List of systems for pipeline, in order of execution
systemsPipeline: [
buildDamageSystem({ enableLogging: true }),
],
// Function that will handle errrors if they happen inside of entity
errorHandlerWrap: callback => {
try {
return callback;
}
catch (error) {
// handling
throw new HandlerWrapWorkedError(); // this is needed to notify Engine that error was handled, so it keeps old component states
}
}
});
Since in multiplayer users can see different parts of the world as well as have their own view of it, we need to frame (filter) world state before passing it to client. This is where framing logic comes into play.
It passes world state with client-related information to framing logic, so it can remove all private, restricted or excessive information before it goes to client-side.
- Home - About Engine
- Comparison with UE
- Approach to documentation
- Architecture
- Implementation
- Development
- Example Game Entities