z_mirror/BottleneckLite
git clone https://git.raiguard.me/z_mirror/BottleneckLite
e4cdc1e
trunk
1local flib_bounding_box =require ( "__flib__.bounding-box" ) 2 3if not settings . startup [ "bnl-enable" ]. value then 4return 5end 6 7local additional_vertical_offset =0.1 8 9local horizontal_position =0.3 10 11local ignored_entities ={ 12-- Mining Drones 13[ "mining-depot" ] =true , 14-- Space Exploration 15[ "se-core-miner" ] =true , 16[ "se-rocket-launch-pad-silo" ] =true , 17-- Transport Drones 18[ "buffer-depot" ] =true , 19[ "fluid-depot" ] =true , 20[ "fuel-depot" ] =true , 21[ "request-depot" ] =true , 22[ "supply-depot" ] =true , 23} 24 25local sizes ={ 26tiny =0.075 , 27small =0.15 , 28medium =0.2 , 29large =0.25 , 30huge =0.5 , 31} 32 33--- @type table<string, Color> 34local status_colors ={} 35for name , spec in pairs ( settings . startup ) do 36local key =string . match ( name , "^bnl%-color%-(.-)$" ) 37if key then 38status_colors [ key ] =util . premul_color ( spec . value --[[@as Color]] ) 39end 40end 41 42local enable_glow =settings . startup [ "bnl-glow" ]. value --[[@as boolean]] 43local size =sizes [ settings . startup [ "bnl-indicator-size" ]. value ] --[[@as double]] 44 45local function add_indicator ( prototype , graphics_set ) 46if not graphics_set then 47return 48end 49 50graphics_set . status_colors =status_colors 51 52local working_visualisations =graphics_set . working_visualisations 53if not working_visualisations then 54working_visualisations ={} 55graphics_set . working_visualisations =working_visualisations 56end 57 58local box =prototype . selection_box or prototype . collision_box 59if not box then 60return 61end 62box =flib_bounding_box . ensure_explicit ( box ) 63local positions ={ 64north_south ={} , 65east_west ={} , 66} 67for _ , pos in pairs ( positions ) do 68pos . x =box . left_top . x + ( flib_bounding_box . width ( box ) * horizontal_position ) 69pos . y =box . right_bottom . y - size - additional_vertical_offset 70box =flib_bounding_box . rotate ( box ) 71end 72 73working_visualisations [ # working_visualisations + 1 ] ={ 74always_draw =true , 75apply_tint ="status" , 76render_layer ="light-effect" , 77animation ={ 78filename ="__BottleneckLite__/graphics/solid.png" , 79flags ={ "icon" } , 80size =64 , 81scale =size , 82line_length =1 , 83frame_count =1 , 84animation_speed =1 , 85draw_as_glow =enable_glow , 86} , 87north_position =positions . north_south , 88east_position =positions . east_west , 89south_position =positions . north_south , 90west_position =positions . east_west , 91} 92end 93 94for _ , type in pairs ( { "assembling-machine" , "furnace" , "rocket-silo" } ) do 95for name , crafter in pairs ( data . raw [ type ]) do 96if not ignored_entities [ name ] then 97if crafter . bottleneck_ignore then 98crafter . bottleneck_ignore =nil --- @diagnostic disable-line:inject-field 99else 100add_indicator ( crafter , crafter . graphics_set ) 101add_indicator ( crafter , crafter . graphics_set_flipped ) 102end 103end 104end 105end 106 107if not settings . startup [ "bnl-include-mining-drills" ]. value then 108return 109end 110 111for name , drill in pairs ( data . raw [ "mining-drill" ]) do 112if not ignored_entities [ name ] then 113--- @diagnostic disable-next-line:undefined-field 114if drill . bottleneck_ignore then 115drill . bottleneck_ignore =nil --- @diagnostic disable-line:inject-field 116else 117--- @diagnostic disable-next-line:undefined-field 118add_indicator ( drill , drill . graphics_set ) 119add_indicator ( drill , drill . graphics_set_flipped ) 120add_indicator ( drill , drill . wet_mining_graphics_set ) 121add_indicator ( drill , drill . wet_mining_graphics_set_flipped ) 122end 123end 124end