turf
receive_edge(tile_icon = edge_icon, tile_state, tile_weight, tile_direction)
var/image/overlay_image = image(tile_icon, tile_state, layer = TURF_LAYER + 0.01 * tile_weight, dir = tile_direction)
var
icon/current = icon(src.icon, src.icon_state)
icon/overlay = icon(overlay_image.icon, overlay_image.icon_state, overlay_image.dir)
/*
// world << "CURRENT DIR: [getdir(src.dir)]"
// world << "IMAGE DIR: [getdir(edge_overlay_image.dir)]"
// world << "TILE ICON: [tile_icon]"
// world << "TILE STATE: [tile_state]"
world << "<font size = +1>[++indice]"
world << "SRC: \icon[icon]"
world << "CURRENT: \icon[current]"
world << "OVERLAY: \icon[overlay]"
*/
current.Blend(overlay, ICON_OVERLAY)
src.icon = current
generate_cardinal_edge()
if(edged || !requires_edges) return NULL
var/north = needs_edging(get_step(src, NORTH))
var/south = needs_edging(get_step(src, SOUTH))
var/east = needs_edging(get_step(src, EAST))
var/west = needs_edging(get_step(src, WEST))
if(north)
north = get_step(src, NORTH)
north:receive_edge(edge_icon, get_edge_clash_state(src, north), weight, NORTH)
if(south)
south = get_step(src, SOUTH)
south:receive_edge(edge_icon, get_edge_clash_state(src, south), weight, SOUTH)
if(east)
east = get_step(src, EAST)
east:receive_edge(edge_icon, get_edge_clash_state(src, east), weight, EAST)
if(west)
west = get_step(src, WEST)
west:receive_edge(edge_icon, get_edge_clash_state(src, west), weight, WEST)
edged = 1
Problem description:
What this piece of code is supposed to do, is basically neighboring tiles around src and, if compatible, combine the necessary edge graphic with src's icon. It works fine until you get another tile that needs its edged applied nearby. For example:
x = dirt
y = grass
1 --- x-x-x-x-x-x-x
2 --- x-x-y-x-y-x-x
3 --- x-x-x-x-x-x-x
----- 1 2 3 4 5 6 7
I can call generative_cardinal_edges() for the grass tile at 3, 2 and it works fine, but if I go ahead and call said function for the grass tile at 5, 2, the dirt tile at 4, 2 will refresh as if I did not call its Blend(icon, ICON_OVERLAY) (so in essence the icon gets rid of the previous edge overlay and places the new, when it's supposed to overlay the new on top and keep both).
The debug messages in the code output everything I need to know, and surprisingly I'm not seeing anything out of the ordinary. It just seems like Blend() isn't working correctly, though I know it works, because I did this same thing yesterday and got it to work, but I don't remember exactly what I did (I overwrote the code on accident when writing this).
Thanks for any help. I've been trying to figure out the issue all day now, and I'm more than positive it's something simple.