VOX
A little voxel engine
Loading...
Searching...
No Matches
ClientWorld Class Reference

#include <ClientWorld.hpp>

Inheritance diagram for ClientWorld:
Inheritance graph
Collaboration diagram for ClientWorld:
Collaboration graph

Classes

struct  PlayerUseResult
 

Public Member Functions

 ClientWorld (RenderAPI &render_api, Sound::Engine &sound_engine, Event::Manager &event_manager, Client &client, uint64_t my_player_id=0)
 
 ~ClientWorld ()
 
 ClientWorld (ClientWorld &other)=delete
 
 ClientWorld (ClientWorld &&other)=delete
 
ClientWorldoperator= (ClientWorld &other)=delete
 
ClientWorldoperator= (ClientWorld &&other)=delete
 
void updateBlock (glm::dvec3 position)
 
void updateSystems (const double delta_time_second)
 
int getRenderDistance () const
 
void setRenderDistance (const int &render_distance)
 
int getServerLoadDistance () const
 
void setServerLoadDistance (const int &server_load_distance)
 
std::pair< glm::dvec3, glm::dvec3 > calculatePlayerMovement (const uint64_t player_id, const int8_t forward, const int8_t backward, const int8_t left, const int8_t right, const int8_t up, const int8_t down, const double delta_time_second)
 
void updatePlayerCamera (const uint64_t player_id, const double x_offset, const double y_offset)
 
void updatePlayerTargetBlock (const uint64_t player_id)
 
std::pair< bool, glm::vec3 > playerAttack (const uint64_t player_id, bool attack)
 
PlayerUseResult playerUse (const uint64_t player_id, bool use)
 
void changePlayerViewMode (const uint64_t player_id)
 
void manageScroll (const double x_offset, const double y_offset)
 
void updatePlayer (const uint64_t player_id, std::function< void(Player &)> update)
 
void createMob ()
 
void updateMobs (const double delta_time_second)
 
void createBaseMob (const glm::dvec3 &position, uint64_t player_id)
 
void modifyBlock (const glm::vec3 &position, const BlockInfo::Type &block_id)
 
uint64_t createPlayer (const glm::vec3 &position)
 
void addPlayer (const uint64_t player_id, const glm::dvec3 &position)
 
void removePlayer (const uint64_t player_id)
 
void updatePlayerPosition (const uint64_t &player_id, const glm::dvec3 &position)
 
void applyPlayerMovement (const uint64_t &player_id, const glm::dvec3 &displacement)
 
Camera getCamera (const uint64_t player_id)
 
glm::dvec3 getPlayerPosition (const uint64_t player_id)
 
void addChunk (std::shared_ptr< Chunk > chunk)
 
void removeChunk (const glm::ivec3 &chunkPosition)
 
std::vector< glm::ivec3 > getNeededChunks (const glm::vec3 &playerPosition)
 
std::shared_ptr< ChunklocalGetChunk (const glm::ivec3 &position) const
 
void otherUpdate ()
 
void handlePacket (std::shared_ptr< IPacket > packet)
 
- Public Member Functions inherited from World
 World (bool save=false)
 
 ~World ()
 
 World (World &other)=delete
 
 World (World &&other)=delete
 
Worldoperator= (World &other)=delete
 
Worldoperator= (World &&other)=delete
 
std::shared_ptr< ChunkgetChunk (const glm::ivec3 &position)
 Get the Chunk object. More...
 
void insertChunk (const glm::ivec3 &position, std::shared_ptr< Chunk > chunk)
 
void unloadRegion (const glm::ivec2 region_pos)
 Unloads all chunk inside a region, if save is enabled, will save the region in a region file. More...
 
WorldGeneratorgetWorldGenerator ()
 
SavegetSave ()
 

Public Attributes

uint64_t m_my_player_id
 

Additional Inherited Members

- Static Public Member Functions inherited from World
static glm::vec3 getBlockChunkPosition (const glm::vec3 &position)
 will return the block position relative to the chunk More...
 
static glm::vec3 getChunkPosition (const glm::vec3 &position)
 will return the chunk position containing the block More...
 
- Protected Member Functions inherited from World
 TracyLockableN (std::mutex, m_players_mutex, "Players")
 
 TracyLockableN (std::mutex, m_mobs_mutex, "Mobs")
 
 TracyLockableN (std::mutex, m_chunks_mutex, "Chunks")
 
std::shared_ptr< ChunkgetChunkNoLock (const glm::ivec3 &position)
 Get a chunk ptr without locking the chunks mutex. More...
 
void insertChunkNoLock (const glm::ivec3 &position, std::shared_ptr< Chunk > chunk)
 
std::unordered_set< glm::ivec3 > updateSkyLight (const glm::ivec3 &block_position)
 Update the sky light of the chunk containing the block. More...
 
std::unordered_set< glm::ivec3 > updateBlockLight (const glm::ivec3 &block_position)
 Update the block light of the chunk containing the block. More...
 
- Protected Attributes inherited from World
std::unordered_map< uint64_t, std::shared_ptr< Player > > m_players
 
std::unordered_map< uint64_t, std::shared_ptr< Mob > > m_mobs
 
uint64_t m_mob_id = 0
 
std::unordered_map< glm::ivec3, std::shared_ptr< Chunk > > m_chunks
 
ExecutorAccessor m_executor
 
WorldGenerator m_world_generator
 
std::unique_ptr< Savem_save
 

Constructor & Destructor Documentation

◆ ClientWorld() [1/3]

ClientWorld::ClientWorld ( RenderAPI render_api,
Sound::Engine sound_engine,
Event::Manager event_manager,
Client client,
uint64_t  my_player_id = 0 
)

◆ ~ClientWorld()

ClientWorld::~ClientWorld ( )

◆ ClientWorld() [2/3]

ClientWorld::ClientWorld ( ClientWorld other)
delete

◆ ClientWorld() [3/3]

ClientWorld::ClientWorld ( ClientWorld &&  other)
delete

Member Function Documentation

◆ addChunk()

void ClientWorld::addChunk ( std::shared_ptr< Chunk chunk)

◆ addPlayer()

void ClientWorld::addPlayer ( const uint64_t  player_id,
const glm::dvec3 &  position 
)

◆ applyPlayerMovement()

void ClientWorld::applyPlayerMovement ( const uint64_t &  player_id,
const glm::dvec3 &  displacement 
)

◆ calculatePlayerMovement()

std::pair< glm::dvec3, glm::dvec3 > ClientWorld::calculatePlayerMovement ( const uint64_t  player_id,
const int8_t  forward,
const int8_t  backward,
const int8_t  left,
const int8_t  right,
const int8_t  up,
const int8_t  down,
const double  delta_time_second 
)

◆ changePlayerViewMode()

void ClientWorld::changePlayerViewMode ( const uint64_t  player_id)

◆ createBaseMob()

void ClientWorld::createBaseMob ( const glm::dvec3 &  position,
uint64_t  player_id 
)

◆ createMob()

void ClientWorld::createMob ( )

◆ createPlayer()

uint64_t ClientWorld::createPlayer ( const glm::vec3 &  position)

◆ getCamera()

Camera ClientWorld::getCamera ( const uint64_t  player_id)

◆ getNeededChunks()

std::vector< glm::ivec3 > ClientWorld::getNeededChunks ( const glm::vec3 &  playerPosition)

◆ getPlayerPosition()

glm::dvec3 ClientWorld::getPlayerPosition ( const uint64_t  player_id)

◆ getRenderDistance()

int ClientWorld::getRenderDistance ( ) const

◆ getServerLoadDistance()

int ClientWorld::getServerLoadDistance ( ) const

◆ handlePacket()

void ClientWorld::handlePacket ( std::shared_ptr< IPacket packet)

◆ localGetChunk()

std::shared_ptr< Chunk > ClientWorld::localGetChunk ( const glm::ivec3 &  position) const

◆ manageScroll()

void ClientWorld::manageScroll ( const double  x_offset,
const double  y_offset 
)

◆ modifyBlock()

void ClientWorld::modifyBlock ( const glm::vec3 &  position,
const BlockInfo::Type block_id 
)

◆ operator=() [1/2]

ClientWorld & ClientWorld::operator= ( ClientWorld &&  other)
delete

◆ operator=() [2/2]

ClientWorld & ClientWorld::operator= ( ClientWorld other)
delete

◆ otherUpdate()

void ClientWorld::otherUpdate ( )

◆ playerAttack()

std::pair< bool, glm::vec3 > ClientWorld::playerAttack ( const uint64_t  player_id,
bool  attack 
)

◆ playerUse()

ClientWorld::PlayerUseResult ClientWorld::playerUse ( const uint64_t  player_id,
bool  use 
)

◆ removeChunk()

void ClientWorld::removeChunk ( const glm::ivec3 &  chunkPosition)

◆ removePlayer()

void ClientWorld::removePlayer ( const uint64_t  player_id)

◆ setRenderDistance()

void ClientWorld::setRenderDistance ( const int &  render_distance)

◆ setServerLoadDistance()

void ClientWorld::setServerLoadDistance ( const int &  server_load_distance)

◆ updateBlock()

void ClientWorld::updateBlock ( glm::dvec3  position)

◆ updateMobs()

void ClientWorld::updateMobs ( const double  delta_time_second)

◆ updatePlayer()

void ClientWorld::updatePlayer ( const uint64_t  player_id,
std::function< void(Player &)>  update 
)

◆ updatePlayerCamera()

void ClientWorld::updatePlayerCamera ( const uint64_t  player_id,
const double  x_offset,
const double  y_offset 
)

◆ updatePlayerPosition()

void ClientWorld::updatePlayerPosition ( const uint64_t &  player_id,
const glm::dvec3 &  position 
)

◆ updatePlayerTargetBlock()

void ClientWorld::updatePlayerTargetBlock ( const uint64_t  player_id)

◆ updateSystems()

void ClientWorld::updateSystems ( const double  delta_time_second)

Member Data Documentation

◆ m_my_player_id

uint64_t ClientWorld::m_my_player_id

The documentation for this class was generated from the following files: