2023-09-18 15:56:17 -04:00
|
|
|
#ifndef WORLD_H__
|
|
|
|
#define WORLD_H__
|
2023-09-30 14:54:39 -04:00
|
|
|
|
2023-09-18 15:56:17 -04:00
|
|
|
#include <fstream>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <future>
|
|
|
|
#include <thread>
|
|
|
|
#include "define.h"
|
|
|
|
#include "vector3.h"
|
2023-09-30 14:46:54 -04:00
|
|
|
#include "array2d.h"
|
2023-09-18 15:56:17 -04:00
|
|
|
#include "bullet.h"
|
2023-09-30 14:46:54 -04:00
|
|
|
#include "chunk.h"
|
2023-12-05 13:44:54 -05:00
|
|
|
#include "netprotocol.h"
|
2023-09-18 15:56:17 -04:00
|
|
|
|
|
|
|
class Chunk;
|
|
|
|
class Bullet;
|
|
|
|
|
|
|
|
class World {
|
|
|
|
public:
|
|
|
|
World();
|
|
|
|
~World();
|
|
|
|
|
|
|
|
Array2d<Chunk*>& GetChunks();
|
2023-10-29 14:54:36 -04:00
|
|
|
void BuildWorld();
|
2023-09-18 15:56:17 -04:00
|
|
|
|
2023-09-30 14:46:54 -04:00
|
|
|
void SetSeed(uint64_t seed);
|
|
|
|
|
2023-09-18 15:56:17 -04:00
|
|
|
Chunk* ChunkAt(float x, float y, float z) const;
|
|
|
|
Chunk* ChunkAt(const Vector3f& pos) const;
|
|
|
|
|
2023-11-08 10:32:16 -05:00
|
|
|
void RemoveChunk(int nbReduit);
|
|
|
|
|
2023-09-18 15:56:17 -04:00
|
|
|
BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const;
|
|
|
|
BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const;
|
|
|
|
|
2023-10-04 15:01:48 -04:00
|
|
|
void Update(Bullet* bullets[MAX_BULLETS], const Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]);
|
2023-09-30 14:46:54 -04:00
|
|
|
|
2023-09-18 15:56:17 -04:00
|
|
|
void GetScope(unsigned int& x, unsigned int& y);
|
|
|
|
|
2023-12-05 13:44:54 -05:00
|
|
|
netprot::ChunkMod* ChangeBlockAtCursor(BlockType blockType, const Vector3f& player_pos, const Vector3f& player_dir, bool& block, bool net);
|
2023-09-18 15:56:17 -04:00
|
|
|
void ChangeBlockAtPosition(BlockType blockType, Vector3f pos);
|
2023-09-30 14:46:54 -04:00
|
|
|
void CleanUpWorld(int& deleteframes, bool clear);
|
|
|
|
int GettbDeleted() const;
|
2023-09-18 15:56:17 -04:00
|
|
|
private:
|
|
|
|
Array2d<Chunk*> m_chunks = Array2d<Chunk*>(WORLD_SIZE_X, WORLD_SIZE_Y);
|
|
|
|
std::vector<Chunk*> m_tbDeleted;
|
2023-09-30 14:46:54 -04:00
|
|
|
uint64_t m_seed = 0;
|
2023-09-18 15:56:17 -04:00
|
|
|
|
|
|
|
unsigned int m_center[2] = { UINT16_MAX / 2 - WORLD_SIZE_X, UINT16_MAX / 2 - WORLD_SIZE_Y };
|
|
|
|
|
2023-10-29 14:54:36 -04:00
|
|
|
//void UpdateChunk(int& updates, unsigned int chx, unsigned int chy, BlockInfo* blockinfo[BTYPE_LAST]);
|
2023-09-30 14:46:54 -04:00
|
|
|
void UpdateWorld(const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]);
|
|
|
|
void TransposeWorld(Vector3f& player, Bullet* bullets[MAX_BULLETS]);
|
|
|
|
|
2023-09-18 15:56:17 -04:00
|
|
|
};
|
|
|
|
#endif // WORLD_H__
|
|
|
|
|