SyndicatQuebecoisdelaConstr.../SQCSim2021/world.h

57 lines
1.7 KiB
C
Raw Normal View History

2021-11-15 20:58:13 -05:00
#ifndef WORLD_H__
#define WORLD_H__
#include "define.h"
#include "chunk.h"
#include "array2d.h"
#include "vector3.h"
2021-12-01 21:21:45 -05:00
#include "player.h"
2021-11-15 20:58:13 -05:00
#include "transformation.h"
2021-12-02 18:12:35 -05:00
#include "perlin.h"
#include "shader.h"
2021-12-07 18:59:50 -05:00
#include "bullet.h"
2021-12-02 18:12:35 -05:00
#include "textureatlas.h"
2021-11-30 19:55:11 -05:00
#include <fstream>
#include <string>
2021-12-01 21:21:45 -05:00
#include <vector>
2021-12-12 23:31:38 -05:00
#include <future>
#include <thread>
2021-11-15 20:58:13 -05:00
class Chunk;
2021-12-01 21:21:45 -05:00
class Player;
2021-12-07 18:59:50 -05:00
class Bullet;
2021-11-15 20:58:13 -05:00
class World {
2021-12-02 18:12:35 -05:00
public:
World();
~World();
2021-11-15 20:58:13 -05:00
2021-12-02 18:12:35 -05:00
Array2d<Chunk*>& GetChunks();
2021-11-15 20:58:13 -05:00
2021-12-02 18:12:35 -05:00
Chunk* ChunkAt(float x, float y, float z) const;
Chunk* ChunkAt(const Vector3f& pos) const;
2021-11-15 20:58:13 -05:00
2021-12-02 18:12:35 -05:00
BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const;
BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const;
2021-12-01 22:06:47 -05:00
2021-12-07 18:59:50 -05:00
void Update(int& rendercount, Bullet* bullets[MAX_BULLETS], Player& player, Transformation& world, Shader& shader, TextureAtlas& atlas, Perlin& perlin, BlockInfo* blockinfo[BTYPE_LAST]);
2021-12-02 18:12:35 -05:00
void GetScope(int& x, int& y);
void ChangeBlockAtCursor(BlockType blockType, Player& player, bool& block);
2021-12-07 18:59:50 -05:00
void ChangeBlockAtPosition(BlockType blockType, Vector3f pos);
2021-12-02 18:12:35 -05:00
void CleanUpWorld(int& deleteframes, bool clear);
2021-11-15 20:58:13 -05:00
private:
2021-11-26 11:59:02 -05:00
Array2d<Chunk*> m_chunks = Array2d<Chunk*>(WORLD_SIZE_X, WORLD_SIZE_Y);
2021-12-01 21:21:45 -05:00
std::vector<Chunk*> m_tbDeleted;
2021-11-15 20:58:13 -05:00
2021-12-02 18:12:35 -05:00
int m_center[2] = { INT16_MAX / 2 - WORLD_SIZE_X / 2, INT16_MAX / 2 - WORLD_SIZE_Y / 2 };
2021-12-12 23:31:38 -05:00
void UpdateChunk(int& updates, int chx, int chy, BlockInfo* blockinfo[BTYPE_LAST]);
2021-12-07 18:59:50 -05:00
void RenderWorld(int& rendercount, Player& player, Transformation& world, Shader& shader);
2021-12-02 18:12:35 -05:00
void UpdateWorld(Player& player, Perlin& perlin, BlockInfo* blockinfo[BTYPE_LAST]);
2021-12-07 18:59:50 -05:00
void TransposeWorld(Player& player, Bullet* bullets[MAX_BULLETS]);
2021-12-02 18:12:35 -05:00
2021-11-15 20:58:13 -05:00
};
2021-11-16 20:48:52 -05:00
#endif // WORLD_H__
2021-11-15 20:58:13 -05:00