Minetest  5.4.0
ClientEnvironment Class Reference

#include <clientenvironment.h>

+ Inheritance diagram for ClientEnvironment:
+ Collaboration diagram for ClientEnvironment:

Public Member Functions

 ClientEnvironment (ClientMap *map, ITextureSource *texturesource, Client *client)
 
 ~ClientEnvironment ()
 
MapgetMap ()
 
ClientMapgetClientMap ()
 
ClientgetGameDef ()
 
void setScript (ClientScripting *script)
 
void step (f32 dtime)
 
virtual void setLocalPlayer (LocalPlayer *player)
 
LocalPlayergetLocalPlayer () const
 
void addSimpleObject (ClientSimpleObject *simple)
 
GenericCAOgetGenericCAO (u16 id)
 
ClientActiveObjectgetActiveObject (u16 id)
 
u16 addActiveObject (ClientActiveObject *object)
 
void addActiveObject (u16 id, u8 type, const std::string &init_data)
 
void removeActiveObject (u16 id)
 
void processActiveObjectMessage (u16 id, const std::string &data)
 
void damageLocalPlayer (u16 damage, bool handle_hp=true)
 
void getActiveObjects (const v3f &origin, f32 max_d, std::vector< DistanceSortedActiveObject > &dest)
 
bool hasClientEnvEvents () const
 
ClientEnvEvent getClientEnvEvent ()
 
virtual void getSelectedActiveObjects (const core::line3d< f32 > &shootline_on_map, std::vector< PointedThing > &objects)
 
const std::list< std::string > & getPlayerNames ()
 
void addPlayerName (const std::string &name)
 
void removePlayerName (const std::string &name)
 
void updateCameraOffset (const v3s16 &camera_offset)
 
v3s16 getCameraOffset () const
 
- Public Member Functions inherited from Environment
 Environment (IGameDef *gamedef)
 
virtual ~Environment ()=default
 
 DISABLE_CLASS_COPY (Environment)
 
u32 getDayNightRatio ()
 
virtual void setTimeOfDay (u32 time)
 
u32 getTimeOfDay ()
 
float getTimeOfDayF ()
 
void stepTimeOfDay (float dtime)
 
void setTimeOfDaySpeed (float speed)
 
void setDayNightRatioOverride (bool enable, u32 value)
 
u32 getDayCount ()
 
bool line_of_sight (v3f pos1, v3f pos2, v3s16 *p=nullptr)
 
void continueRaycast (RaycastState *state, PointedThing *result)
 
IGameDefgetGameDef ()
 

Private Attributes

ClientMapm_map
 
LocalPlayerm_local_player = nullptr
 
ITextureSourcem_texturesource
 
Clientm_client
 
ClientScriptingm_script = nullptr
 
client::ActiveObjectMgr m_ao_manager
 
std::vector< ClientSimpleObject * > m_simple_objects
 
std::queue< ClientEnvEventm_client_event_queue
 
IntervalLimiter m_active_object_light_update_interval
 
std::list< std::string > m_player_names
 
v3s16 m_camera_offset
 

Additional Inherited Members

- Public Attributes inherited from Environment
u32 m_added_objects
 
- Protected Attributes inherited from Environment
std::atomic< float > m_time_of_day_speed
 
u32 m_time_of_day
 
float m_time_of_day_f
 
float m_time_conversion_skew = 0.0f
 
bool m_enable_day_night_ratio_override = false
 
u32 m_day_night_ratio_override = 0.0f
 
std::atomic< u32 > m_day_count
 
bool m_cache_enable_shaders
 
float m_cache_active_block_mgmt_interval
 
float m_cache_abm_interval
 
float m_cache_nodetimer_interval
 
float m_cache_abm_time_budget
 
IGameDefm_gamedef
 

Constructor & Destructor Documentation

◆ ClientEnvironment()

ClientEnvironment::ClientEnvironment ( ClientMap map,
ITextureSource texturesource,
Client client 
)

References IWritableShaderSource::addShaderConstantSetterFactory(), Client::getShaderSource(), and m_client.

+ Here is the call graph for this function:

◆ ~ClientEnvironment()

ClientEnvironment::~ClientEnvironment ( )

References client::ActiveObjectMgr::clear(), ClientMap::drop(), m_ao_manager, m_local_player, m_map, and m_simple_objects.

+ Here is the call graph for this function:

Member Function Documentation

◆ addActiveObject() [1/2]

u16 ClientEnvironment::addActiveObject ( ClientActiveObject object)

References Environment::getDayNightRatio(), m_ao_manager, m_texturesource, and client::ActiveObjectMgr::registerObject().

Referenced by addActiveObject(), and Client::handleCommand_ActiveObjectRemoveAdd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addActiveObject() [2/2]

void ClientEnvironment::addActiveObject ( u16  id,
u8  type,
const std::string &  init_data 
)

References addActiveObject(), ClientActiveObject::create(), errorstream, getActiveObject(), ClientActiveObject::getAttachmentChildIds(), infostream, ClientActiveObject::initialize(), m_client, serializeJsonString(), ActiveObject::setId(), and BaseException::what().

+ Here is the call graph for this function:

◆ addPlayerName()

void ClientEnvironment::addPlayerName ( const std::string &  name)
inline

References m_player_names.

Referenced by Client::handleCommand_UpdatePlayerList().

+ Here is the caller graph for this function:

◆ addSimpleObject()

void ClientEnvironment::addSimpleObject ( ClientSimpleObject simple)

References m_simple_objects.

Referenced by GenericCAO::directReportPunch(), and GenericCAO::processMessage().

+ Here is the caller graph for this function:

◆ damageLocalPlayer()

void ClientEnvironment::damageLocalPlayer ( u16  damage,
bool  handle_hp = true 
)

References CEE_PLAYER_DAMAGE, getLocalPlayer(), LocalPlayer::hp, m_client_event_queue, and ClientEnvEvent::type.

Referenced by step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActiveObject()

ClientActiveObject* ClientEnvironment::getActiveObject ( u16  id)
inline

References ActiveObjectMgr< T >::getActiveObject(), and m_ao_manager.

Referenced by addActiveObject(), GenericCAO::clearChildAttachments(), getGenericCAO(), GenericCAO::getParent(), Client::handleCommand_PlaySound(), processActiveObjectMessage(), removeActiveObject(), GenericCAO::setAttachment(), Client::step(), GenericCAO::step(), and ParticleSpawner::step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActiveObjects()

void ClientEnvironment::getActiveObjects ( const v3f origin,
f32  max_d,
std::vector< DistanceSortedActiveObject > &  dest 
)
inline

References client::ActiveObjectMgr::getActiveObjects(), and m_ao_manager.

Referenced by collisionMoveSimple(), and getSelectedActiveObjects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCameraOffset()

v3s16 ClientEnvironment::getCameraOffset ( ) const
inline

References m_camera_offset.

Referenced by GenericCAO::getPosition(), ParticleSpawner::spawnParticle(), GenericCAO::updateAttachments(), GenericCAO::updateNodePos(), and Particle::updateVertices().

+ Here is the caller graph for this function:

◆ getClientEnvEvent()

ClientEnvEvent ClientEnvironment::getClientEnvEvent ( )

References FATAL_ERROR_IF, and m_client_event_queue.

Referenced by Client::step().

+ Here is the caller graph for this function:

◆ getClientMap()

ClientMap & ClientEnvironment::getClientMap ( )

References m_map.

Referenced by Client::interact(), Client::sendPlayerPos(), Camera::update(), Particle::updateLight(), and Game::updatePointedThing().

+ Here is the caller graph for this function:

◆ getGameDef()

Client* ClientEnvironment::getGameDef ( )
inline

References m_client.

Referenced by SmokePuffCSO::SmokePuffCSO(), ParticleManager::handleParticleEvent(), ParticleSpawner::spawnParticle(), and GenericCAO::step().

+ Here is the caller graph for this function:

◆ getGenericCAO()

GenericCAO * ClientEnvironment::getGenericCAO ( u16  id)

References ACTIVEOBJECT_TYPE_GENERIC, getActiveObject(), and ActiveObject::getType().

Referenced by GenericCAO::setChildrenVisible().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLocalPlayer()

LocalPlayer* ClientEnvironment::getLocalPlayer ( ) const
inline

◆ getMap()

Map & ClientEnvironment::getMap ( )
virtual

Implements Environment.

References m_map.

Referenced by SmokePuffCSO::SmokePuffCSO(), Client::addNode(), Client::addUpdateMeshTask(), Client::CSMGetNode(), Client::getInventory(), Client::handleCommand_BlockData(), Client::handleCommand_NodemetaChanged(), Client::removeNode(), Client::step(), GenericCAO::step(), and GenericCAO::updateLight().

+ Here is the caller graph for this function:

◆ getPlayerNames()

const std::list<std::string>& ClientEnvironment::getPlayerNames ( )
inline

References m_player_names.

Referenced by Client::getConnectedPlayerNames().

+ Here is the caller graph for this function:

◆ getSelectedActiveObjects()

void ClientEnvironment::getSelectedActiveObjects ( const core::line3d< f32 > &  shootline_on_map,
std::vector< PointedThing > &  objects 
)
virtual

Gets the objects pointed by the shootline as pointed things. If this is a client environment, the local player won't be returned.

Parameters
[in]shootline_on_mapthe shootline for the test in world coordinates
[out]objectsfound objects

Implements Environment.

References boxLineCollision(), getActiveObjects(), ActiveObject::getId(), ClientActiveObject::getPosition(), and ClientActiveObject::getSelectionBox().

+ Here is the call graph for this function:

◆ hasClientEnvEvents()

bool ClientEnvironment::hasClientEnvEvents ( ) const
inline

References m_client_event_queue.

Referenced by Client::step().

+ Here is the caller graph for this function:

◆ processActiveObjectMessage()

void ClientEnvironment::processActiveObjectMessage ( u16  id,
const std::string &  data 
)

References errorstream, getActiveObject(), ActiveObject::getType(), infostream, ClientActiveObject::processMessage(), and BaseException::what().

Referenced by Client::handleCommand_ActiveObjectMessages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeActiveObject()

void ClientEnvironment::removeActiveObject ( u16  id)

References getActiveObject(), m_ao_manager, and client::ActiveObjectMgr::removeObject().

Referenced by Client::handleCommand_ActiveObjectRemoveAdd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removePlayerName()

void ClientEnvironment::removePlayerName ( const std::string &  name)
inline

References m_player_names.

Referenced by Client::handleCommand_UpdatePlayerList().

+ Here is the caller graph for this function:

◆ setLocalPlayer()

void ClientEnvironment::setLocalPlayer ( LocalPlayer player)
virtual

References FATAL_ERROR_IF, and m_local_player.

Referenced by Client::Client().

+ Here is the caller graph for this function:

◆ setScript()

void ClientEnvironment::setScript ( ClientScripting script)
inline

References m_script.

Referenced by Client::loadMods().

+ Here is the caller graph for this function:

◆ step()

void ClientEnvironment::step ( f32  dtime)
virtual

Implements Environment.

References LocalPlayer::applyControl(), Profiler::avg(), BS, Client::checkLocalPrivilege(), COLLISION_NODE, CONTENT_AIR, damageLocalPlayer(), ScriptApiClient::environment_step(), final_color_blend(), g_profiler, g_settings, Settings::getBool(), LocalPlayer::getCAO(), Environment::getDayNightRatio(), Client::getEventManager(), getInteriorLight(), LocalPlayer::getLightPosition(), getLocalPlayer(), Map::getNode(), Player::getSpeed(), ContentFeatures::groups, LocalPlayer::in_liquid, LocalPlayer::in_liquid_stable, LocalPlayer::is_climbing, GenericCAO::isImmortal(), itemgroup_get(), LocalPlayer::light_color, LocalPlayer::liquid_viscosity, m_active_object_light_update_interval, m_ao_manager, m_client, m_map, m_script, m_simple_objects, ClientSimpleObject::m_to_be_removed, Client::modsLoaded(), LocalPlayer::move(), Player::movement_gravity, Player::movement_liquid_fluidity, Player::movement_liquid_fluidity_smooth, Player::movement_liquid_sink, MYMIN, IGameDef::ndef(), p(), LocalPlayer::physics_override_gravity, MtEvent::PLAYER_FALLING_DAMAGE, MtEventManager::put(), Player::setSpeed(), ClientSimpleObject::step(), client::ActiveObjectMgr::step(), IntervalLimiter::step(), Environment::stepTimeOfDay(), LocalPlayer::swimming_pitch, LocalPlayer::swimming_vertical, and U16_MAX.

Referenced by Client::step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateCameraOffset()

void ClientEnvironment::updateCameraOffset ( const v3s16 camera_offset)
inline

References m_camera_offset.

Member Data Documentation

◆ m_active_object_light_update_interval

IntervalLimiter ClientEnvironment::m_active_object_light_update_interval
private

Referenced by step().

◆ m_ao_manager

◆ m_camera_offset

v3s16 ClientEnvironment::m_camera_offset
private

◆ m_client

Client* ClientEnvironment::m_client
private

◆ m_client_event_queue

std::queue<ClientEnvEvent> ClientEnvironment::m_client_event_queue
private

◆ m_local_player

LocalPlayer* ClientEnvironment::m_local_player = nullptr
private

◆ m_map

ClientMap* ClientEnvironment::m_map
private

◆ m_player_names

std::list<std::string> ClientEnvironment::m_player_names
private

◆ m_script

ClientScripting* ClientEnvironment::m_script = nullptr
private

Referenced by setScript(), and step().

◆ m_simple_objects

std::vector<ClientSimpleObject*> ClientEnvironment::m_simple_objects
private

◆ m_texturesource

ITextureSource* ClientEnvironment::m_texturesource
private

Referenced by addActiveObject().


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