diff --git a/code/__HELPERS/icon_smoothing.dm b/code/__HELPERS/icon_smoothing.dm
index 27ec6e7202f..1bb7fe939c1 100644
--- a/code/__HELPERS/icon_smoothing.dm
+++ b/code/__HELPERS/icon_smoothing.dm
@@ -111,12 +111,15 @@
/proc/smooth_icon(atom/A)
if(QDELETED(A))
return
- if(A && (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)
+ 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)
+ A.diagonal_smooth(adjacencies)
+ else
+ cardinal_smooth(A, adjacencies)
/atom/proc/diagonal_smooth(adjacencies)
switch(adjacencies)
@@ -244,23 +247,11 @@
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
+
if(source.canSmoothWith)
var/atom/A
if(source.smooth & SMOOTH_MORE)
@@ -287,22 +278,22 @@
//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)
+/proc/smooth_zlevel(var/zlevel, now = FALSE)
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)
+ if(now)
+ smooth_icon(T)
+ else
+ queue_smooth(T)
for(var/R in T)
var/atom/A = R
if(A.smooth)
- smooth_icon(A)
+ if(now)
+ smooth_icon(A)
+ else
+ queue_smooth(A)
/atom/proc/clear_smooth_overlays()
overlays -= top_left_corner
@@ -362,6 +353,31 @@
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"
diff --git a/code/controllers/subsystem/icon_smooth.dm b/code/controllers/subsystem/icon_smooth.dm
new file mode 100644
index 00000000000..568157baebb
--- /dev/null
+++ b/code/controllers/subsystem/icon_smooth.dm
@@ -0,0 +1,24 @@
+var/datum/controller/subsystem/icon_smooth/SSicon_smooth
+
+/datum/controller/subsystem/icon_smooth
+ name = "Icon Smoothing"
+ priority = -5
+ wait = 5
+ var/list/smooth_queue = list()
+
+/datum/controller/subsystem/icon_smooth/New()
+ NEW_SS_GLOBAL(SSicon_smooth)
+
+/datum/controller/subsystem/icon_smooth/fire()
+ for(var/atom in smooth_queue)
+ ss_smooth_icon(atom)
+ smooth_queue -= atom
+
+/datum/controller/subsystem/icon_smooth/Initialize()
+ smooth_zlevel(1,TRUE)
+ smooth_zlevel(2,TRUE)
+ for(var/V in smooth_queue)
+ var/atom/A = V
+ if(A.z == 1 || A.z == 2)
+ smooth_queue -= A
+ ..()
diff --git a/code/game/objects/structures.dm b/code/game/objects/structures.dm
index 00860477833..b9b34220549 100644
--- a/code/game/objects/structures.dm
+++ b/code/game/objects/structures.dm
@@ -32,8 +32,8 @@
..()
if(smooth)
if(ticker && ticker.current_state == GAME_STATE_PLAYING)
- smooth_icon(src)
- smooth_icon_neighbors(src)
+ queue_smooth(src)
+ queue_smooth_neighbors(src)
icon_state = ""
if(climbable)
verbs += /obj/structure/proc/climb_on
@@ -46,7 +46,7 @@
if(smooth)
var/turf/T = get_turf(src)
spawn(0)
- smooth_icon_neighbors(T)
+ queue_smooth_neighbors(T)
return ..()
/obj/structure/proc/climb_on()
diff --git a/code/game/objects/structures/false_walls.dm b/code/game/objects/structures/false_walls.dm
index 31239a5ecb4..98d17d71be9 100644
--- a/code/game/objects/structures/false_walls.dm
+++ b/code/game/objects/structures/false_walls.dm
@@ -82,7 +82,7 @@
if(density)
icon_state = initial(icon_state)
smooth = SMOOTH_TRUE
- smooth_icon(src)
+ queue_smooth(src)
else
icon_state = "fwall_open"
@@ -322,4 +322,4 @@
mineral = /obj/item/stack/sheet/mineral/plastitanium
walltype = /turf/simulated/wall/mineral/plastitanium
smooth = SMOOTH_MORE
- canSmoothWith = list(/turf/simulated/wall/mineral/plastitanium, /obj/machinery/door/airlock/shuttle, /obj/machinery/door/airlock, /obj/structure/window/full/shuttle, /obj/structure/shuttle/engine/heater)
\ No newline at end of file
+ canSmoothWith = list(/turf/simulated/wall/mineral/plastitanium, /obj/machinery/door/airlock/shuttle, /obj/machinery/door/airlock, /obj/structure/window/full/shuttle, /obj/structure/shuttle/engine/heater)
diff --git a/code/game/objects/structures/tables_racks.dm b/code/game/objects/structures/tables_racks.dm
index 91f348d0106..7554b7ae194 100644
--- a/code/game/objects/structures/tables_racks.dm
+++ b/code/game/objects/structures/tables_racks.dm
@@ -50,8 +50,8 @@
/obj/structure/table/update_icon()
if(smooth && !flipped)
icon_state = ""
- smooth_icon(src)
- smooth_icon_neighbors(src)
+ queue_smooth(src)
+ queue_smooth_neighbors(src)
if(flipped)
clear_smooth_overlays()
diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm
index 25c78f6e972..b103d44ae7e 100644
--- a/code/game/objects/structures/window.dm
+++ b/code/game/objects/structures/window.dm
@@ -425,7 +425,7 @@ var/global/wcCommon = pick(list("#379963", "#0d8395", "#58b5c3", "#49e46e", "#8f
/obj/structure/window/proc/update_nearby_icons()
update_icon()
if(smooth)
- smooth_icon_neighbors(src)
+ queue_smooth_neighbors(src)
/obj/structure/window/update_icon()
if(!QDELETED(src))
@@ -434,7 +434,7 @@ var/global/wcCommon = pick(list("#379963", "#0d8395", "#58b5c3", "#49e46e", "#8f
var/ratio = obj_integrity / max_integrity
ratio = CEILING(ratio*4, 1) * 25
if(smooth)
- smooth_icon(src)
+ queue_smooth(src)
overlays -= crack_overlay
if(ratio > 75)
return
@@ -714,4 +714,4 @@ obj/structure/window/full/reinforced/ice
dir = FULLTILE_WINDOW_DIR
max_integrity = 120
level = 3
- glass_amount = 2
\ No newline at end of file
+ glass_amount = 2
diff --git a/code/game/turfs/simulated.dm b/code/game/turfs/simulated.dm
index fedbfaa5929..21dbdb9e024 100644
--- a/code/game/turfs/simulated.dm
+++ b/code/game/turfs/simulated.dm
@@ -85,6 +85,6 @@
/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 0121daf3ee4..0e8d8e13f8f 100644
--- a/code/game/turfs/simulated/floor/fancy_floor.dm
+++ b/code/game/turfs/simulated/floor/fancy_floor.dm
@@ -131,11 +131,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.dm b/code/game/turfs/simulated/walls.dm
index a24e6f2953f..8e3952ea42f 100644
--- a/code/game/turfs/simulated/walls.dm
+++ b/code/game/turfs/simulated/walls.dm
@@ -72,7 +72,7 @@
if(!damage_overlays[1]) //list hasn't been populated
generate_overlays()
- smooth_icon(src)
+ queue_smooth(src)
if(!damage)
if(damage_overlay)
overlays -= damage_overlays[damage_overlay]
diff --git a/code/game/turfs/simulated/walls_reinforced.dm b/code/game/turfs/simulated/walls_reinforced.dm
index eb054ba19ed..f1837173d6d 100644
--- a/code/game/turfs/simulated/walls_reinforced.dm
+++ b/code/game/turfs/simulated/walls_reinforced.dm
@@ -65,7 +65,7 @@
d_state = RWALL_INTACT
update_icon()
- smooth_icon_neighbors(src)
+ queue_smooth_neighbors(src)
to_chat(user, "You repair the last of the damage.")
return TRUE
@@ -84,7 +84,7 @@
to_chat(user, "You add an additional layer of coating to the wall.")
ChangeTurf(/turf/simulated/wall/r_wall/coated)
update_icon()
- smooth_icon_neighbors(src)
+ queue_smooth_neighbors(src)
can_be_reinforced = FALSE
return TRUE
return FALSE
diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm
index 012d270005a..d7ed44c3c9a 100644
--- a/code/game/turfs/turf.dm
+++ b/code/game/turfs/turf.dm
@@ -39,18 +39,18 @@
for(var/atom/movable/AM in src)
Entered(AM)
if(smooth && ticker && ticker.current_state == GAME_STATE_PLAYING)
- smooth_icon(src)
+ queue_smooth(src)
/hook/startup/proc/smooth_world()
var/watch = start_watch()
log_startup_progress("Smoothing atoms...")
for(var/turf/T in world)
if(T.smooth)
- smooth_icon(T)
+ queue_smooth(T)
for(var/A in T)
var/atom/AA = A
if(AA.smooth)
- smooth_icon(AA)
+ queue_smooth(AA)
log_startup_progress(" Smoothed atoms in [stop_watch(watch)]s.")
return 1
@@ -477,4 +477,4 @@
SSair.add_to_active(T0,1)
/turf/AllowDrop()
- return TRUE
\ No newline at end of file
+ return TRUE
diff --git a/code/modules/awaymissions/zlevel.dm b/code/modules/awaymissions/zlevel.dm
index c0bc96489b4..f6da9d0347f 100644
--- a/code/modules/awaymissions/zlevel.dm
+++ b/code/modules/awaymissions/zlevel.dm
@@ -17,11 +17,11 @@ var/global/list/potentialRandomZlevels = generateMapList(filename = "config/away
log_debug("Smoothing tiles")
for(var/turf/T in smoothTurfs)
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)
if(istype(T, /turf/simulated/mineral)) // For the listening post, among other maps
var/turf/simulated/mineral/MT = T
MT.add_edges()
diff --git a/code/modules/shuttle/on_move.dm b/code/modules/shuttle/on_move.dm
index 88551f49096..4a587ac1253 100644
--- a/code/modules/shuttle/on_move.dm
+++ b/code/modules/shuttle/on_move.dm
@@ -52,7 +52,7 @@
// After docking //
/atom/proc/postDock(obj/docking_port/S1)
if(smooth)
- smooth_icon(src)
+ queue_smooth(src)
/obj/machinery/door/airlock/postDock(obj/docking_port/stationary/S1)
. = ..()
diff --git a/code/modules/shuttle/ripple.dm b/code/modules/shuttle/ripple.dm
index 3489394671b..591420ddd60 100644
--- a/code/modules/shuttle/ripple.dm
+++ b/code/modules/shuttle/ripple.dm
@@ -15,5 +15,5 @@
/obj/effect/temp_visual/ripple/New()
. = ..()
- smooth_icon(src)
+ queue_smooth(src)
animate(src, alpha=255, time=SHUTTLE_RIPPLE_TIME)
diff --git a/paradise.dme b/paradise.dme
index de38b9a410d..cc0b9a23676 100644
--- a/paradise.dme
+++ b/paradise.dme
@@ -204,6 +204,7 @@
#include "code\controllers\subsystem\atoms.dm"
#include "code\controllers\subsystem\fires.dm"
#include "code\controllers\subsystem\garbage.dm"
+#include "code\controllers\subsystem\icon_smooth.dm"
#include "code\controllers\subsystem\machinery.dm"
#include "code\controllers\subsystem\mobs.dm"
#include "code\controllers\subsystem\nano_mob_hunter.dm"