{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "World Chunk",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "worldId",
    "chunkX",
    "chunkY",
    "width",
    "height",
    "backgroundTileId",
    "roomLayers",
    "heightLayers",
    "instances"
  ],
  "properties": {
    "schemaVersion": {
      "type": "integer",
      "minimum": 1
    },
    "worldId": {
      "type": "string",
      "minLength": 1
    },
    "chunkX": {
      "type": "integer"
    },
    "chunkY": {
      "type": "integer"
    },
    "width": {
      "type": "integer",
      "minimum": 1
    },
    "height": {
      "type": "integer",
      "minimum": 1
    },
    "backgroundTileId": {
      "type": "string"
    },
    "roomLayers": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["layer", "rows", "instanceIds"],
        "properties": {
          "layer": {
            "type": "integer",
            "minimum": 0
          },
          "name": {
            "type": "string"
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "instanceIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    },
    "heightLayers": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "z", "x", "y", "rows"],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "type": "string"
          },
          "z": {
            "type": "integer",
            "minimum": 1
          },
          "x": {
            "type": "integer",
            "minimum": 0
          },
          "y": {
            "type": "integer",
            "minimum": 0
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    },
    "instances": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "layer", "x", "y", "record"],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "templateId": {
            "type": "string"
          },
          "layer": {
            "type": "integer",
            "minimum": 0
          },
          "x": {
            "type": "integer",
            "minimum": 0
          },
          "y": {
            "type": "integer",
            "minimum": 0
          },
          "record": {
            "type": "object"
          }
        }
      }
    }
  }
}
