Kryo Serialization - junkdog/artemis-odb GitHub Wiki
Introduction
This module provides serialization to binary format using Kryo.
Dependencies
- Add
artemis-odb-serializer-kryomodule as dependency to your gradle/maven configuration. - 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.