Skip to content

Commit

Permalink
Use LuaRendering for overlay
Browse files Browse the repository at this point in the history
Also remove the rm_overlay entity, as it was a much more heavy-handed approach to the same outcome.

Closes #175
  • Loading branch information
narc0tiq committed Dec 18, 2024
1 parent 449372d commit 3dc6cba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 31 deletions.
Binary file removed graphics/rm_Overlay.png
Binary file not shown.
25 changes: 0 additions & 25 deletions prototypes/prototypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,6 @@ data:extend(
},
},

{
type = 'container',
name = 'rm_overlay',
flags = { 'placeable-neutral', 'player-creation', 'not-repairable' },
icon = '__YARM__/graphics/rm_Overlay.png',
icon_size = 32,

max_health = 1,
order = 'z[resource-monitor]',

collision_mask = { layers = { resource = true } },
collision_box = { { -0.35, -0.35 }, { 0.35, 0.35 } },

selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
inventory_size = 1,
picture =
{
filename = '__YARM__/graphics/rm_Overlay.png',
priority = 'extra-high',
width = 32,
height = 32,
shift = { 0.0, 0.0 }
}
},

{
type = 'font',
name = 'yarm-gui-font',
Expand Down
14 changes: 8 additions & 6 deletions resmon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,14 @@ function resmon.put_marker_at(surface, pos, player_data)
return
end

local overlay = surface.create_entity { name = "rm_overlay",
force = game.forces.neutral,
position = pos }
overlay.minable = false
overlay.destructible = false
overlay.operable = false
local overlay = rendering.draw_rectangle {
left_top = { math.floor(pos.x), math.floor(pos.y) },
right_bottom = { math.floor(pos.x+1), math.floor(pos.y+1) },
filled = true,
color = { 0, 0, 0.5, 0.4 },
surface = surface,
draw_on_ground = true,
}
table.insert(player_data.overlays, overlay)
end

Expand Down

0 comments on commit 3dc6cba

Please sign in to comment.