diff --git a/code/__HELPERS/icon_smoothing.dm b/code/__HELPERS/icon_smoothing.dm index 5651e82e70b..beadb3c0ce5 100644 --- a/code/__HELPERS/icon_smoothing.dm +++ b/code/__HELPERS/icon_smoothing.dm @@ -111,8 +111,10 @@ /proc/smooth_icon(atom/A) if(qdeleted(A)) return - spawn(0) //don't remove this, otherwise smoothing breaks - if(A && (A.smooth & SMOOTH_TRUE) || (A.smooth & SMOOTH_MORE)) + if(!A || !A.smooth) + return + spawn(0) + if((A.smooth & SMOOTH_TRUE) || (A.smooth & SMOOTH_MORE)) var/adjacencies = calculate_adjacencies(A) if(A.smooth & SMOOTH_DIAGONAL) @@ -244,21 +246,8 @@ A.bottom_left_corner = se A.overlays += se -/proc/find_type_in_direction(atom/source, direction, range=1) - var/x_offset = 0 - var/y_offset = 0 - - if(direction & NORTH) - y_offset = range - else if(direction & SOUTH) - y_offset -= range - - if(direction & EAST) - x_offset = range - else if(direction & WEST) - x_offset -= range - - var/turf/target_turf = locate(source.x + x_offset, source.y + y_offset, source.z) +/proc/find_type_in_direction(atom/source, direction) + var/turf/target_turf = get_step(source, direction) if(!target_turf) return NULLTURF_BORDER @@ -287,23 +276,16 @@ return A && A.type == source.type ? A : null //Icon smoothing helpers - -/proc/smooth_icon_neighbors(atom/A) - for(var/V in orange(1,A)) - var/atom/T = V - if(T.smooth) - smooth_icon(T) - /proc/smooth_zlevel(var/zlevel) var/list/away_turfs = block(locate(1, 1, zlevel), locate(world.maxx, world.maxy, zlevel)) for(var/V in away_turfs) var/turf/T = V if(T.smooth) - smooth_icon(T) + queue_smooth(T) for(var/R in T) var/atom/A = R if(A.smooth) - smooth_icon(A) + queue_smooth(A) /atom/proc/clear_smooth_overlays() overlays -= top_left_corner @@ -363,6 +345,33 @@ else return 0 +//SSicon_smooth +/proc/ss_smooth_icon(atom/A) + if(qdeleted(A)) + return + if(!istype(A) || (A && !A.smooth)) + return + if((A.smooth & SMOOTH_TRUE) || (A.smooth & SMOOTH_MORE)) + var/adjacencies = calculate_adjacencies(A) + if(A.smooth & SMOOTH_DIAGONAL) + A.diagonal_smooth(adjacencies) + else + cardinal_smooth(A, adjacencies) + +//SSicon_smooth +/proc/queue_smooth_neighbors(atom/A) + for(var/V in orange(1,A)) + var/atom/T = V + if(T.smooth) + queue_smooth(T) + +//SSicon_smooth +/proc/queue_smooth(atom/A) + if(SSicon_smooth) + SSicon_smooth.smooth_queue |= A + else + smooth_icon(A) + //Example smooth wall /turf/simulated/wall/smooth name = "smooth wall" @@ -370,4 +379,4 @@ icon_state = "smooth" walltype = "shuttle" smooth = SMOOTH_TRUE|SMOOTH_DIAGONAL|SMOOTH_BORDER - canSmoothWith = null \ No newline at end of file + canSmoothWith = null diff --git a/code/controllers/subsystem/icon_smooth.dm b/code/controllers/subsystem/icon_smooth.dm new file mode 100644 index 00000000000..4a06f7d602a --- /dev/null +++ b/code/controllers/subsystem/icon_smooth.dm @@ -0,0 +1,15 @@ +var/datum/subsystem/icon_smooth/SSicon_smooth + +/datum/subsystem/icon_smooth + name = "Icon Smoothing" + priority = -5 + wait = 5 + var/list/smooth_queue = list() + +/datum/subsystem/icon_smooth/New() + NEW_SS_GLOBAL(SSicon_smooth) + +/datum/subsystem/icon_smooth/fire() + for(var/atom in smooth_queue) + ss_smooth_icon(atom) + smooth_queue -= atom diff --git a/code/game/objects/structures.dm b/code/game/objects/structures.dm index b94f10a3805..b50ae5e49a5 100644 --- a/code/game/objects/structures.dm +++ b/code/game/objects/structures.dm @@ -5,8 +5,8 @@ /obj/structure/New() ..() if(smooth) - smooth_icon(src) - smooth_icon_neighbors(src) + queue_smooth(src) + queue_smooth_neighbors(src) icon_state = "" if(ticker) cameranet.updateVisibility(src) @@ -23,7 +23,7 @@ if(opacity) UpdateAffectingLights() if(smooth) - smooth_icon_neighbors(src) + queue_smooth_neighbors(src) return ..() /obj/structure/mech_melee_attack(obj/mecha/M) diff --git a/code/game/objects/structures/false_walls.dm b/code/game/objects/structures/false_walls.dm index 6fb3e3cb3bc..97de9e90419 100644 --- a/code/game/objects/structures/false_walls.dm +++ b/code/game/objects/structures/false_walls.dm @@ -59,7 +59,7 @@ /obj/structure/falsewall/update_icon()//Calling icon_update will refresh the smoothwalls if it's closed, otherwise it will make sure the icon is correct if it's open if(density) smooth = SMOOTH_TRUE - smooth_icon(src) + queue_smooth(src) icon_state = "" else icon_state = "fwall_open" diff --git a/code/game/objects/structures/tables_racks.dm b/code/game/objects/structures/tables_racks.dm index bb3b7a2612f..16e3c80c08a 100644 --- a/code/game/objects/structures/tables_racks.dm +++ b/code/game/objects/structures/tables_racks.dm @@ -40,8 +40,8 @@ /obj/structure/table/update_icon() if(smooth) - smooth_icon(src) - smooth_icon_neighbors(src) + queue_smooth(src) + queue_smooth_neighbors(src) /obj/structure/table/ex_act(severity, target) switch(severity) diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm index 2e557ebd49b..1ef80fd670c 100644 --- a/code/game/objects/structures/window.dm +++ b/code/game/objects/structures/window.dm @@ -398,7 +398,7 @@ /obj/structure/window/proc/update_nearby_icons() update_icon() if(smooth) - smooth_icon_neighbors(src) + queue_smooth_neighbors(src) //merges adjacent full-tile windows into one (blatant ripoff from game/smoothwall.dm) /obj/structure/window/update_icon() @@ -414,7 +414,7 @@ ratio = Ceiling(ratio*4) * 25 if(smooth) - smooth_icon(src) + queue_smooth(src) overlays -= crack_overlay if(ratio > 75) diff --git a/code/game/turfs/simulated.dm b/code/game/turfs/simulated.dm index fe7351ac84b..87e2b33d782 100644 --- a/code/game/turfs/simulated.dm +++ b/code/game/turfs/simulated.dm @@ -59,7 +59,7 @@ /turf/simulated/ChangeTurf(var/path) . = ..() - smooth_icon_neighbors(src) + queue_smooth_neighbors(src) /turf/simulated/proc/is_shielded() diff --git a/code/game/turfs/simulated/floor/fancy_floor.dm b/code/game/turfs/simulated/floor/fancy_floor.dm index 2fe7f8d8724..c980f36b361 100644 --- a/code/game/turfs/simulated/floor/fancy_floor.dm +++ b/code/game/turfs/simulated/floor/fancy_floor.dm @@ -63,11 +63,11 @@ return 0 if(!broken && !burnt) if(smooth) - smooth_icon(src) + queue_smooth(src) else make_plating() if(smooth) - smooth_icon_neighbors(src) + queue_smooth_neighbors(src) /turf/simulated/floor/carpet/break_tile() broken = 1 diff --git a/code/game/turfs/simulated/walls_reinforced.dm b/code/game/turfs/simulated/walls_reinforced.dm index 15957c579be..799596b589d 100644 --- a/code/game/turfs/simulated/walls_reinforced.dm +++ b/code/game/turfs/simulated/walls_reinforced.dm @@ -55,7 +55,7 @@ MS.use(1) src.d_state = 0 src.icon_state = "r_wall" - smooth_icon_neighbors(src) + queue_smooth_neighbors(src) user << "You repair the last of the damage." return 1 return 0 diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index fb70f577b3e..0c48002ac79 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -311,7 +311,7 @@ /turf/indestructible/riveted/New() ..() if(smooth) - smooth_icon(src) + queue_smooth(src) icon_state = "" /turf/indestructible/riveted/uranium diff --git a/code/modules/atmospherics/environmental/LINDA_turf_tile.dm b/code/modules/atmospherics/environmental/LINDA_turf_tile.dm index beb5a6071eb..671e8eec9bc 100644 --- a/code/modules/atmospherics/environmental/LINDA_turf_tile.dm +++ b/code/modules/atmospherics/environmental/LINDA_turf_tile.dm @@ -44,7 +44,7 @@ ..() levelupdate() if(smooth) - smooth_icon(src) + queue_smooth(src) visibilityChanged() if(!blocks_air) air = new diff --git a/code/modules/holodeck/turfs.dm b/code/modules/holodeck/turfs.dm index c8ef40a0d72..d0f67e42c7a 100644 --- a/code/modules/holodeck/turfs.dm +++ b/code/modules/holodeck/turfs.dm @@ -82,4 +82,4 @@ if(!..()) return 0 if(intact) - smooth_icon(src) + queue_smooth(src) diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm index bfe72e9e3f3..ab941f3445b 100644 --- a/code/modules/shuttle/shuttle.dm +++ b/code/modules/shuttle/shuttle.dm @@ -282,7 +282,7 @@ //resmooth if need be. if(smooth) - smooth_icon(src) + queue_smooth(src) //rotate the pixel offsets too. if (pixel_x || pixel_y) diff --git a/tgstation.dme b/tgstation.dme index 60525204c9f..df9f0335387 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -127,6 +127,7 @@ #include "code\controllers\subsystem\diseases.dm" #include "code\controllers\subsystem\events.dm" #include "code\controllers\subsystem\garbage.dm" +#include "code\controllers\subsystem\icon_smooth.dm" #include "code\controllers\subsystem\jobs.dm" #include "code\controllers\subsystem\lighting.dm" #include "code\controllers\subsystem\machines.dm"