mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2025-12-15 20:52:07 +00:00
* Adds linter defines to repo. * Uncomments linter defines already in the code. * Resolves unreachable code linter errors. * Nukes decade+ old syndie specops code except for computer since that's mapped in????? * Resolves procs has no parent linter error. * Proc signature fixes * Bad comments * "In" danger * Type safety * Implied nested list abuse * Top level ..() usage * Sleepy coder typos * Invalid kwargs calls * Pointless returns * Linter hacks (see full message) Byond doesn't care and it has no effect but linter doesn't like var/proc for holding references to procs, despite that it's valid byond code. Also, the linter seems to have serious issues figuring out relative proc names. This commit is a sort of take-it-or-leave-it thing. It's not required, it just cuts down on warnings, but this code is valid DM code. * WHATEVER THIS IS * Trick dreamchecker linter into ignoring this file's sins in it's weird use of vars * Fix list decoration syntax - Its a list, not list of lists - To declare that a var is a list you can `var/list/blah = list()` syntax or the `var/blah[0]` syntax. Both do exactly the same thing. But if you do `var/list/blah[0]` that is just like doing `var/list/list/blah = list()` * Hopefully stops the ai holder subtype folder from going quantum and sometimes changes capitalization over time, and incidentally causing 20+ linter errors. * Fixes unwrapped negated object in list linter error. * Resolves colon-like list accessing linter error. * Turns linter on in linter config. * Fixes closet indentation properly and cleans up suit storage unit switch. Co-authored-by: Aronai Sieyes <arokha@arokha.com> Co-authored-by: Leshana <Leshana@users.noreply.github.com>
144 lines
3.7 KiB
Plaintext
144 lines
3.7 KiB
Plaintext
/obj/item/device/assembly/prox_sensor
|
|
name = "proximity sensor"
|
|
desc = "Used for scanning and alerting when someone enters a certain proximity."
|
|
icon_state = "prox"
|
|
origin_tech = list(TECH_MAGNET = 1)
|
|
matter = list(DEFAULT_WALL_MATERIAL = 800, "glass" = 200, "waste" = 50)
|
|
wires = WIRE_PULSE
|
|
|
|
secured = 0
|
|
|
|
var/scanning = 0
|
|
var/timing = 0
|
|
var/time = 10
|
|
|
|
var/range = 2
|
|
|
|
/obj/item/device/assembly/prox_sensor/activate()
|
|
if(!..())
|
|
return FALSE
|
|
timing = !timing
|
|
update_icon()
|
|
return FALSE
|
|
|
|
/obj/item/device/assembly/prox_sensor/toggle_secure()
|
|
secured = !secured
|
|
if(secured)
|
|
START_PROCESSING(SSobj, src)
|
|
else
|
|
scanning = 0
|
|
timing = 0
|
|
STOP_PROCESSING(SSobj, src)
|
|
update_icon()
|
|
return secured
|
|
|
|
/obj/item/device/assembly/prox_sensor/HasProximity(turf/T, atom/movable/AM, old_loc)
|
|
if(!istype(AM))
|
|
log_debug("DEBUG: HasProximity called with [AM] on [src] ([usr]).")
|
|
return
|
|
if (istype(AM, /obj/effect/beam))
|
|
return
|
|
if (!isobserver(AM) && AM.move_speed < 12)
|
|
sense()
|
|
|
|
/obj/item/device/assembly/prox_sensor/proc/sense()
|
|
if((!holder && !secured) || !scanning || !process_cooldown())
|
|
return FALSE
|
|
var/turf/mainloc = get_turf(src)
|
|
pulse(0)
|
|
if(!holder)
|
|
mainloc.visible_message("[bicon(src)] *beep* *beep*", "*beep* *beep*")
|
|
|
|
/obj/item/device/assembly/prox_sensor/process()
|
|
if(scanning)
|
|
var/turf/mainloc = get_turf(src)
|
|
for(var/mob/living/A in range(range,mainloc))
|
|
if (A.move_speed < 12)
|
|
sense()
|
|
|
|
if(timing && (time >= 0))
|
|
time--
|
|
if(timing && time <= 0)
|
|
timing = 0
|
|
toggle_scan()
|
|
time = initial(time)
|
|
|
|
/obj/item/device/assembly/prox_sensor/dropped()
|
|
sense()
|
|
|
|
/obj/item/device/assembly/prox_sensor/proc/toggle_scan()
|
|
if(!secured)
|
|
return FALSE
|
|
scanning = !scanning
|
|
update_icon()
|
|
|
|
/obj/item/device/assembly/prox_sensor/update_icon()
|
|
cut_overlays()
|
|
LAZYCLEARLIST(attached_overlays)
|
|
if(timing)
|
|
add_overlay("prox_timing")
|
|
LAZYADD(attached_overlays, "prox_timing")
|
|
if(scanning)
|
|
add_overlay("prox_scanning")
|
|
LAZYADD(attached_overlays, "prox_scanning")
|
|
if(holder)
|
|
holder.update_icon()
|
|
if(holder && istype(holder.loc,/obj/item/weapon/grenade/chem_grenade))
|
|
var/obj/item/weapon/grenade/chem_grenade/grenade = holder.loc
|
|
grenade.primed(scanning)
|
|
|
|
/obj/item/device/assembly/prox_sensor/Moved(atom/old_loc, direction, forced = FALSE)
|
|
. = ..()
|
|
if(isturf(old_loc))
|
|
unsense_proximity(range = range, callback = /atom/proc/HasProximity, center = old_loc)
|
|
if(isturf(loc))
|
|
sense_proximity(range = range, callback = /atom/proc/HasProximity)
|
|
sense()
|
|
|
|
/obj/item/device/assembly/prox_sensor/tgui_interact(mob/user, datum/tgui/ui)
|
|
if(!secured)
|
|
to_chat(user, "<span class='warning'>[src] is unsecured!</span>")
|
|
return FALSE
|
|
ui = SStgui.try_update_ui(user, src, ui)
|
|
if(!ui)
|
|
ui = new(user, src, "AssemblyProx", name)
|
|
ui.open()
|
|
|
|
/obj/item/device/assembly/prox_sensor/tgui_data(mob/user)
|
|
var/list/data = ..()
|
|
|
|
data["time"] = time * 10
|
|
data["timing"] = timing
|
|
data["range"] = range
|
|
data["maxRange"] = 5
|
|
data["scanning"] = scanning
|
|
|
|
return data
|
|
|
|
/obj/item/device/assembly/prox_sensor/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
|
|
if(..())
|
|
return TRUE
|
|
|
|
switch(action)
|
|
if("scanning")
|
|
toggle_scan()
|
|
return TRUE
|
|
if("timing")
|
|
timing = !timing
|
|
update_icon()
|
|
return TRUE
|
|
if("set_time")
|
|
var/real_new_time = 0
|
|
var/new_time = params["time"]
|
|
var/list/L = splittext(new_time, ":")
|
|
if(LAZYLEN(L))
|
|
for(var/i in 1 to LAZYLEN(L))
|
|
real_new_time += text2num(L[i]) * (60 ** (LAZYLEN(L) - i))
|
|
else
|
|
real_new_time = text2num(new_time)
|
|
time = clamp(real_new_time, 0, 600)
|
|
return TRUE
|
|
if("range")
|
|
range = clamp(params["range"], 1, 5)
|
|
return TRUE
|