Fix issue with MapPosition.energy

This commit is contained in:
Cooldude2606
2026-08-08 21:58:46 +01:00
parent d495a345d6
commit 1e861c5c0b
10 changed files with 15 additions and 15 deletions
@@ -26,7 +26,7 @@ local function on_entity_damaged(event)
-- Outputs the message as floating text
if message then
local entity_position = entity.position --[[@as MapPosition.struct]]
local entity_position = entity.position
local entity_radius = max(1, entity.get_radius())
local offset = (random() - 0.5) * entity_radius * config.damage_location_variance
local position = { x = entity_position.x + offset, y = entity_position.y - entity_radius }
@@ -85,7 +85,7 @@ local function on_player_changed_position(event)
if player.controller_type ~= defines.controllers.character then return end
local surface = player.physical_surface
local position = player.physical_position --[[@as MapPosition.struct]]
local position = player.physical_position
local strength = get_tile_strength(surface, position)
if not strength then return end
@@ -68,7 +68,7 @@ local function try_deconstruct_output_chest(entity)
end
-- Get all adjacent mining drills and inserters
local target_position = target.position --[[@as MapPosition.struct]]
local target_position = target.position
local entities = target.surface.find_entities_filtered{
type = { "mining-drill", "inserter" },
to_be_deconstructed = false,
@@ -160,7 +160,7 @@ local function try_deconstruct_miner(entity)
end
-- Build pipes if the miner used fluid
local position = entity.position --[[@as MapPosition.struct]]
local position = entity.position
local create_entity_position = { x = position.x, y = position.y }
local create_entity_param = { name = "entity-ghost", inner_name = "pipe", force = entity.force, position = create_entity_position }
local create_entity = surface.create_entity
@@ -247,7 +247,7 @@ local function on_resource_depleted(event)
end
-- Find all mining drills within the area
local position = resource.position --[[@as MapPosition.struct]]
local position = resource.position
local drills = resource.surface.find_entities_filtered{
type = "mining-drill",
area = {
@@ -259,7 +259,7 @@ local function on_resource_depleted(event)
-- Check which could have reached this resource
for _, drill in pairs(drills) do
local radius = drill.prototype.mining_drill_radius
local drill_position = drill.position --[[@as MapPosition.struct]]
local drill_position = drill.position
local dx = math.abs(drill_position.x - position.x)
local dy = math.abs(drill_position.y - position.y)
if dx <= radius and dy <= radius then