Skip to content
Adrian Papari edited this page Oct 2, 2016 · 9 revisions

Annotated serialization

  • Json reported as-is, with inlined comments.
  • Ids are relative and update upon instantiation
{
    "metadata": {
        "version": 1 // in case we ever update
    },
    "componentIdentifiers": { // component aliases, avoids collisions
        "net.onedaybeard.core.component.render.Layer": "Layer",
        "net.onedaybeard.core.component.Position": "Position",
        "net.onedaybeard.core.component.Affix": "Affix",
        "net.onedaybeard.core.component.Tint": "Tint",
        "net.onedaybeard.core.component.Anchor": "Anchor",
        "net.onedaybeard.core.component.render.DistanceField": "DistanceField",
        "net.onedaybeard.core.component.render.TextureReference": "TextureReference",
        "net.onedaybeard.core.component.DynamicTransform": "DynamicTransform",
        "net.onedaybeard.core.component.FontUpperCase": "FontUpperCase",
        "net.onedaybeard.core.component.render.FontReference": "FontReference",
        "net.onedaybeard.core.component.HudRenderable": "HudRenderable",
        "net.onedaybeard.core.component.Size": "Size"
    },
    "entities": {
        "0": { // 0 *was* the entityId at the time of saving
            "archetype": 33, // archetypes are also translated upon loading
            "key": "bottom", // SerializationTag, see SaveFileFormat::get
            "components": {
                "Affix": {
                    "target": 3, // "affixes" to entity "3"
                    "anchor": {
                        "x": 1  // no "y", default value excludes field from output
                    }
                },
                "Anchor": {
                    "anchor": {
                        "y": 1  // no "x", default value
                    }
                },
                "Layer": {
                    "order": 19
                },
                "Position": {
                    "xy": {
                        "y": 13.333334
                    }
                },
                "Size": {
                    "width": 7.23,
                    "height": 2.6
                },
                "TextureReference": {
                    "path": "choose_bg_top",
                    "atlas": "theme_1/images/spritesheet.atlas"
                }
            }
        },
        "1": {
            "archetype": 33,
            "key": "top",
            "components": {
                "Affix": {
                    "target": 3,
                    "anchor": {
                        "y": 1
                    }
                },
                "Anchor": {
                    "anchor": {
                        "x": 1
                    }
                },
                "Layer": {
                    "order": 19
                },
                "Position": {
                    "xy": {
                        "x": 10.000001
                    }
                },
                "Size": {
                    "width": 7.29,
                    "height": 2.54
                },
                "TextureReference": {
                    "path": "choose_bg_bottom",
                    "atlas": "theme_1/images/spritesheet.atlas"
                }
            }
        },
        "3": {
            "archetype": 34,
            "tag": "background", // TagManager and GroupManager ("group") also valid
            "key": "main",
            "components": {
                "Anchor": {
                    "anchor": {
                        "x": 0.5,
                        "y": 0.5
                    }
                },
                "Layer": {
                    "order": 11
                },
                "Position": {
                    "xy": {
                        "x": 5.0000005,
                        "y": 6.666667
                    }
                },
                "Size": {
                    "width": 10.000001,
                    "height": 13.333334
                },
                "TextureReference": {
                    "path": "choose_bg",
                    "atlas": "theme_1/images/spritesheet.atlas"
                }
            }
        }
    },
    "archetypes": { // archetypes == compositionId
        "34": [
            "Position",
            "Anchor",
            "DynamicTransform", // not visisble in "components" due comp having no fields
            "Size",
            "Tint",
            "Layer",
            "TextureReference",
            "HudRenderable"
        ],
        "33": [
            "Position",
            "Anchor",
            "DynamicTransform",
            "Size",
            "Affix",
            "Tint",
            "Layer",
            "TextureReference",
            "HudRenderable"
        ]
    }
}
Clone this wiki locally