/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/examine(mob/user) . = ..() if(in_range(user, src) || isobserver(user)) . += "The status display reads: Scanning module has been upgraded to level [scan_level]." /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 || SEND_SIGNAL(occupant, COMSIG_NANITE_CHECK_CONSOLE_LOCK)) return SEND_SIGNAL(occupant, COMSIG_NANITE_SET_SAFETY, threshold) /obj/machinery/nanite_chamber/proc/set_cloud(cloud_id) if(!occupant || SEND_SIGNAL(occupant, COMSIG_NANITE_CHECK_CONSOLE_LOCK)) 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/remove_nanites(datum/nanite_program/NP) if(stat & (NOPOWER|BROKEN)) return if((stat & MAINT) || panel_open) return if(!occupant || busy || SEND_SIGNAL(occupant, COMSIG_NANITE_CHECK_CONSOLE_LOCK)) return var/locked_state = locked locked = TRUE //TODO OMINOUS MACHINE SOUNDS set_busy(TRUE, "Initializing cleanup 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, "Pinging nanites...", "[initial(icon_state)]_active"),40) addtimer(CALLBACK(src, .proc/set_busy, TRUE, "Initiating graceful self-destruct sequence...", "[initial(icon_state)]_active"),70) addtimer(CALLBACK(src, .proc/set_busy, TRUE, "Removing debris...", "[initial(icon_state)]_falling"),110) addtimer(CALLBACK(src, .proc/complete_removal, locked_state),130) /obj/machinery/nanite_chamber/proc/complete_removal(locked_state) //TODO MACHINE DING locked = locked_state set_busy(FALSE) if(!occupant) return SEND_SIGNAL(occupant, COMSIG_NANITE_DELETE) /obj/machinery/nanite_chamber/update_icon_state() //running and someone in there if(occupant) if(busy) icon_state = busy_icon_state else icon_state = initial(icon_state) + "_occupied" else //running icon_state = initial(icon_state) + (state_open ? "_open" : "") /obj/machinery/nanite_chamber/update_overlays() . = ..() if((stat & MAINT) || panel_open) . += "maint" else if(!(stat & (NOPOWER|BROKEN))) if(busy || locked) . += "red" if(locked) . += "bolted" else . += "green" /obj/machinery/nanite_chamber/proc/toggle_open(mob/user) if(panel_open) to_chat(user, "Close the maintenance panel first.") return if(state_open) close_machine() return else if(locked) to_chat(user, "The bolts are locked down, securing the door shut.") return open_machine() /obj/machinery/nanite_chamber/container_resist(mob/living/user) if(!locked) open_machine() return if(busy) return user.visible_message("You see [user] kicking against the door of [src]!", \ "You lean on the back of [src] and start pushing the door open... (this will take about [DisplayTimeText(breakout_time)].)", \ "You hear a metallic creaking from [src].") 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("[user] successfully broke out of [src]!", \ "You successfully break out of [src]!") 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, "[src]'s door won't budge!") 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.canUseTopic(src, BE_CLOSE, FALSE, NO_TK) || !Adjacent(target) || !user.Adjacent(target) || !iscarbon(target)) return if(close_machine(target)) log_combat(user, target, "inserted", null, "into [src].") add_fingerprint(user)