2018-12-15 23:55:36 -08:00
|
|
|
//
|
|
|
|
// Created by aurailus on 14/12/18.
|
|
|
|
//
|
|
|
|
|
2019-08-24 17:39:35 -07:00
|
|
|
#pragma once
|
2018-12-15 23:55:36 -08:00
|
|
|
|
2020-01-09 21:04:31 -08:00
|
|
|
#include "World.h"
|
|
|
|
|
2019-10-01 16:33:04 -07:00
|
|
|
#include "../../../world/LocalDimension.h"
|
2018-12-15 23:55:36 -08:00
|
|
|
|
2020-07-28 14:11:11 -07:00
|
|
|
class Target;
|
|
|
|
class Player;
|
|
|
|
class Renderer;
|
|
|
|
class ItemStack;
|
|
|
|
class LocalSubgame;
|
|
|
|
class ParticleEntity;
|
|
|
|
class BlockCrackEntity;
|
2019-07-22 01:22:40 -07:00
|
|
|
class ClientNetworkInterpreter;
|
2020-02-20 11:23:12 -08:00
|
|
|
class WorldInterpolationStream;
|
2019-06-04 00:05:52 -07:00
|
|
|
|
2020-01-09 21:04:31 -08:00
|
|
|
class LocalWorld : public World {
|
2018-12-15 23:55:36 -08:00
|
|
|
public:
|
2020-07-25 20:19:18 -07:00
|
|
|
LocalWorld(LocalSubgame& defs, ClientNetworkInterpreter* net);
|
2018-12-15 23:55:36 -08:00
|
|
|
|
2020-02-27 17:23:42 -08:00
|
|
|
void init(Player* player);
|
2020-01-09 21:04:31 -08:00
|
|
|
void update(double delta) override;
|
2019-03-30 00:48:02 -07:00
|
|
|
|
2020-07-28 14:11:11 -07:00
|
|
|
void createDimension(std::string identifier);
|
|
|
|
|
2020-07-16 19:38:25 -07:00
|
|
|
void loadWorldPacket(std::unique_ptr<PacketView> p);
|
2020-06-21 12:52:03 -07:00
|
|
|
void commitChunk(std::shared_ptr<Chunk> chunk);
|
2018-12-15 23:55:36 -08:00
|
|
|
|
2020-01-09 21:04:31 -08:00
|
|
|
unsigned int getBlock(glm::ivec3 pos) override;
|
|
|
|
void setBlock(glm::ivec3 pos, unsigned int block) override;
|
2019-01-29 16:41:59 -08:00
|
|
|
|
2020-07-28 14:11:11 -07:00
|
|
|
double setBlockDamage(glm::ivec3 pos, double damage) override;
|
2020-07-21 19:33:26 -07:00
|
|
|
|
2020-07-28 14:11:11 -07:00
|
|
|
void blockPlace(Target& target);
|
|
|
|
void blockPlaceOrInteract(Target& target);
|
|
|
|
void blockInteract(Target& target);
|
|
|
|
double blockHit(Target& target);
|
2018-12-26 23:59:00 -08:00
|
|
|
|
2019-11-18 23:03:51 -08:00
|
|
|
unsigned short getBiome(glm::vec3 pos);
|
2020-06-21 12:52:03 -07:00
|
|
|
std::shared_ptr<Chunk> getChunk(glm::ivec3 pos);
|
2019-06-04 00:05:52 -07:00
|
|
|
|
2020-01-09 21:04:31 -08:00
|
|
|
int getMeshChunkCount();
|
|
|
|
int renderChunks(Renderer &render);
|
|
|
|
void renderEntities(Renderer &renderer);
|
2019-06-04 00:05:52 -07:00
|
|
|
|
2020-07-28 14:11:11 -07:00
|
|
|
LocalSubgame& game;
|
2020-01-09 21:04:31 -08:00
|
|
|
LocalDimension dimension;
|
2018-12-26 23:59:00 -08:00
|
|
|
|
2020-07-16 19:38:25 -07:00
|
|
|
int mapBlocksInterpolated = 0;
|
2019-10-01 16:33:04 -07:00
|
|
|
int lastMeshUpdates = 0;
|
2018-12-20 23:41:57 -08:00
|
|
|
private:
|
2019-08-31 23:58:38 -07:00
|
|
|
void finishChunks();
|
|
|
|
void updateBlockDamages(double delta);
|
|
|
|
|
2020-07-28 14:11:11 -07:00
|
|
|
std::unordered_map<glm::ivec3, BlockCrackEntity*, Vec::ivec3> crackEntities;
|
2019-05-16 16:29:46 -07:00
|
|
|
std::vector<ParticleEntity*> particles;
|
2019-05-14 12:05:54 -07:00
|
|
|
|
2020-02-27 17:23:42 -08:00
|
|
|
Player* player = nullptr;
|
|
|
|
ClientNetworkInterpreter* net = nullptr;
|
2019-08-31 23:58:38 -07:00
|
|
|
WorldInterpolationStream* worldGenStream = nullptr;
|
2018-12-15 23:55:36 -08:00
|
|
|
};
|