mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-07-21 21:10:30 +01:00
5fec421dae
Destroys a ton of sources of lag: - /obj/machinery/biogenerator/interact and /obj/machinery/computer/rdconsole/attack_hand Both of these call REF(src) constantly on their UI update, which also happens constantly. Death by a thousand cuts - /obj/machinery/button/ignition/attack_hand and /obj/machinery/button/switch/holosign/attack_hand Sleeps rather than timers, iterating the entire machinery list rather than just storing the IDs we need at roundstart - /obj/machinery/telecomms/update_icon and /obj/machinery/meter/process Calling overlay updates WAY TOO MUCH. UpdateOverlays is a significant overhead for the server at this point and the two of these combined are responsible for a little over 20% of updates. They now should only update overlays when necessary rather than every tick. - NEW! /obj/machinery/disposal/proc/update and /obj/machinery/portable_atmospherics/hydroponics/update_icon These two were also offenders, worse than telecomms but better than meters. They have also been brought into line. - /mob/living/carbon/slime Hard-del'd if grinded into slime extract less than two minutes after being "born". Fixed by adding TIMER_DELETE_ME flag. --------- Co-authored-by: Matt Atlas <liermattia@gmail.com>
54 lines
1.4 KiB
Plaintext
54 lines
1.4 KiB
Plaintext
/obj/machinery/camera
|
|
var/list/motionTargets = list()
|
|
var/detectTime = 0
|
|
var/area/ai_monitored/area_motion = null
|
|
/// Don't forget, there's another 10 seconds in queueAlarm()
|
|
var/alarm_delay = 100
|
|
movable_flags = MOVABLE_FLAG_PROXMOVE
|
|
|
|
/obj/machinery/camera/proc/newTarget(var/mob/target)
|
|
if(QDELETED(target))
|
|
return FALSE
|
|
|
|
if (istype(target, /mob/living/silicon/ai))
|
|
return FALSE
|
|
|
|
if (detectTime == 0)
|
|
detectTime = world.time // start the clock
|
|
if (!(target in motionTargets) && !QDELING(target))
|
|
motionTargets += target
|
|
RegisterSignal(target, COMSIG_QDELETING, PROC_REF(lostTarget))
|
|
|
|
return TRUE
|
|
|
|
/obj/machinery/camera/proc/lostTarget(var/mob/target)
|
|
SIGNAL_HANDLER
|
|
if (target in motionTargets)
|
|
motionTargets -= target
|
|
UnregisterSignal(target, COMSIG_QDELETING)
|
|
if (motionTargets.len == 0)
|
|
cancelAlarm()
|
|
|
|
/obj/machinery/camera/proc/cancelAlarm()
|
|
if (!status || (stat & NOPOWER))
|
|
return 0
|
|
if (detectTime == -1)
|
|
GLOB.motion_alarm.clearAlarm(loc, src)
|
|
detectTime = 0
|
|
return 1
|
|
|
|
/obj/machinery/camera/proc/triggerAlarm()
|
|
if (!status || (stat & NOPOWER))
|
|
return 0
|
|
if (!detectTime) return 0
|
|
GLOB.motion_alarm.triggerAlarm(loc, src)
|
|
detectTime = -1
|
|
return 1
|
|
|
|
/obj/machinery/camera/HasProximity(atom/movable/AM as mob|obj)
|
|
// Motion cameras outside of an "ai monitored" area will use this to detect stuff.
|
|
if (!area_motion)
|
|
if(isliving(AM) && !QDELING(AM))
|
|
newTarget(AM)
|
|
|