#pragma once #include #include #include #include class GameRenderer; class Entity; class DynamicLighting { private: struct DynamicLightSource { Entity* entity; double luminance; double x; double y; double z; }; static double constexpr MAX_RADIUS = 7.75; static std::mutex dynamicEntityLightSourcesMutex; static std::vector dynamicEntityLightSources; static std::mutex dynamicCompiledLightSourcesMutex; static std::vector dynamicCompiledLightSources; static std::unordered_map> dynamicEntitySourceDefines; static std::unordered_map> dynamicItemSourceDefines; static int64_t lastUpdate; static std::atomic dynamicLightingEnabled; static int getEntityFlickerRange(Entity* entity); static int getItemFlickerRange(shared_ptr item); static int getFlickeredLuminance(Entity* entity, int luminance, int64_t now); public: static void addDynamicEntityLightSource(Entity* entity); static void removeDynamicEntityLightSource(Entity* entity); static int getLightmapWithDynamicLight(int x, int y, int z, int lightMap); static int getLightmapWithDynamicLight(Entity* entity, int lightMap); static int getLightmapWithDynamicLight(double dynamicLuminance, int lightMap); static int getEntityLuminance(Entity* entity); static int getItemLuminance(shared_ptr item); static int getDynamicLuminance(int x, int y, int z); static int maxDynamicLuminance(int x, int y, int z, DynamicLightSource& source, double currentLuminance); static void updateAll(GameRenderer* renderer); static void markTilesDirty(MultiPlayerLevel* level, int x, int y, int z, int luminance); };