mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-07-20 04:17:33 +01:00
Assembly Code Clean-up (#10146)
This commit is contained in:
@@ -3,107 +3,98 @@
|
||||
desc = "Used to time things. Works well with contraptions which has to count down. Tick tock."
|
||||
icon_state = "timer"
|
||||
drop_sound = 'sound/items/drop/component.ogg'
|
||||
pickup_sound = 'sound/items/pickup/component.ogg'
|
||||
pickup_sound = 'sound/items/pickup/component.ogg'
|
||||
origin_tech = list(TECH_MAGNET = 1)
|
||||
matter = list(DEFAULT_WALL_MATERIAL = 500, MATERIAL_GLASS = 50)
|
||||
|
||||
wires = WIRE_PULSE
|
||||
secured = FALSE
|
||||
|
||||
secured = 0
|
||||
|
||||
var/timing = 0
|
||||
var/timing = FALSE
|
||||
var/time = 10
|
||||
|
||||
proc
|
||||
timer_end()
|
||||
|
||||
/obj/item/device/assembly/timer/activate()
|
||||
. = ..()
|
||||
if(!.)
|
||||
return FALSE //Cooldown check
|
||||
|
||||
activate()
|
||||
if(!..()) return 0//Cooldown check
|
||||
timing = !timing
|
||||
update_icon()
|
||||
return FALSE
|
||||
|
||||
timing = !timing
|
||||
/obj/item/device/assembly/timer/toggle_secure()
|
||||
secured = !secured
|
||||
if(secured)
|
||||
START_PROCESSING(SSprocessing, src)
|
||||
else
|
||||
timing = FALSE
|
||||
STOP_PROCESSING(SSprocessing, src)
|
||||
update_icon()
|
||||
return secured
|
||||
|
||||
update_icon()
|
||||
return 0
|
||||
/obj/item/device/assembly/timer/proc/timer_end()
|
||||
if(!secured)
|
||||
return FALSE
|
||||
pulse(FALSE)
|
||||
if(!holder)
|
||||
audible_message("[icon2html(src, viewers(get_turf(src)))] *beep* *beep*", "*beep* *beep*")
|
||||
cooldown = 2
|
||||
addtimer(CALLBACK(src, .proc/process_cooldown), 1 SECOND)
|
||||
|
||||
|
||||
toggle_secure()
|
||||
secured = !secured
|
||||
if(secured)
|
||||
START_PROCESSING(SSprocessing, src)
|
||||
else
|
||||
timing = 0
|
||||
STOP_PROCESSING(SSprocessing, src)
|
||||
update_icon()
|
||||
return secured
|
||||
|
||||
|
||||
timer_end()
|
||||
if(!secured) return 0
|
||||
pulse(0)
|
||||
if(!holder)
|
||||
visible_message("[icon2html(src, viewers(get_turf(src)))] *beep* *beep*", "*beep* *beep*")
|
||||
cooldown = 2
|
||||
addtimer(CALLBACK(src, .proc/process_cooldown), 10)
|
||||
return
|
||||
|
||||
|
||||
process()
|
||||
if(timing && (time > 0))
|
||||
/obj/item/device/assembly/timer/process()
|
||||
if(timing)
|
||||
if(time > 0)
|
||||
time--
|
||||
if(timing && time <= 0)
|
||||
timing = 0
|
||||
if(time <= 0)
|
||||
timing = FALSE
|
||||
timer_end()
|
||||
time = 10
|
||||
|
||||
SSvueui.check_uis_for_change(src)
|
||||
|
||||
/obj/item/device/assembly/timer/update_icon()
|
||||
cut_overlays()
|
||||
attached_overlays = list()
|
||||
if(timing)
|
||||
add_overlay("timer_timing")
|
||||
attached_overlays += "timer_timing"
|
||||
if(holder)
|
||||
holder.update_icon()
|
||||
|
||||
/obj/item/device/assembly/timer/interact(mob/user)
|
||||
if(!secured)
|
||||
to_chat(user, SPAN_WARNING("\The [src] is unsecured!"))
|
||||
return
|
||||
|
||||
var/datum/vueui/ui = SSvueui.get_open_ui(user, src)
|
||||
if(!ui)
|
||||
ui = new(user, src, "devices-assembly-timer", 320, 220, capitalize_first_letters(name))
|
||||
ui.open()
|
||||
|
||||
update_icon()
|
||||
cut_overlays()
|
||||
attached_overlays = list()
|
||||
if(timing)
|
||||
add_overlay("timer_timing")
|
||||
attached_overlays += "timer_timing"
|
||||
if(holder)
|
||||
holder.update_icon()
|
||||
return
|
||||
/obj/item/device/assembly/timer/vueui_data_change(var/list/data, var/mob/user, var/datum/vueui/ui)
|
||||
if(!data)
|
||||
data = list()
|
||||
|
||||
var/second = time % 60
|
||||
var/minute = (time - second) / 60
|
||||
|
||||
interact(mob/user as mob)//TODO: Have this use the wires
|
||||
if(!secured)
|
||||
user.show_message("<span class='warning'>The [name] is unsecured!</span>")
|
||||
return 0
|
||||
var/second = time % 60
|
||||
var/minute = (time - second) / 60
|
||||
var/dat = text("<TT><B>Timing Unit</B>\n[] []:[]\n<A href='?src=\ref[];tp=-30'>-</A> <A href='?src=\ref[];tp=-1'>-</A> <A href='?src=\ref[];tp=1'>+</A> <A href='?src=\ref[];tp=30'>+</A>\n</TT>", (timing ? text("<A href='?src=\ref[];time=0'>Timing</A>", src) : text("<A href='?src=\ref[];time=1'>Not Timing</A>", src)), minute, second, src, src, src, src)
|
||||
dat += "<BR><BR><A href='?src=\ref[src];refresh=1'>Refresh</A>"
|
||||
dat += "<BR><BR><A href='?src=\ref[src];close=1'>Close</A>"
|
||||
user << browse(dat, "window=timer")
|
||||
onclose(user, "timer")
|
||||
return
|
||||
VUEUI_SET_CHECK(data["timeractive"], timing, ., data)
|
||||
VUEUI_SET_CHECK(data["minute"], minute, ., data)
|
||||
VUEUI_SET_CHECK(data["second"], second, ., data)
|
||||
|
||||
/obj/item/device/assembly/timer/Topic(href, href_list)
|
||||
..()
|
||||
|
||||
Topic(href, href_list)
|
||||
..()
|
||||
if(!usr.canmove || usr.stat || usr.restrained() || !in_range(loc, usr))
|
||||
usr << browse(null, "window=timer")
|
||||
onclose(usr, "timer")
|
||||
return
|
||||
if(href_list["time"])
|
||||
timing = !timing
|
||||
update_icon()
|
||||
|
||||
if(href_list["time"])
|
||||
timing = text2num(href_list["time"])
|
||||
update_icon()
|
||||
if(href_list["tp"])
|
||||
var/tp = text2num(href_list["tp"])
|
||||
time += tp
|
||||
time = round(time)
|
||||
time = clamp(time, 1, 600)
|
||||
|
||||
if(href_list["tp"])
|
||||
var/tp = text2num(href_list["tp"])
|
||||
time += tp
|
||||
time = min(max(round(time), 0), 600)
|
||||
|
||||
if(href_list["close"])
|
||||
usr << browse(null, "window=timer")
|
||||
return
|
||||
|
||||
if(usr)
|
||||
attack_self(usr)
|
||||
|
||||
return
|
||||
var/datum/vueui/ui = SSvueui.get_open_ui(usr, src)
|
||||
ui.check_for_change()
|
||||
Reference in New Issue
Block a user