Zepha/src/world/ServerWorld.h

70 lines
1.7 KiB
C
Raw Normal View History

//
2020-05-12 17:16:11 -07:00
// World subclass for the server.
// Handles blocks, entities, and clients.
// Created by aurailus on 05/03/19.
//
#pragma once
2020-08-13 00:55:18 -07:00
#include "world/World.h"
2020-08-13 00:55:18 -07:00
#include "world/dim/ServerDimension.h"
class Target;
class ItemStack;
class ServerPlayer;
2021-07-07 15:39:04 -07:00
class ServerClients;
class ServerSubgame;
2020-06-24 16:35:01 -07:00
class ServerGenStream;
2021-07-07 15:39:04 -07:00
class ServerInventoryRefs;
class ServerPacketStream;
2020-06-24 16:35:01 -07:00
class ServerWorld : public World {
public:
2020-11-08 22:57:34 -08:00
explicit ServerWorld(unsigned int seed, SubgamePtr game, ServerClients& clients);
void init(const std::string& worldDir);
void update(double delta) override;
virtual void sendMessage(const std::string& channel, const std::string& message) override;
2020-11-08 22:57:34 -08:00
virtual DimensionPtr
createDimension(const std::string& identifier, std::unordered_set<std::string>& biomes) override;
virtual DimensionPtr getDimension(unsigned int index) override;
virtual DimensionPtr getDimension(const std::string& identifier) override;
virtual InventoryRefsPtr getRefs() override;
virtual ServerClients& getClients();
private:
2020-11-08 22:57:34 -08:00
void changedMapBlocks(ServerPlayer& player);
bool generateMapBlock(unsigned int dim, glm::ivec3 pos);
void generateMapBlocks(ServerPlayer& player);
void sendChunksToPlayer(ServerPlayer& client);
std::shared_ptr<ServerGenStream> genStream = nullptr;
std::shared_ptr<ServerPacketStream> packetStream = nullptr;
u32 seed;
2020-11-08 22:57:34 -08:00
ServerClients& clients;
std::shared_ptr<ServerInventoryRefs> refs;
// std::string worldDir;
// std::shared_ptr<FileManipulator> fileManip;
2020-11-08 22:57:34 -08:00
u32 generatedMapBlocks = 0;
std::vector<ivec3> generateOrder;
2020-11-08 22:57:34 -08:00
const ivec2 mapBlockGenRange = { 4, 4 };
const ivec2 sendRange = { 4, 4 };
const ivec2 activeChunkRange = { 16, 16 };
};