Dawn/src/world/map/chunk.h

49 lines
1.2 KiB
C

/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <dawn/dawn.h>
#include "../../display/primitive.h"
#include "../../util/math.h"
#include "tile.h"
/**
* Loads a given chunk.
*
* @param chunk The chunk to load.
* @param x X of the chunk.
* @param y Y of the chunk.
* @param z Z of the chunk.
*/
void chunkLoad(chunk_t *chunk, int32_t x, int32_t y, int32_t z);
/**
* Unload a given chunk.
*
* @param chunk Chunk to unload.
*/
void chunkUnload(chunk_t *chunk);
/**
* Gets the chunk index from an absolute coordinate.
*
* @param x Absolute chunk X.
* @param y Absolute chunk Y.
* @param z Absolute chunk Z.
* @returns The index for that chunk. -1 if out of bounds of the current list.
*/
int32_t chunkGet(int32_t x, int32_t y, int32_t z);
/**
* Gets the tile index from a local tile coordinate.
*
* @param x The local X coordinate of the tile.
* @param y The local Y coordinate of the tile.
* @param z The local Z coordinate of the tile.
* @return The index within the chunk that the tile resides.
*/
int32_t chunkGetTile(int32_t x, int32_t y, int32_t z);