Skip to content
Oleg Yushko edited this page Mar 25, 2018 · 8 revisions

Introduction

This module provides serialization to binary format using Kryo.

Dependencies

  1. Add artemis-odb-serializer-kryo module as dependency to your gradle/maven configuration.
  2. Add the required manager and configure the kryo backend:
     final WorldSerializationManager manager = new WorldSerializationManager();
     World world = new World(new WorldConfiguration().setSystem(manager));
     manager.setSerializer(new KryoArtemisSerializer(world));

Usage

Load from file

     final InputStream is = AnyClass.class.getResourceAsStream("level.bin");
     manager.load(is, SaveFileFormat.class);

Anything already in the world is unaffected by the load, so you can incrementally load parts of a world.

Save to file

     final FileOutputStream fos = new FileOutputStream("level.bin");
     manager.save(fos, new SaveFileFormat(entities));

entities is an IntBag with entity IDs defining the scope of the save operation.

Clone this wiki locally