mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-24 09:02:27 +00:00
Wall Icon Refactor (#3023)
changes: Atom types can now define custom adjacency code for the smoothing system. Walls now draw using the generic icon smoothing system. Walls now pre-bake colors into their icons instead of doing it client-side with the color var. Walls can now use the SSoverlay appearance cache; wall icon updates should be faster. The "rusty" wall type now actually works. Smoothing now uses mutable_appearance instead of image in some places. Should be a bit easier on clients, though I haven't done profiling. This PR breaks 510 compatibility.
This commit is contained in:
@@ -11,6 +11,9 @@
|
||||
material = get_material_by_name(DEFAULT_WALL_MATERIAL)
|
||||
if(material)
|
||||
explosion_resistance = material.explosion_resistance
|
||||
if (material.wall_icon)
|
||||
icon = material.wall_icon
|
||||
|
||||
if(reinf_material && reinf_material.explosion_resistance > explosion_resistance)
|
||||
explosion_resistance = reinf_material.explosion_resistance
|
||||
|
||||
@@ -26,10 +29,8 @@
|
||||
else if(material.opacity < 0.5 && opacity)
|
||||
set_light(0)
|
||||
|
||||
update_connections(1)
|
||||
update_icon()
|
||||
|
||||
|
||||
/turf/simulated/wall/proc/set_material(var/material/newmaterial, var/material/newrmaterial)
|
||||
material = newmaterial
|
||||
reinf_material = newrmaterial
|
||||
@@ -42,37 +43,43 @@
|
||||
if(!damage_overlays[1]) //list hasn't been populated
|
||||
generate_overlays()
|
||||
|
||||
cut_overlays()
|
||||
var/list/cutlist = (reinforcement_images||list()) + damage_image
|
||||
cut_overlay(cutlist, TRUE)
|
||||
LAZYCLEARLIST(reinforcement_images)
|
||||
damage_image = null
|
||||
|
||||
var/list/overlays_to_add = list()
|
||||
var/image/I
|
||||
|
||||
if(!density)
|
||||
I = image('icons/turf/wall_masks.dmi', "[material.icon_base]fwall_open")
|
||||
I.color = material.icon_colour
|
||||
add_overlay(I)
|
||||
if (!density) // We're a fake and we're open.
|
||||
clear_smooth_overlays()
|
||||
fake_wall_image = image('icons/turf/wall_masks.dmi', "[material.icon_base]fwall_open")
|
||||
fake_wall_image.color = material.icon_colour
|
||||
add_overlay(fake_wall_image)
|
||||
smooth = SMOOTH_FALSE
|
||||
return
|
||||
else if (fake_wall_image)
|
||||
cut_overlay(fake_wall_image)
|
||||
fake_wall_image = null
|
||||
smooth = initial(smooth)
|
||||
|
||||
for(var/i = 1 to 4)
|
||||
I = image('icons/turf/wall_masks.dmi', "[material.icon_base][wall_connections[i]]", dir = 1<<(i-1))
|
||||
I.color = material.icon_colour
|
||||
overlays_to_add += I
|
||||
calculate_adjacencies() // Update cached_adjacency
|
||||
|
||||
if(reinf_material)
|
||||
var/image/I
|
||||
if(construction_stage != null && construction_stage < 6)
|
||||
I = image('icons/turf/wall_masks.dmi', "reinf_construct-[construction_stage]")
|
||||
I.color = reinf_material.icon_colour
|
||||
overlays_to_add += I
|
||||
LAZYADD(reinforcement_images, I)
|
||||
else
|
||||
if("[reinf_material.icon_reinf]0" in icon_states('icons/turf/wall_masks.dmi'))
|
||||
// Directional icon
|
||||
for(var/i = 1 to 4)
|
||||
I = image('icons/turf/wall_masks.dmi', "[reinf_material.icon_reinf][wall_connections[i]]", dir = 1<<(i-1))
|
||||
I.color = reinf_material.icon_colour
|
||||
overlays_to_add += I
|
||||
if (reinf_material.multipart_reinf_icon)
|
||||
LAZYADD(reinforcement_images, cardinal_smooth_fromicon(reinf_material.multipart_reinf_icon, cached_adjacency))
|
||||
else
|
||||
I = image('icons/turf/wall_masks.dmi', reinf_material.icon_reinf)
|
||||
I.color = reinf_material.icon_colour
|
||||
overlays_to_add += I
|
||||
LAZYADD(reinforcement_images, I)
|
||||
|
||||
if (reinforcement_images)
|
||||
overlays_to_add += reinforcement_images
|
||||
|
||||
if(damage != 0)
|
||||
var/integrity = material.integrity
|
||||
@@ -83,9 +90,12 @@
|
||||
if(overlay > damage_overlays.len)
|
||||
overlay = damage_overlays.len
|
||||
|
||||
overlays_to_add += damage_overlays[overlay]
|
||||
damage_image = damage_overlays[overlay]
|
||||
overlays_to_add += damage_image
|
||||
|
||||
add_overlay(overlays_to_add)
|
||||
add_overlay(overlays_to_add, TRUE)
|
||||
UNSETEMPTY(reinforcement_images)
|
||||
queue_smooth(src)
|
||||
|
||||
/turf/simulated/wall/proc/generate_overlays()
|
||||
var/alpha_inc = 256 / damage_overlays.len
|
||||
@@ -96,23 +106,50 @@
|
||||
img.alpha = (i * alpha_inc) - 1
|
||||
damage_overlays[i] = img
|
||||
|
||||
|
||||
/turf/simulated/wall/proc/update_connections(propagate = 0)
|
||||
if(!material)
|
||||
/turf/simulated/wall/calculate_adjacencies()
|
||||
. = 0
|
||||
if (!loc || !material)
|
||||
return
|
||||
var/list/dirs = list()
|
||||
for(var/turf/simulated/wall/W in orange(src, 1))
|
||||
if(!W.material)
|
||||
continue
|
||||
if(propagate)
|
||||
W.update_connections()
|
||||
W.update_icon()
|
||||
if(can_join_with(W))
|
||||
dirs += get_dir(src, W)
|
||||
|
||||
wall_connections = dirs_to_corner_states(dirs)
|
||||
var/turf/simulated/wall/W
|
||||
var/material/M
|
||||
var/our_icon_base = material.icon_base
|
||||
|
||||
/turf/simulated/wall/proc/can_join_with(var/turf/simulated/wall/W)
|
||||
if(material && W.material && material.icon_base == W.material.icon_base)
|
||||
return 1
|
||||
return 0
|
||||
for (var/dir in cardinal)
|
||||
W = get_step(src, dir)
|
||||
if (istype(W) && (W.smooth || !W.density))
|
||||
M = W.material
|
||||
if (M && M.icon_base == our_icon_base)
|
||||
. |= 1 << dir
|
||||
|
||||
if (. & N_NORTH)
|
||||
if (. & N_WEST)
|
||||
W = get_step(src, NORTHWEST)
|
||||
if (istype(W) && (W.smooth || !W.density))
|
||||
M = W.material
|
||||
if (M && M.icon_base == our_icon_base)
|
||||
. |= N_NORTHWEST
|
||||
|
||||
if (. & N_EAST)
|
||||
W = get_step(src, NORTHEAST)
|
||||
if (istype(W) && (W.smooth || !W.density))
|
||||
M = W.material
|
||||
if (M && M.icon_base == our_icon_base)
|
||||
. |= N_NORTHEAST
|
||||
|
||||
if (. & N_SOUTH)
|
||||
if (. & N_WEST)
|
||||
W = get_step(src, SOUTHWEST)
|
||||
if (istype(W) && (W.smooth || !W.density))
|
||||
M = W.material
|
||||
if (M && M.icon_base == our_icon_base)
|
||||
. |= N_SOUTHWEST
|
||||
|
||||
if (. & N_EAST)
|
||||
W = get_step(src, SOUTHEAST)
|
||||
if (istype(W) && (W.smooth || !W.density))
|
||||
M = W.material
|
||||
if (M && M.icon_base == our_icon_base)
|
||||
. |= N_SOUTHEAST
|
||||
|
||||
cached_adjacency = .
|
||||
|
||||
@@ -19,7 +19,12 @@
|
||||
var/last_state
|
||||
var/construction_stage
|
||||
|
||||
var/list/wall_connections = list("0", "0", "0", "0")
|
||||
var/tmp/list/image/reinforcement_images
|
||||
var/tmp/image/damage_image
|
||||
var/tmp/image/fake_wall_image
|
||||
var/tmp/cached_adjacency
|
||||
|
||||
smooth = SMOOTH_TRUE | SMOOTH_NO_CLEAR_ICON
|
||||
|
||||
// Walls always hide the stuff below them.
|
||||
/turf/simulated/wall/levelupdate(mapload)
|
||||
@@ -178,7 +183,6 @@
|
||||
clear_plants()
|
||||
material = get_material_by_name("placeholder")
|
||||
reinf_material = null
|
||||
update_connections(1)
|
||||
|
||||
if (!no_change)
|
||||
ChangeTurf(/turf/simulated/floor/plating)
|
||||
|
||||
@@ -81,9 +81,7 @@
|
||||
..()
|
||||
return QDEL_HINT_IWILLGC
|
||||
|
||||
// This should be using mutable_appearance, but 510. Woe.
|
||||
// Update this & all overrides if/when we move to 511.
|
||||
/turf/proc/get_smooth_underlay_icon(image/underlay_appearance, turf/asking_turf, adjacency_dir)
|
||||
/turf/proc/get_smooth_underlay_icon(mutable_appearance/underlay_appearance, turf/asking_turf, adjacency_dir)
|
||||
underlay_appearance.icon = icon
|
||||
underlay_appearance.icon_state = icon_state
|
||||
underlay_appearance.dir = adjacency_dir
|
||||
|
||||
Reference in New Issue
Block a user