@@ -3,17 +3,17 @@ local SearchResults = {}
33local group_gap_size = 20
44
55--- @param entity LuaEntity
6- --- @param surface_data CategorisedSurfaceData
6+ --- @param entity_groups EntityGroup[]
77--- @return EntityGroup
8- function SearchResults .add_entity (entity , surface_data )
8+ function SearchResults .add_entity (entity , entity_groups )
99 -- Group entities
1010 -- Group contains count, avg_position, selection_box, entity_name, selection_boxes
1111 local entity_name = entity .name
1212 local entity_position = entity .position
1313 local entity_selection_box = entity .selection_box
1414 --- @type EntityGroup ?
1515 local assigned_group
16- for _ , group in pairs (surface_data ) do
16+ for _ , group in pairs (entity_groups ) do
1717 if entity_name == group .entity_name and math2d .bounding_box .collides_with (entity_selection_box , group .selection_box ) then
1818 -- Add entity to group
1919 assigned_group = group
@@ -57,18 +57,18 @@ function SearchResults.add_entity(entity, surface_data)
5757 selection_boxes = {[1 ] = entity .selection_box },
5858 localised_name = entity .localised_name ,
5959 }
60- table.insert (surface_data , assigned_group )
60+ table.insert (entity_groups , assigned_group )
6161 end
6262 return assigned_group
6363end
6464
6565local add_entity = SearchResults .add_entity
6666
6767--- @param entity LuaEntity
68- --- @param surface_data CategorisedSurfaceData
68+ --- @param entity_groups EntityGroup[]
6969--- @param recipe LuaRecipe | LuaRecipePrototype
70- function SearchResults .add_entity_product (entity , surface_data , recipe )
71- local group = add_entity (entity , surface_data )
70+ function SearchResults .add_entity_product (entity , entity_groups , recipe )
71+ local group = add_entity (entity , entity_groups )
7272 local group_recipe_list = group .recipe_list or {}
7373 recipe_name_info = group_recipe_list [recipe .name ] or {localised_name = recipe .localised_name , count = 0 }
7474 recipe_name_info .count = recipe_name_info .count + 1
@@ -77,70 +77,71 @@ function SearchResults.add_entity_product(entity, surface_data, recipe)
7777end
7878
7979--- @param entity LuaEntity
80- --- @param surface_data CategorisedSurfaceData
80+ --- @param entity_groups EntityGroup[]
8181--- @param item_count number
82- function SearchResults .add_entity_storage (entity , surface_data , item_count )
83- local group = add_entity (entity , surface_data )
82+ function SearchResults .add_entity_storage (entity , entity_groups , item_count )
83+ local group = add_entity (entity , entity_groups )
8484 local group_item_count = group .item_count or 0
8585 group .item_count = group_item_count + item_count
8686end
8787
8888--- @param entity LuaEntity
89- --- @param surface_data CategorisedSurfaceData
89+ --- @param entity_groups EntityGroup[]
9090--- @param fluid_count number
91- function SearchResults .add_entity_storage_fluid (entity , surface_data , fluid_count )
92- local group = add_entity (entity , surface_data )
91+ function SearchResults .add_entity_storage_fluid (entity , entity_groups , fluid_count )
92+ local group = add_entity (entity , entity_groups )
9393 local group_fluid_count = group .fluid_count or 0
9494 group .fluid_count = group_fluid_count + fluid_count
9595end
9696
9797--- @param entity LuaEntity
98- --- @param surface_data CategorisedSurfaceData
98+ --- @param entity_groups EntityGroup[]
9999--- @param module_count number
100- function SearchResults .add_entity_module (entity , surface_data , module_count )
101- local group = add_entity (entity , surface_data )
100+ function SearchResults .add_entity_module (entity , entity_groups , module_count )
101+ local group = add_entity (entity , entity_groups )
102102 local group_module_count = group .module_count or 0
103103 group .module_count = group_module_count + module_count
104104end
105105
106106--- @param entity LuaEntity
107- --- @param surface_data CategorisedSurfaceData
107+ --- @param entity_groups EntityGroup[]
108108--- @param request_count number
109- function SearchResults .add_entity_request (entity , surface_data , request_count )
110- local group = add_entity (entity , surface_data )
109+ function SearchResults .add_entity_request (entity , entity_groups , request_count )
110+ local group = add_entity (entity , entity_groups )
111111 local group_request_count = group .request_count or 0
112112 group .request_count = group_request_count + request_count
113113end
114114
115115--- @param entity LuaEntity
116- --- @param surface_data CategorisedSurfaceData
116+ --- @param entity_groups EntityGroup[]
117117--- @param signal_count number
118- function SearchResults .add_entity_signal (entity , surface_data , signal_count )
119- local group = add_entity (entity , surface_data )
118+ function SearchResults .add_entity_signal (entity , entity_groups , signal_count )
119+ local group = add_entity (entity , entity_groups )
120120 local group_signal_count = group .signal_count or 0
121121 group .signal_count = group_signal_count + signal_count
122122end
123123
124124--- @param entity LuaEntity
125- --- @param surface_data CategorisedSurfaceData
125+ --- @param entity_groups EntityGroup[]
126126--- @return number
127- function SearchResults .add_entity_resource (entity , surface_data )
127+ function SearchResults .add_entity_resource (entity , entity_groups )
128128 local resource_count
129129 if entity .initial_amount then
130130 resource_count = entity .amount / 3000 -- Calculate yield from amount
131131 else
132132 resource_count = entity .amount
133133 end
134134
135- local group = add_entity (entity , surface_data )
135+ local group = add_entity (entity , entity_groups )
136136 local group_resource_count = group .resource_count or 0
137137 group .resource_count = group_resource_count + resource_count
138138 return resource_count
139139end
140140
141141--- @param tag LuaCustomChartTag
142- --- @param surface_data CategorisedSurfaceData
143- function SearchResults .add_tag (tag , surface_data )
142+ --- @param entity_groups EntityGroup[]
143+ function SearchResults .add_tag (tag , entity_groups )
144+ -- An alternative to add_entity*, for map tags
144145 -- Tag groups always have size 1
145146 local tag_position = tag .position
146147 local tag_box_size = 8
@@ -168,7 +169,7 @@ function SearchResults.add_tag(tag, surface_data)
168169 },
169170 localised_name = localised_name ,
170171 }
171- table.insert (surface_data , group )
172+ table.insert (entity_groups , group )
172173end
173174
174175--- @param category SurfaceStatisticsCategoryName
0 commit comments