Files
fb4cf2e80a Weakref cleanup (#19382)
* oh god help

* fixes

* oops

* container runtime

---------

Co-authored-by: Cameron Lennox <killer65311@gmail.com>
2026-04-21 04:57:02 -04:00

87 lines
2.3 KiB
Plaintext

/obj/machinery/rnd
name = "R&D Device"
icon = 'icons/obj/machines/research_vr.dmi'
density = TRUE
anchored = TRUE
use_power = USE_POWER_IDLE
///Are we currently printing a machine
var/busy = FALSE
///Is this machne hacked via wires
var/hacked = FALSE
///Is this machine disabled via wires
var/disabled = FALSE
///Ref to global science techweb.
var/datum/techweb/stored_research
///The item loaded inside the machine, used by experimentors and destructive analyzers only.
var/datum/weakref/loaded_item
/obj/machinery/rnd/Initialize(mapload)
. = ..()
if(!stored_research)
CONNECT_TO_RND_SERVER_ROUNDSTART(stored_research, src)
if(stored_research)
on_connected_techweb()
set_wires(new /datum/wires/rnd(src))
/obj/machinery/rnd/Destroy()
if(stored_research)
log_research("[src] disconnected from techweb [stored_research] (destroyed).")
stored_research = null
QDEL_NULL(wires)
loaded_item = null
return ..()
/obj/machinery/rnd/tgui_status(mob/user)
if(disabled)
return STATUS_CLOSE
return ..()
///Called when attempting to connect the machine to a techweb, forgetting the old.
/obj/machinery/rnd/proc/connect_techweb(datum/techweb/new_techweb)
if(stored_research)
log_research("[src] disconnected from techweb [stored_research] when connected to [new_techweb].")
stored_research = new_techweb
if(!isnull(stored_research))
on_connected_techweb()
///Called post-connection to a new techweb.
/obj/machinery/rnd/proc/on_connected_techweb()
SHOULD_CALL_PARENT(FALSE)
///Reset the state of this machine
/obj/machinery/rnd/proc/reset_busy()
busy = FALSE
/obj/machinery/rnd/attack_hand(mob/user)
. = ..()
if(.)
return
if(wires && panel_open)
return wires.Interact(user)
if(disabled)
return
tgui_interact(user)
/obj/machinery/rnd/attackby(obj/item/W, mob/user, attack_modifier, click_parameters)
add_fingerprint(user)
if(default_deconstruction_screwdriver(user, W))
if(wires && panel_open)
wires.Interact(user)
return
if(default_deconstruction_crowbar(user, W))
return
if(default_part_replacement(user, W))
return
if(default_unfasten_wrench(user, W, 2 SECONDS))
return
return ..()
/obj/machinery/rnd/dismantle()
var/obj/item/our_item = loaded_item?.resolve()
if(our_item)
our_item.forceMove(drop_location())
loaded_item = null
. = ..()