Subsystem created... works!

This commit is contained in:
Purpose
2018-10-06 20:05:02 +01:00
parent bc67a1e39d
commit d335a5a4ce
15 changed files with 95 additions and 54 deletions
+46 -30
View File
@@ -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"
+24
View File
@@ -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
..()
+3 -3
View File
@@ -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()
+2 -2
View File
@@ -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)
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)
+2 -2
View File
@@ -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()
+3 -3
View File
@@ -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
glass_amount = 2
+1 -1
View File
@@ -85,6 +85,6 @@
/turf/simulated/ChangeTurf(var/path)
. = ..()
smooth_icon_neighbors(src)
queue_smooth_neighbors(src)
/turf/simulated/proc/is_shielded()
@@ -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
+1 -1
View File
@@ -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]
@@ -65,7 +65,7 @@
d_state = RWALL_INTACT
update_icon()
smooth_icon_neighbors(src)
queue_smooth_neighbors(src)
to_chat(user, "<span class='notice'>You repair the last of the damage.</span>")
return TRUE
@@ -84,7 +84,7 @@
to_chat(user, "<span class='notice'>You add an additional layer of coating to the wall.</span>")
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
+4 -4
View File
@@ -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
return TRUE
+2 -2
View File
@@ -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()
+1 -1
View File
@@ -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)
. = ..()
+1 -1
View File
@@ -15,5 +15,5 @@
/obj/effect/temp_visual/ripple/New()
. = ..()
smooth_icon(src)
queue_smooth(src)
animate(src, alpha=255, time=SHUTTLE_RIPPLE_TIME)
+1
View File
@@ -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"