Worker SDK in C++

The Worker SDK in C++ is an implementation of the Worker SDK, based on the C API, and is designed to highlight SpatialOS’s capabilities. It comes with code generation, and makes use of C++ templates and the standard template library (STL) as a common, type-safe, and easy to understand set of generic algorithms and data structures on which you can build worker logic.

It is aimed at evaluation, quick prototyping, and potentially workers that you create without using a game engine. The implementation is deliberately not targeted at a frictionless, performance-critical integration with an existing or planned game engine or abstraction layer (for that use case, refer to the Worker SDK in C). This is due to the following drawbacks:

  • It can be difficult, even wasteful, to interoperate with if the rest of your codebase does not use STL.
  • Your codebase might make different design choices, for example:
    • whether or not, or how heavily, it uses C++ templates.
    • whether individual ops are exposed via dispatcher callbacks (like in the Worker SDK in C++) or directly as a list of ops (like in the Worker SDK in C).
  • If you want to use your own code generation, you have to write this on top of the output of the code generation we provide.
  • It is generic and not optimized for high performance.

Recommended for:

  • understanding SpatialOS’s concepts and abstractions.
  • evaluating SpatialOS’s capabilities.
  • quick prototyping of workers that you create without using a game engine.

May also be suitable for:

  • production use of workers that you create without using a game engine.

Not recommended for:

  • integration into a game engine for production use.

What’s included

The SDK provides functionality to write a worker that:

The SDK also includes methods to load and save snapshots of the entire simulation from and to a file. (See Manipulating snapshots.)

A typical C++ worker uses both the core API defined in <improbable/worker.h>, and C++ generated code based on the user-specified simulated world schema. See Compiling a C++ worker for what to include.

Using the Worker SDK in C++

The most important units of functionality in the C++ worker API are:

For more, see <improbable/worker.h>, the C++ API reference documentation, or the pages under “Using the Worker SDK in C++” in this section.

C++ blank project

You can use the C++ blank project as a starting point for a project using the Worker SDK in C++, or to add a C++ worker to an existing SpatialOS project.

Game engine integrations

The APIs are lower-level than the a game engine integration like the Unity3D integration.

If you’re using a game engine we don’t have an integration with, you can use this SDK to integrate that game engine with SpatialOS. See Integrating an engine for details.

2019-12-13 Page updated with editorial review: added introductory section

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums