3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 This class is the game's environment.
28 - The current time in the game
38 #include "network/networkprotocol.h" // for AccessDeniedCode
39 #include "util/basic_macros.h"
49 // Environment will delete the map passed to the constructor
50 Environment(IGameDef *gamedef);
51 virtual ~Environment() = default;
52 DISABLE_CLASS_COPY(Environment);
55 Step everything in environment.
60 virtual void step(f32 dtime) = 0;
62 virtual Map &getMap() = 0;
64 u32 getDayNightRatio();
67 virtual void setTimeOfDay(u32 time);
69 float getTimeOfDayF();
71 void stepTimeOfDay(float dtime);
73 void setTimeOfDaySpeed(float speed);
75 void setDayNightRatioOverride(bool enable, u32 value);
80 * Gets the objects pointed by the shootline as
82 * If this is a client environment, the local player
84 * @param[in] shootline_on_map the shootline for
85 * the test in world coordinates
87 * @param[out] objects found objects
89 virtual void getSelectedActiveObjects(const core::line3d<f32> &shootline_on_map,
90 std::vector<PointedThing> &objects) = 0;
93 * Returns the next node or object the shootline meets.
94 * @param state current state of the raycast
95 * @result output, will contain the next pointed thing
97 void continueRaycast(RaycastState *state, PointedThing *result);
99 // counter used internally when triggering ABMs
102 IGameDef *getGameDef() { return m_gamedef; }
105 std::atomic<float> m_time_of_day_speed;
108 * Below: values managed by m_time_lock
110 // Time of day in milli-hours (0-23999), determines day and night
112 // Time of day in 0...1
113 float m_time_of_day_f;
114 // Stores the skew created by the float -> u32 conversion
115 // to be applied at next conversion, so that there is no real skew.
116 float m_time_conversion_skew = 0.0f;
117 // Overriding the day-night ratio is useful for custom sky visuals
118 bool m_enable_day_night_ratio_override = false;
119 u32 m_day_night_ratio_override = 0.0f;
120 // Days from the server start, accounts for time shift
121 // in game (e.g. /time or bed usage)
122 std::atomic<u32> m_day_count;
124 * Above: values managed by m_time_lock
127 /* TODO: Add a callback function so these can be updated when a setting
128 * changes. At this point in time it doesn't matter (e.g. /set
129 * is documented to change server settings only)
131 * TODO: Local caching of settings is not optimal and should at some stage
132 * be updated to use a global settings object for getting thse values
133 * (as opposed to the this local caching). This can be addressed in
136 bool m_cache_enable_shaders;
137 float m_cache_active_block_mgmt_interval;
138 float m_cache_abm_interval;
139 float m_cache_nodetimer_interval;
144 std::mutex m_time_lock;