Proximity sensing refactor (#425)
This commit is contained in:
committed by
TalkingCactus
parent
dfd470adf9
commit
64068fc614
@@ -10,8 +10,6 @@
|
||||
var/timing = 0
|
||||
var/time = 10
|
||||
var/sensitivity = 1
|
||||
var/atom/oldloc
|
||||
var/list/turfs_around = list()
|
||||
|
||||
/obj/item/device/assembly/prox_sensor/proc/toggle_scan()
|
||||
|
||||
@@ -19,22 +17,15 @@
|
||||
/obj/item/device/assembly/prox_sensor/proc/sense()
|
||||
|
||||
|
||||
/obj/item/device/assembly/prox_sensor/New()
|
||||
..()
|
||||
START_PROCESSING(SSobj, src)
|
||||
oldloc = loc
|
||||
/obj/item/device/assembly/prox_sensor/Initialize()
|
||||
. = ..()
|
||||
proximity_monitor = new(src, 0)
|
||||
|
||||
/obj/item/device/assembly/prox_sensor/describe()
|
||||
if(timing)
|
||||
return "<span class='notice'>The proximity sensor is arming.</span>"
|
||||
return "The proximity sensor is [scanning?"armed":"disarmed"]."
|
||||
|
||||
/obj/item/device/assembly/prox_sensor/on_attach(datum/wires/w)
|
||||
handle_move(w.holder)
|
||||
|
||||
/obj/item/device/assembly/prox_sensor/on_detach(datum/wires/w)
|
||||
handle_move(w.holder.loc)
|
||||
|
||||
/obj/item/device/assembly/prox_sensor/activate()
|
||||
if(!..())
|
||||
return 0//Cooldown check
|
||||
@@ -42,12 +33,15 @@
|
||||
update_icon()
|
||||
return 1
|
||||
|
||||
|
||||
/obj/item/device/assembly/prox_sensor/toggle_secure()
|
||||
secured = !secured
|
||||
if(!secured)
|
||||
scanning = 0
|
||||
if(scanning)
|
||||
toggle_scan()
|
||||
proximity_monitor.host = src
|
||||
timing = 0
|
||||
else
|
||||
proximity_monitor.host = loc
|
||||
update_icon()
|
||||
return secured
|
||||
|
||||
@@ -73,36 +67,19 @@
|
||||
timing = 0
|
||||
toggle_scan(1)
|
||||
time = initial(time)
|
||||
handle_move(loc)
|
||||
|
||||
/obj/item/device/assembly/prox_sensor/dropped()
|
||||
..()
|
||||
if(scanning)
|
||||
INVOKE_ASYNC(src, .proc/sense)
|
||||
|
||||
/obj/item/device/assembly/prox_sensor/Destroy()
|
||||
if(scanning)
|
||||
remove_from_proximity_list(src, sensitivity, oldloc)
|
||||
return ..()
|
||||
|
||||
/obj/item/device/assembly/prox_sensor/toggle_scan(scan)
|
||||
if(!secured)
|
||||
return 0
|
||||
scanning = scan
|
||||
if(scanning)
|
||||
add_to_proximity_list(src, sensitivity)
|
||||
else
|
||||
remove_from_proximity_list(src, sensitivity)
|
||||
oldloc = get_turf(loc)
|
||||
proximity_monitor.SetRange(scanning ? sensitivity : 0)
|
||||
update_icon()
|
||||
|
||||
/obj/item/device/assembly/prox_sensor/proc/sensitivity_change(value)
|
||||
var/sense = min(max(sensitivity + value, 0), 5)
|
||||
if(scanning)
|
||||
if(shift_proximity(src, oldloc, sensitivity, loc, sense))
|
||||
sense()
|
||||
oldloc = loc
|
||||
sensitivity = sense
|
||||
if(scanning && proximity_monitor.SetRange(sense))
|
||||
sense()
|
||||
|
||||
/obj/item/device/assembly/prox_sensor/update_icon()
|
||||
cut_overlays()
|
||||
@@ -117,17 +94,6 @@
|
||||
holder.update_icon()
|
||||
return
|
||||
|
||||
/obj/item/device/assembly/prox_sensor/proc/handle_move(atom/newloc)
|
||||
if(scanning)
|
||||
if(shift_proximity(src, oldloc, sensitivity, newloc, sensitivity) || newloc != oldloc)
|
||||
sense()
|
||||
oldloc = newloc
|
||||
|
||||
/obj/item/device/assembly/prox_sensor/Moved()
|
||||
..()
|
||||
handle_move(loc)
|
||||
|
||||
|
||||
/obj/item/device/assembly/prox_sensor/interact(mob/user)//TODO: Change this to the wires thingy
|
||||
if(is_secured(user))
|
||||
var/second = time % 60
|
||||
|
||||
Reference in New Issue
Block a user