diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index 17b6f9e55c8..b8c0f3d02f4 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -181,12 +181,6 @@ About the new airlock wires panel: /obj/machinery/door/airlock/bumpopen(mob/living/simple_animal/user) ..(user) -/obj/machinery/door/airlock/autoclose() - autoclose_timer = 0 - if(!QDELETED(src) && !density && !operating && !locked && !welded && autoclose) - close() - return - /obj/machinery/door/airlock/proc/isElectrified() if(electrified_until != 0) return 1 @@ -645,7 +639,7 @@ About the new airlock wires panel: add_overlay(I) else set_light(0) - + /obj/machinery/door/airlock/CanPass(atom/movable/mover, turf/target, height=0) if(isElectrified() && density && istype(mover, /obj/item)) var/obj/item/I = mover @@ -1103,6 +1097,10 @@ About the new airlock wires panel: playsound(loc, doorOpen, 30, 1) if(closeOther != null && istype(closeOther, /obj/machinery/door/airlock/) && !closeOther.density) closeOther.close() + + if(autoclose) + autoclose_in(normalspeed ? auto_close_time : auto_close_time_dangerous) + if(!density) return TRUE operating = TRUE @@ -1117,10 +1115,6 @@ About the new airlock wires panel: layer = OPEN_DOOR_LAYER update_icon(AIRLOCK_OPEN, 1) operating = FALSE - - // The `addtimer` system has the advantage of being cancelable - if(autoclose) - autoclose_timer = addtimer(CALLBACK(src, .proc/autoclose), normalspeed ? auto_close_time : auto_close_time_dangerous, TIMER_UNIQUE | TIMER_STOPPABLE) return TRUE /obj/machinery/door/airlock/close(forced=0, override = 0) @@ -1137,7 +1131,8 @@ About the new airlock wires panel: for(var/turf/turf in locs) for(var/atom/movable/M in turf) if(M.density && M != src) //something is blocking the door - addtimer(CALLBACK(src, .proc/autoclose), 60) + autoclose_in(60) + return use_power(360) //360 W seems much more appropriate for an actuator moving an industrial door capable of crushing people if(forced) diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index fdfaae71477..17116b5249b 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -14,14 +14,13 @@ var/visible = 1 var/operating = FALSE var/autoclose = 0 - var/autoclose_timer var/safe = TRUE //whether the door detects things and mobs in its way and reopen or crushes them. var/locked = FALSE //whether the door is bolted or not. var/glass = FALSE var/welded = FALSE var/normalspeed = 1 var/auto_close_time = 150 - var/auto_close_time_dangerous = 5 + var/auto_close_time_dangerous = 15 var/assemblytype //the type of door frame to drop during deconstruction var/datum/effect_system/spark_spread/spark_system var/damage_deflection = 10 @@ -77,9 +76,6 @@ air_update_turf(1) update_freelook_sight() GLOB.airlocks -= src - if(autoclose_timer) - deltimer(autoclose_timer) - autoclose_timer = 0 QDEL_NULL(spark_system) return ..() @@ -187,7 +183,7 @@ /obj/machinery/door/proc/unrestricted_side(mob/M) //Allows for specific side of airlocks to be unrestrected (IE, can exit maint freely, but need access to enter) return get_dir(src, M) & unres_sides - + /obj/machinery/door/proc/try_to_weld(obj/item/weldingtool/W, mob/user) return @@ -282,11 +278,8 @@ operating = FALSE air_update_turf(1) update_freelook_sight() - - // The `addtimer` system has the advantage of being cancelable if(autoclose) - autoclose_timer = addtimer(CALLBACK(src, .proc/autoclose), normalspeed ? auto_close_time : auto_close_time_dangerous, TIMER_UNIQUE | TIMER_STOPPABLE) - + addtimer(CALLBACK(src, .proc/close), autoclose) return TRUE /obj/machinery/door/proc/close() @@ -295,18 +288,15 @@ if(operating || welded) return if(safe) - for(var/atom/movable/M in get_turf(src)) - if(M.density && M != src) //something is blocking the door - if(autoclose) - addtimer(CALLBACK(src, .proc/autoclose), 60) - return + for(var/turf/turf in locs) + for(var/atom/movable/M in turf) + if(M.density && M != src) //something is blocking the door + if(autoclose) + autoclose_in(60) + return operating = TRUE - if(autoclose_timer) - deltimer(autoclose_timer) - autoclose_timer = 0 - do_animate("closing") layer = closingLayer sleep(5) @@ -354,10 +344,12 @@ return !(stat & NOPOWER) /obj/machinery/door/proc/autoclose() - autoclose_timer = 0 if(!QDELETED(src) && !density && !operating && !locked && !welded && autoclose) close() +/obj/machinery/door/proc/autoclose_in(wait) + addtimer(CALLBACK(src, .proc/autoclose), wait, TIMER_UNIQUE | TIMER_NO_HASH_WAIT | TIMER_OVERRIDE) + /obj/machinery/door/proc/update_freelook_sight() if(!glass && cameranet) cameranet.updateVisibility(src, 0)