![]() |
Peoplemon
0.1.0
Peoplemon 3 game source documentation
|
System for handling lighting in Maps. Manages all the lights and performs rendering. Also handles the loading and saving of lights to map files. More...
#include <LightingSystem.hpp>
Public Types | |
using | Handle = std::uint16_t |
Handle representing a light in the map. More... | |
Public Member Functions | |
LightingSystem () | |
Initializes the lighting system with no lights. More... | |
virtual | ~LightingSystem ()=default |
Destroys the lighting system. More... | |
void | addLight (const Light &light) |
Adds a light to the map and to the persistent map file. More... | |
void | updateLight (Handle handle, const Light &value) |
Updates the light with the given handle to the new information. More... | |
Handle | getClosestLight (const sf::Vector2i &position) |
Returns a handle to the light closest to the given position. More... | |
const Light & | getLight (Handle handle) const |
Returns the value of the light with the given handle. Invalid handles return a default value (a light with a negative position and 0 radius) More... | |
void | removeLight (Handle light) |
Remove the given light from the system and optionally persist the removal. More... | |
bool | lightsAreOn () const |
Returns whether lights are being shown or not based on how dark it is. More... | |
void | setAmbientLevel (std::uint8_t lowLightLevel, std::uint8_t highLightLevel) |
The ambient light band. 0 is full darkness and 255 is full brightness. More... | |
std::uint8_t | getMinLightLevel () const |
Returns the minimum ambient light level of this map. More... | |
std::uint8_t | getMaxLightLevel () const |
Returns the maximum ambient light level of this map. More... | |
void | adjustForSunlight (bool adjust) |
Set whether or not the light level is adjusted based on time of day. If not adjusting for sunlight the higher light level is used for a constant ambient. More... | |
bool | adjustsForSunlight () const |
Returns whether or not this map is adjusted for time of day. More... | |
void | activate (bl::rc::lgt::Scene2DLighting &sceneLighting) |
Adds all lights into the scene. More... | |
void | subscribe () |
Subscribes the lighting system to time events for ambient light level. More... | |
void | unsubscribe () |
Unsubscribes the lighting system from the event dispatcher. More... | |
void | clear () |
Clears all lights from the map, including the persisted light data. More... | |
void | update (float dt) |
Updates the lighting system. More... | |
void | setColorTint (const glm::vec3 &tint) |
Sets a color tint to apply to the ambient lighting. More... | |
virtual void | observe (const event::TimeChange &timeChange) override |
Updates the light level based on the new current time. More... | |
virtual void | observe (const event::WeatherStarted &event) override |
Adjusts the ambient lighting based on the current weather. More... | |
virtual void | observe (const event::WeatherStopped &event) override |
Resets the ambient lighting when weather stops. More... | |
virtual void | observe (const event::Thundered &) override |
Triggers the lighting cycle for thunder. More... | |
Static Public Attributes | |
static constexpr Handle | None = 0 |
Special handle indicating that no light is referenced. More... | |
Friends | |
struct | bl::serial::SerializableObject< LightingSystem > |
System for handling lighting in Maps. Manages all the lights and performs rendering. Also handles the loading and saving of lights to map files.
Definition at line 26 of file LightingSystem.hpp.
using core::map::LightingSystem::Handle = std::uint16_t |
Handle representing a light in the map.
Definition at line 31 of file LightingSystem.hpp.
core::map::LightingSystem::LightingSystem | ( | ) |
Initializes the lighting system with no lights.
Definition at line 22 of file LightingSystem.cpp.
|
virtualdefault |
Destroys the lighting system.
void core::map::LightingSystem::activate | ( | bl::rc::lgt::Scene2DLighting & | sceneLighting | ) |
Adds all lights into the scene.
sceneLighting | The lighting manager for the map scene |
Definition at line 107 of file LightingSystem.cpp.
void core::map::LightingSystem::addLight | ( | const Light & | light | ) |
Adds a light to the map and to the persistent map file.
light | The light to add |
Definition at line 34 of file LightingSystem.cpp.
void core::map::LightingSystem::adjustForSunlight | ( | bool | adjust | ) |
Set whether or not the light level is adjusted based on time of day. If not adjusting for sunlight the higher light level is used for a constant ambient.
adjust | True to adjust based on time of day, false to always use ambient level |
Definition at line 103 of file LightingSystem.cpp.
bool core::map::LightingSystem::adjustsForSunlight | ( | ) | const |
Returns whether or not this map is adjusted for time of day.
Definition at line 105 of file LightingSystem.cpp.
void core::map::LightingSystem::clear | ( | ) |
Clears all lights from the map, including the persisted light data.
Definition at line 124 of file LightingSystem.cpp.
LightingSystem::Handle core::map::LightingSystem::getClosestLight | ( | const sf::Vector2i & | position | ) |
Returns a handle to the light closest to the given position.
position | The position to search near |
Definition at line 64 of file LightingSystem.cpp.
Returns the value of the light with the given handle. Invalid handles return a default value (a light with a negative position and 0 radius)
handle | The handle to get the light for |
Definition at line 80 of file LightingSystem.cpp.
std::uint8_t core::map::LightingSystem::getMaxLightLevel | ( | ) | const |
Returns the maximum ambient light level of this map.
Definition at line 101 of file LightingSystem.cpp.
std::uint8_t core::map::LightingSystem::getMinLightLevel | ( | ) | const |
Returns the minimum ambient light level of this map.
Definition at line 99 of file LightingSystem.cpp.
bool core::map::LightingSystem::lightsAreOn | ( | ) | const |
Returns whether lights are being shown or not based on how dark it is.
Definition at line 91 of file LightingSystem.cpp.
|
overridevirtual |
Triggers the lighting cycle for thunder.
Definition at line 265 of file LightingSystem.cpp.
|
overridevirtual |
Updates the light level based on the new current time.
timeChange | The new current time |
Definition at line 209 of file LightingSystem.cpp.
|
overridevirtual |
Adjusts the ambient lighting based on the current weather.
event | The new weather that has started |
Definition at line 219 of file LightingSystem.cpp.
|
overridevirtual |
Resets the ambient lighting when weather stops.
event | The weather that just stopped |
Definition at line 263 of file LightingSystem.cpp.
void core::map::LightingSystem::removeLight | ( | Handle | light | ) |
Remove the given light from the system and optionally persist the removal.
light | A handle to the light to remove |
updateSave | True to update the data saved to the map file (editor only) |
Definition at line 82 of file LightingSystem.cpp.
void core::map::LightingSystem::setAmbientLevel | ( | std::uint8_t | lowLightLevel, |
std::uint8_t | highLightLevel | ||
) |
The ambient light band. 0 is full darkness and 255 is full brightness.
lowLightLevel | The min light level. This is reached at midnight |
highLightLevel | The max light level. This is reached at noon |
Definition at line 93 of file LightingSystem.cpp.
void core::map::LightingSystem::setColorTint | ( | const glm::vec3 & | tint | ) |
Sets a color tint to apply to the ambient lighting.
tint | The tint to apply to the ambient light color |
Definition at line 267 of file LightingSystem.cpp.
void core::map::LightingSystem::subscribe | ( | ) |
Subscribes the lighting system to time events for ambient light level.
Definition at line 120 of file LightingSystem.cpp.
void core::map::LightingSystem::unsubscribe | ( | ) |
Unsubscribes the lighting system from the event dispatcher.
Definition at line 122 of file LightingSystem.cpp.
void core::map::LightingSystem::update | ( | float | dt | ) |
Updates the lighting system.
dt | Time elapsed in seconds |
Definition at line 134 of file LightingSystem.cpp.
Updates the light with the given handle to the new information.
handle | The handle referencing the light to update |
value | The new light information |
Definition at line 50 of file LightingSystem.cpp.
|
friend |
Definition at line 213 of file LightingSystem.hpp.
|
staticconstexpr |
Special handle indicating that no light is referenced.
Definition at line 34 of file LightingSystem.hpp.