World, entities, components
This page covers: The game world. Entities and components.
Before you read this page, you should read What is SpatialOS?
The SpatialOS world
In a game running on SpatialOS, the game world is a core concept. By this we mean the SpatialOS world: the canonical source of truth about things in your game.
Entities and components
Entities are the objects in your game. All of the data that you want to share between worker instances has to be stored in entities. Each entity is made up of components; it’s the components which store this data.
For example, in a world with rabbits and lettuces, you’d have
Rabbit entities and
Lettuce entities, each with certain components. These components in turn would have certain properties:
As a developer working with SpatialOS, you will:
- define components, i.e. what data entities can be composed of (write a schema)
- place entities into your world to form a starting point for your game (create a snapshot)
The components on entities act as the data of the game world. And you’ll write code, within workers: game logic makes use of that data to work.
Why is this necessary?
The reason for having this separately-defined world is to store the state of the game world in such a way that many instances of server-workers and client-workers can access and change it, without needing to communicate with each other.
A major reason to use SpatialOS is to exceed those limits: instead of one server looking after the server-side of the game world, SpatialOS coordinates multiple programs (server-workers) to do that.