/**
 * Copyright (c) 2021 Dominic Masters
 * 
 * This software is released under the MIT License.
 * https://opensource.org/licenses/MIT
 */

#pragma once
#include "../../libs.h"
#include "tile.h"
#include "chunk.h"
#include "../../display/texture.h"
#include "../../display/tileset.h"

/** Width of map (in chunks) */
#define MAP_WIDTH 3
/** Height of map (in chunks) */
#define MAP_HEIGHT MAP_WIDTH
/** Depth of map (in chunks) */
#define MAP_DEPTH 2
/** Count of chunks in the world */
#define MAP_CHUNK_COUNT MAP_WIDTH * MAP_HEIGHT * MAP_DEPTH

#define MAP_ASSET_TEXTURE "world/tileset.png"

typedef struct {
  /** Tile definitions */
  tiledef_t *tileDefinitions;
  
  /** Tileset predivided */
  tileset_t *tileset;

  /** Texture of the tileset */
  texture_t *texture;
  
  /** Current (chunk) coordinates of the first chunk in the chunk list */
  int32_t x, y, z;

  /** Current chunk list, ordered */
  chunk_t *chunkList[MAP_CHUNK_COUNT];
  
  /** Chunk array, unordered */
  chunk_t chunks[MAP_CHUNK_COUNT];
} map_t;

extern map_t MAP_STATE;