mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-30 00:21:11 +01:00
Repaths obj/machinery to obj/structure/machinery. **Note for reviewers:** the only meaningful changed code exists within **code/game/objects/structures.dm** and **code/game/objects/structures/_machinery.dm**, largely concerning damage procs. With the exception of moving airlock defines to their own file, ALL OTHER CHANGES ARE STRICTLY PATH CHANGES. Objects, _categorically_, are largely divided between those you can hold in your hand/inventory and those you can't. Machinery objects are already subtypes of Structures behaviorally, this PR just makes their pathing reflect that, and allows for future work (tool actions, more health/destruction functionality) to be developed without unnecessary code duplication. I have tested this PR by loading up the Horizon and dismantling various machines and structures with tools, shooting guns of various types throughout the ship, and detonating a bunch of explosions throughout the ship.
54 lines
1.4 KiB
Plaintext
54 lines
1.4 KiB
Plaintext
/obj/structure/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/structure/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/structure/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/structure/machinery/camera/proc/cancelAlarm()
|
|
if (!status || (stat & NOPOWER))
|
|
return 0
|
|
if (detectTime == -1)
|
|
GLOB.motion_alarm.clearAlarm(loc, src)
|
|
detectTime = 0
|
|
return 1
|
|
|
|
/obj/structure/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/structure/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)
|
|
|