232 lines
6.9 KiB
Plaintext
232 lines
6.9 KiB
Plaintext
/obj/machinery/nanite_chamber
|
|
name = "nanite chamber"
|
|
desc = "A device that can scan, reprogram, and inject nanites."
|
|
circuit = /obj/item/circuitboard/machine/nanite_chamber
|
|
icon = 'icons/obj/machines/nanite_chamber.dmi'
|
|
icon_state = "nanite_chamber"
|
|
layer = ABOVE_WINDOW_LAYER
|
|
use_power = IDLE_POWER_USE
|
|
anchored = TRUE
|
|
density = TRUE
|
|
idle_power_usage = 50
|
|
active_power_usage = 300
|
|
|
|
var/obj/machinery/computer/nanite_chamber_control/console
|
|
var/locked = FALSE
|
|
var/breakout_time = 1200
|
|
var/scan_level
|
|
var/busy = FALSE
|
|
var/busy_icon_state
|
|
var/busy_message
|
|
var/message_cooldown = 0
|
|
|
|
/obj/machinery/nanite_chamber/Initialize()
|
|
. = ..()
|
|
occupant_typecache = GLOB.typecache_living
|
|
|
|
/obj/machinery/nanite_chamber/RefreshParts()
|
|
scan_level = 0
|
|
for(var/obj/item/stock_parts/scanning_module/P in component_parts)
|
|
scan_level += P.rating
|
|
|
|
/obj/machinery/nanite_chamber/proc/set_busy(status, message, working_icon)
|
|
busy = status
|
|
busy_message = message
|
|
busy_icon_state = working_icon
|
|
update_icon()
|
|
|
|
/obj/machinery/nanite_chamber/proc/set_safety(threshold)
|
|
if(!occupant)
|
|
return
|
|
SEND_SIGNAL(occupant, COMSIG_NANITE_SET_SAFETY, threshold)
|
|
|
|
/obj/machinery/nanite_chamber/proc/set_cloud(cloud_id)
|
|
if(!occupant)
|
|
return
|
|
SEND_SIGNAL(occupant, COMSIG_NANITE_SET_CLOUD, cloud_id)
|
|
|
|
/obj/machinery/nanite_chamber/proc/inject_nanites()
|
|
if(stat & (NOPOWER|BROKEN))
|
|
return
|
|
if((stat & MAINT) || panel_open)
|
|
return
|
|
if(!occupant || busy)
|
|
return
|
|
|
|
var/locked_state = locked
|
|
locked = TRUE
|
|
|
|
//TODO OMINOUS MACHINE SOUNDS
|
|
set_busy(TRUE, "Initializing injection protocol...", "[initial(icon_state)]_raising")
|
|
addtimer(CALLBACK(src, .proc/set_busy, TRUE, "Analyzing host bio-structure...", "[initial(icon_state)]_active"),20)
|
|
addtimer(CALLBACK(src, .proc/set_busy, TRUE, "Priming nanites...", "[initial(icon_state)]_active"),40)
|
|
addtimer(CALLBACK(src, .proc/set_busy, TRUE, "Injecting...", "[initial(icon_state)]_active"),70)
|
|
addtimer(CALLBACK(src, .proc/set_busy, TRUE, "Activating nanites...", "[initial(icon_state)]_falling"),110)
|
|
addtimer(CALLBACK(src, .proc/complete_injection, locked_state),130)
|
|
|
|
/obj/machinery/nanite_chamber/proc/complete_injection(locked_state)
|
|
//TODO MACHINE DING
|
|
locked = locked_state
|
|
set_busy(FALSE)
|
|
if(!occupant)
|
|
return
|
|
occupant.AddComponent(/datum/component/nanites, 100)
|
|
|
|
/obj/machinery/nanite_chamber/proc/install_program(datum/nanite_program/NP)
|
|
if(stat & (NOPOWER|BROKEN))
|
|
return
|
|
if((stat & MAINT) || panel_open)
|
|
return
|
|
if(!occupant || busy)
|
|
return
|
|
|
|
var/locked_state = locked
|
|
locked = TRUE
|
|
|
|
//TODO COMPUTERY MACHINE SOUNDS
|
|
set_busy(TRUE, "Initializing installation protocol...", "[initial(icon_state)]_raising")
|
|
addtimer(CALLBACK(src, .proc/set_busy, TRUE, "Connecting to nanite framework...", "[initial(icon_state)]_active"),20)
|
|
addtimer(CALLBACK(src, .proc/set_busy, TRUE, "Installing program...", "[initial(icon_state)]_falling"),35)
|
|
addtimer(CALLBACK(src, .proc/complete_installation, locked_state, NP),55)
|
|
|
|
/obj/machinery/nanite_chamber/proc/complete_installation(locked_state, datum/nanite_program/NP)
|
|
//TODO MACHINE DING
|
|
locked = locked_state
|
|
set_busy(FALSE)
|
|
if(!occupant)
|
|
return
|
|
|
|
SEND_SIGNAL(occupant, COMSIG_NANITE_ADD_PROGRAM, NP.copy())
|
|
|
|
/obj/machinery/nanite_chamber/proc/uninstall_program(datum/nanite_program/NP)
|
|
if(stat & (NOPOWER|BROKEN))
|
|
return
|
|
if((stat & MAINT) || panel_open)
|
|
return
|
|
if(!occupant || busy)
|
|
return
|
|
|
|
var/locked_state = locked
|
|
locked = TRUE
|
|
|
|
//TODO COMPUTERY MACHINE SOUNDS
|
|
set_busy(TRUE, "Initializing uninstallation protocol...", "[initial(icon_state)]_raising")
|
|
addtimer(CALLBACK(src, .proc/set_busy, TRUE, "Connecting to nanite framework...", "[initial(icon_state)]_active"),20)
|
|
addtimer(CALLBACK(src, .proc/set_busy, TRUE, "Uninstalling program...", "[initial(icon_state)]_falling"),35)
|
|
addtimer(CALLBACK(src, .proc/complete_uninstallation, locked_state, NP),55)
|
|
|
|
/obj/machinery/nanite_chamber/proc/complete_uninstallation(locked_state, datum/nanite_program/NP)
|
|
//TODO MACHINE DING
|
|
locked = locked_state
|
|
set_busy(FALSE)
|
|
if(!occupant)
|
|
return
|
|
qdel(NP)
|
|
|
|
/obj/machinery/nanite_chamber/update_icon()
|
|
cut_overlays()
|
|
|
|
if((stat & MAINT) || panel_open)
|
|
add_overlay("maint")
|
|
|
|
else if(!(stat & (NOPOWER|BROKEN)))
|
|
if(busy || locked)
|
|
add_overlay("red")
|
|
if(locked)
|
|
add_overlay("bolted")
|
|
else
|
|
add_overlay("green")
|
|
|
|
//running and someone in there
|
|
if(occupant)
|
|
if(busy)
|
|
icon_state = busy_icon_state
|
|
else
|
|
icon_state = initial(icon_state)+ "_occupied"
|
|
return
|
|
|
|
//running
|
|
icon_state = initial(icon_state)+ (state_open ? "_open" : "")
|
|
|
|
/obj/machinery/nanite_chamber/power_change()
|
|
..()
|
|
update_icon()
|
|
|
|
/obj/machinery/nanite_chamber/proc/toggle_open(mob/user)
|
|
if(panel_open)
|
|
to_chat(user, "<span class='notice'>Close the maintenance panel first.</span>")
|
|
return
|
|
|
|
if(state_open)
|
|
close_machine()
|
|
return
|
|
|
|
else if(locked)
|
|
to_chat(user, "<span class='notice'>The bolts are locked down, securing the door shut.</span>")
|
|
return
|
|
|
|
open_machine()
|
|
|
|
/obj/machinery/nanite_chamber/container_resist(mob/living/user)
|
|
if(!locked)
|
|
open_machine()
|
|
return
|
|
if(busy)
|
|
return
|
|
user.changeNext_move(CLICK_CD_BREAKOUT)
|
|
user.last_special = world.time + CLICK_CD_BREAKOUT
|
|
user.visible_message("<span class='notice'>You see [user] kicking against the door of [src]!</span>", \
|
|
"<span class='notice'>You lean on the back of [src] and start pushing the door open... (this will take about [DisplayTimeText(breakout_time)].)</span>", \
|
|
"<span class='italics'>You hear a metallic creaking from [src].</span>")
|
|
if(do_after(user,(breakout_time), target = src))
|
|
if(!user || user.stat != CONSCIOUS || user.loc != src || state_open || !locked || busy)
|
|
return
|
|
locked = FALSE
|
|
user.visible_message("<span class='warning'>[user] successfully broke out of [src]!</span>", \
|
|
"<span class='notice'>You successfully break out of [src]!</span>")
|
|
open_machine()
|
|
|
|
/obj/machinery/nanite_chamber/close_machine(mob/living/carbon/user)
|
|
if(!state_open)
|
|
return FALSE
|
|
|
|
..(user)
|
|
return TRUE
|
|
|
|
/obj/machinery/nanite_chamber/open_machine()
|
|
if(state_open)
|
|
return FALSE
|
|
|
|
..()
|
|
|
|
return TRUE
|
|
|
|
/obj/machinery/nanite_chamber/relaymove(mob/user as mob)
|
|
if(user.stat || locked)
|
|
if(message_cooldown <= world.time)
|
|
message_cooldown = world.time + 50
|
|
to_chat(user, "<span class='warning'>[src]'s door won't budge!</span>")
|
|
return
|
|
open_machine()
|
|
|
|
/obj/machinery/nanite_chamber/attackby(obj/item/I, mob/user, params)
|
|
if(!occupant && default_deconstruction_screwdriver(user, icon_state, icon_state, I))//sent icon_state is irrelevant...
|
|
update_icon()//..since we're updating the icon here, since the scanner can be unpowered when opened/closed
|
|
return
|
|
|
|
if(default_pry_open(I))
|
|
return
|
|
|
|
if(default_deconstruction_crowbar(I))
|
|
return
|
|
|
|
return ..()
|
|
|
|
/obj/machinery/nanite_chamber/interact(mob/user)
|
|
toggle_open(user)
|
|
|
|
/obj/machinery/nanite_chamber/MouseDrop_T(mob/target, mob/user)
|
|
if(user.stat || user.lying || !Adjacent(user) || !user.Adjacent(target) || !iscarbon(target) || !user.IsAdvancedToolUser())
|
|
return
|
|
close_machine(target)
|