XtreemNodes/include/MapBlock.h

75 lines
1.0 KiB
C
Raw Normal View History

2022-10-22 17:03:43 +02:00
#ifndef MAPBLOCK_H
#define MAPBLOCK_H
#include "Base.h"
2022-10-23 23:44:58 +02:00
#include <math.h>
2022-10-22 17:03:43 +02:00
class NodeManager
{
public:
2022-10-23 23:44:58 +02:00
int blockX;
int blockZ;
2022-10-22 17:03:43 +02:00
2022-10-23 23:44:58 +02:00
NodeManager(int x, int z)
2022-10-22 17:03:43 +02:00
{
2022-10-23 23:44:58 +02:00
2022-10-22 17:03:43 +02:00
}
2022-10-23 23:44:58 +02:00
2022-10-22 17:03:43 +02:00
virtual ~NodeManager()
{
}
void addNode(int id, int meta, int x, int y, int z)
{
mapBlock[256 * y + z * 16 + x] = id;
}
bool isAir(int x, int y, int z)
{
return getNodeAt(x, y, z) == 0;
}
int getNodeAt(int x, int y, int z)
{
return x < 16 && z < 16 && x >= 0 && z >= 0 ? mapBlock[256 * y + z * 16 + x] : 0;
}
protected:
private:
int mapBlock[65536];
};
2022-10-23 23:44:58 +02:00
class BlockManager
{
};
class BlockUtilities
2022-10-22 17:03:43 +02:00
{
public:
2022-10-23 23:44:58 +02:00
BlockUtilities()
2022-10-22 17:03:43 +02:00
{
}
2022-10-23 23:44:58 +02:00
static Position2D getBlockFromNodeCoordinates(int x, int z)
2022-10-22 17:03:43 +02:00
{
2022-10-23 23:44:58 +02:00
Position2D pos2d;
pos2d.x = floor(x / 16);
pos2d.z = floor(z / 16);
return pos2d;
2022-10-22 17:03:43 +02:00
}
2022-10-23 23:44:58 +02:00
2022-10-22 17:03:43 +02:00
};
#endif