diff --git a/src/item.cpp b/src/item.cpp index 2eacc629b49f7..c4b21bc88e22b 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -10248,7 +10248,21 @@ bool item::is_funnel_container( units::volume &bigger_than ) const bool item::is_emissive() const { - return light.luminance > 0 || type->light_emission > 0; + if( light.luminance > 0 || type->light_emission > 0 ) { + return true; + } + + for( const item_pocket *pkt : get_all_contained_pockets() ) { + if( pkt->transparent() ) { + for( const item *it : pkt->all_items_top() ) { + if( it->is_emissive() ) { + return true; + } + } + } + } + + return false; } bool item::is_deployable() const diff --git a/src/lightmap.cpp b/src/lightmap.cpp index b6e36a4429b83..2af38447a63a5 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -68,22 +68,35 @@ std::string four_quadrants::to_string() const ( *this )[quadrant::SW], ( *this )[quadrant::NW] ); } -void map::add_light_from_items( const tripoint_bub_ms &p, const item_stack &items ) +void map::add_item_light_recursive( const tripoint_bub_ms &p, const item &it ) { - for( const item &it : items ) { - float ilum = 0.0f; // brightness - units::angle iwidth = 0_degrees; // 0-360 degrees. 0 is a circular light_source - units::angle idir = 0_degrees; // otherwise, it's a light_arc pointed in this direction - if( it.getlight( ilum, iwidth, idir ) ) { - if( iwidth > 0_degrees ) { - apply_light_arc( p, idir, ilum, iwidth ); - } else { - add_light_source( p, ilum ); + float ilum = 0.0f; // brightness + units::angle iwidth = 0_degrees; // 0-360 degrees. 0 is a circular light_source + units::angle idir = 0_degrees; // otherwise, it's a light_arc pointed in this direction + if( it.getlight( ilum, iwidth, idir ) ) { + if( iwidth > 0_degrees ) { + apply_light_arc( p, idir, ilum, iwidth ); + } else { + add_light_source( p, ilum ); + } + } + + for( const item_pocket *pkt : it.get_all_contained_pockets() ) { + if( pkt->transparent() ) { + for( const item *cont : pkt->all_items_top() ) { + add_item_light_recursive( p, *cont ); } } } } +void map::add_light_from_items( const tripoint_bub_ms &p, const item_stack &items ) +{ + for( const item &it : items ) { + add_item_light_recursive( p, it ); + } +} + // TODO: Consider making this just clear the cache and dynamically fill it in as is_transparent() is called bool map::build_transparency_cache( const int zlev ) { diff --git a/src/map.h b/src/map.h index cad4ae8032098..f2eb24bc85e41 100644 --- a/src/map.h +++ b/src/map.h @@ -2397,6 +2397,7 @@ class map void apply_light_ray( cata::mdarray &lit, const tripoint &s, const tripoint &e, float luminance ); void add_light_from_items( const tripoint_bub_ms &p, const item_stack &items ); + void add_item_light_recursive( const tripoint_bub_ms &p, const item &it ); std::unique_ptr add_vehicle_to_map( std::unique_ptr veh, bool merge_wrecks ); // Internal methods used to bash just the selected features