/** * @file lighting.h * * Interface of light and vision. */ #pragma once #include #include #include #include "automap.h" #include "engine/displacement.hpp" #include "engine/lighting_defs.hpp" #include "engine/point.hpp" #include "engine/world_tile.hpp" #include "utils/attributes.h" namespace devilution { struct LightPosition { WorldTilePosition tile; /** Pixel offset from tile. */ DisplacementOf offset; /** Previous position. */ WorldTilePosition old; }; struct Light { LightPosition position; uint8_t radius; uint8_t oldRadius; bool isInvalid; bool hasChanged; }; extern Light VisionList[MAXVISION]; extern std::array VisionActive; extern Light Lights[MAXLIGHTS]; extern std::array ActiveLights; extern int ActiveLightCount; extern DVL_API_FOR_TEST std::array, NumLightingLevels> LightTables; /** @brief Contains a pointer to a light table that is fully lit (no color mapping is required). Can be null in hell. */ extern DVL_API_FOR_TEST uint8_t *FullyLitLightTable; /** @brief Contains a pointer to a light table that is fully dark (every color result to 0/black). Can be null in hellfire levels. */ extern DVL_API_FOR_TEST uint8_t *FullyDarkLightTable; extern std::array InfravisionTable; extern std::array StoneTable; extern std::array PauseTable; #ifdef _DEBUG extern bool DisableLighting; #endif extern bool UpdateLighting; void DoUnLight(Point position, uint8_t radius); void DoLighting(Point position, uint8_t radius, DisplacementOf offset); void DoUnVision(Point position, uint8_t radius); void DoVision(Point position, uint8_t radius, MapExplorationType doAutomap, bool visible); tl::expected LoadTrns(); void MakeLightTable(); #ifdef _DEBUG void ToggleLighting(); #endif void InitLighting(); int AddLight(Point position, uint8_t radius); void AddUnLight(int i); void ChangeLightRadius(int i, uint8_t radius); void ChangeLightXY(int i, Point position); void ChangeLightOffset(int i, DisplacementOf offset); void ChangeLight(int i, Point position, uint8_t radius); void ProcessLightList(); void SavePreLighting(); void ActivateVision(Point position, int r, size_t id); void ChangeVisionRadius(size_t id, int r); void ChangeVisionXY(size_t id, Point position); void ProcessVisionList(); void lighting_color_cycling(); constexpr int MaxCrawlRadius = 18; } // namespace devilution