Final manual fixups

This commit is contained in:
Cooldude2606
2026-08-08 23:09:39 +01:00
parent 1e861c5c0b
commit 5890155331
19 changed files with 59 additions and 75 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ local abs = math.abs
local commands = {}
--- @param player LuaPlayer
--- @param area ExpUtil_AABB.Box
--- @param area BoundingBox.struct
--- @return boolean
local function location_break(player, area)
local surface = player.surface -- Allow remote view
@@ -37,7 +37,7 @@ end
--- Get the key used in protected_areas
--- TODO expose this from EntityProtection
--- @param area ExpUtil_AABB.Box
--- @param area BoundingBox.struct
--- @return string
local function get_area_key(area)
return format_string("%i,%i", floor(area.left_top.x), floor(area.left_top.y))
@@ -49,7 +49,7 @@ end
local function show_protected_entity(player, entity)
local key = get_entity_key(entity)
if renders[player.index][key] then return end
local selection_box = entity.selection_box --[[@as ExpUtil_AABB.Box]]
local selection_box = entity.selection_box
local rb = selection_box.right_bottom
local position = entity.position
renders[player.index][key] = rendering.draw_sprite{
@@ -69,7 +69,7 @@ end
--- Show a protected area to a player
--- @param player LuaPlayer
--- @param surface LuaSurface
--- @param area ExpUtil_AABB.Box
--- @param area BoundingBox.struct
local function show_protected_area(player, surface, area)
local key = get_area_key(area)
if renders[player.index][key] then return end
+1 -2
View File
@@ -55,8 +55,7 @@ Commands.new("get-roles", { "exp-commands_roles.description-get" })
end
local last = #roles_formatted
--- @diagnostic disable-next-line: need-check-nil
roles_formatted[last] = roles_formatted[last][2]
roles_formatted[last] = assert(roles_formatted[last])[2]
return Commands.status.success(response)
end)
@@ -42,7 +42,7 @@ local function format_position(pos)
end
--- Convert an area to a string
--- @param area ExpUtil_AABB.Box
--- @param area BoundingBox.struct
--- @return string
local function format_area(area)
return format_string("%.1f,%.1f,%.1f,%.1f", area.left_top.x, area.left_top.y, area.right_bottom.x, area.right_bottom.y)
@@ -137,8 +137,7 @@ local function on_player_ammo_inventory_changed(event)
if not player or not player.character then return end
local character_ammo = assert(player.get_inventory(defines.inventory.character_ammo))
local gun_index = player.character.selected_gun_index
--- @cast gun_index uint
local gun_index = player.character.selected_gun_index --[[@as uint]]
local item = character_ammo[gun_index]
if not item or not item.valid or not item.valid_for_read then
return
@@ -32,7 +32,7 @@ local function degrade_entity(entity)
local tiles = {}
local surface = entity.surface
local bounding_box = entity.bounding_box --[[@as ExpUtil_AABB.Box]]
local bounding_box = entity.bounding_box
local left_top = bounding_box.left_top
local right_bottom = bounding_box.right_bottom
for x = left_top.x, right_bottom.x do
@@ -167,7 +167,7 @@ local function try_deconstruct_miner(entity)
create_entity(create_entity_param)
-- Find all the entities to connect to
local bounding_box = entity.bounding_box --[[@as ExpUtil_AABB.Box]]
local bounding_box = entity.bounding_box
local search_area = {
{ bounding_box.left_top.x - 1, bounding_box.left_top.y - 1 },
{ bounding_box.right_bottom.x + 1, bounding_box.right_bottom.y + 1 },
@@ -57,7 +57,7 @@ local function rename_station(event)
-- Find the closest resource
local icon = ""
local item_name = ""
local bounding_box = entity.bounding_box --[[@as ExpUtil_AABB.Box]]
local bounding_box = entity.bounding_box
local resources = entity.surface.find_entities_filtered{ position = entity.position, radius = 250, type = "resource" }
if #resources > 0 then
local closest_recourse --- @type LuaEntity?
@@ -66,7 +66,7 @@ local function rename_station(event)
-- Check which recourse is closest
for _, resource in ipairs(resources) do
local resource_box = resource.bounding_box --[[@as ExpUtil_AABB.Box]]
local resource_box = resource.bounding_box
local dx = px - resource_box.left_top.x
local dy = py - resource_box.left_top.y
local distance = (dx * dx) + (dy * dy)
+1 -1
View File
@@ -427,7 +427,7 @@ local function on_entity_settings_pasted(event)
-- Attempt to rotate a machine to match the source machine
if (source.name == destination.name or source.prototype.fast_replaceable_group == destination.prototype.fast_replaceable_group) then
if source.supports_direction and destination.supports_direction and source.type ~= "transport-belt" then
local destination_box = destination.bounding_box --[[@as ExpUtil_AABB.Box]]
local destination_box = destination.bounding_box
local ltx = destination_box.left_top.x
local lty = destination_box.left_top.y
+5 -10
View File
@@ -433,8 +433,7 @@ function Elements.progress_table.add_row(progress_table, row_data)
progress.style.padding = { 0, 2 }
progress.style.font_color = row_data.color
local unit_number = row_data.entity.unit_number
--- @cast unit_number uint
local unit_number = row_data.entity.unit_number --[[@as uint]]
rows[unit_number] = { x = x, y = y, progress = progress }
end
@@ -457,8 +456,7 @@ end
--- @param row_data ExpGui_RocketInfo.elements.progress_table.row_data
function Elements.progress_table.refresh_row(progress_table, row_data)
local element_data = Elements.progress_table.data[progress_table]
local unit_number = row_data.entity.unit_number
--- @cast unit_number uint
local unit_number = row_data.entity.unit_number --[[@as uint]]
local row = element_data.rows[unit_number]
row.x.caption = row_data.x
row.y.caption = row_data.y
@@ -624,8 +622,7 @@ end
function Elements.container.add_silo(entity)
local force = entity.force --[[@as LuaForce]]
local silos = Elements.container._get_force_data(force).silos
local unit_number = entity.unit_number
--- @cast unit_number uint
local unit_number = entity.unit_number --[[@as uint]]
silos[unit_number] = {
entity = entity,
launched = 0,
@@ -661,9 +658,8 @@ Gui.toolbar.create_button{
--- Record the launch and update the stats when a cargo pod finishes ascending
--- @param event EventData.on_cargo_pod_finished_ascending
local function on_cargo_pod_finished_ascending(event)
local force = event.cargo_pod.force
--- @cast force LuaForce
local rockets_launched = force.rockets_launched
local force = event.cargo_pod.force --[[@as LuaForce]]
local rockets_launched = force.rockets_launched --[[@as number]]
-- Update the launch stats for the force
local stats = Elements.container.get_stats(force)
@@ -678,7 +674,6 @@ local function on_cargo_pod_finished_ascending(event)
-- Append the launch tick into the times array
local times = Elements.container.get_launch_times(force)
--- @cast rockets_launched uint
times[rockets_launched] = event.tick
-- Discard the launch time that is no longer needed by any rolling average unless it is a milestone