ConvertComponentMap

ceramic.ConvertComponentMap (Class)
Implements: ConvertField

Converter for component map fields in fragments and data serialization.

This converter handles maps of Component instances by storing and restoring them using component initializer names. Components are instantiated from registered initializers during deserialization, allowing fragments to declaratively specify which components an entity should have.

Note: This system requires the ceramic_use_component_initializers flag to be enabled for full functionality.

Instance Members

basicToField(instance: Entity, field: String, assets: Assets, basic: haxe.DynamicAccess<String>, done: Function): Void

Convert a basic object mapping component names to initializer names into a map of actual Component instances.

Each entry in the basic object maps a component name (key) to a component initializer name (value). The initializer is looked up in the app's component initializers registry and used to create a new component instance.

Name Type Description
instance Entity The entity that will own these components
field String The name of the field being converted
assets Assets Assets instance for resource loading (unused for components)
basic haxe.DynamicAccess<String> Object mapping component names to initializer names
done Function Callback invoked with the map of instantiated components

fieldToBasic(instance: Entity, field: String, value: Map): haxe.DynamicAccess<String>

Convert a map of Component instances to a basic object for serialization.

Only components that have an initializer name are included in the serialized output. The resulting object maps component names to their initializer names, allowing them to be recreated later.

Name Type Description
instance Entity The entity that owns these components
field String The name of the field being converted
value Map Map of component instances to serialize
Returns Description
haxe.DynamicAccess<String> Object mapping component names to initializer names

new(): Void

Create a new component map converter instance.