BCIs are now stored in the manipulation chamber's contents, instead of nullspace (#70350)

Fixes a bug where MMIs would be sent into the nullspace room when in an MMI component inside of a BCI that is inserted into a BCI manipulation chamber.

Stores the BCI in the chamber's contents, instead of nullspace, allowing the MMI to talk, the BCI to still act as it would normally and overall just solves the issue and maybe some others alongside it.

Fixes #70349
This commit is contained in:
RikuTheKiller
2022-10-08 17:24:31 +03:00
committed by GitHub
parent 5c2b340a94
commit a2fcec6a33
2 changed files with 33 additions and 27 deletions
@@ -281,7 +281,7 @@
var/busy_icon_state
var/locked = FALSE
var/datum/weakref/bci_to_implant
var/obj/item/organ/internal/cyberimp/bci/bci_to_implant
COOLDOWN_DECLARE(message_cooldown)
@@ -290,18 +290,15 @@
occupant_typecache = typecacheof(/mob/living/carbon)
/obj/machinery/bci_implanter/on_deconstruction()
var/obj/item/organ/internal/cyberimp/bci/bci_to_implant_resolved = bci_to_implant?.resolve()
bci_to_implant_resolved?.forceMove(drop_location())
bci_to_implant = null
drop_stored_bci()
/obj/machinery/bci_implanter/Destroy()
QDEL_NULL(bci_to_implant)
qdel(bci_to_implant)
return ..()
/obj/machinery/bci_implanter/examine(mob/user)
. = ..()
if (isnull(bci_to_implant?.resolve()))
if (isnull(bci_to_implant))
. += span_notice("There is no BCI inserted.")
else
. += span_notice("Right-click to remove current BCI.")
@@ -350,15 +347,12 @@
balloon_alert(user, "it's locked!")
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
var/obj/item/organ/internal/cyberimp/bci/bci_to_implant_resolved = bci_to_implant?.resolve()
if (isnull(bci_to_implant_resolved))
if (isnull(bci_to_implant))
balloon_alert(user, "no bci inserted!")
else
user.put_in_hands(bci_to_implant_resolved)
user.put_in_hands(bci_to_implant)
balloon_alert(user, "ejected bci")
bci_to_implant = null
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
/obj/machinery/bci_implanter/attackby(obj/item/weapon, mob/user, params)
@@ -368,10 +362,10 @@
balloon_alert(user, "bci has no circuit!")
return
var/obj/item/organ/internal/cyberimp/bci/previous_bci_to_implant = bci_to_implant?.resolve()
var/obj/item/organ/internal/cyberimp/bci/previous_bci_to_implant = bci_to_implant
bci_to_implant = WEAKREF(weapon)
weapon.moveToNullspace()
user.transferItemToLoc(weapon, src)
bci_to_implant = weapon
if (isnull(previous_bci_to_implant))
balloon_alert(user, "inserted bci")
@@ -426,22 +420,20 @@
playsound(loc, 'sound/machines/ping.ogg', 30, FALSE)
var/obj/item/organ/internal/cyberimp/bci/bci_organ = carbon_occupant.getorgan(/obj/item/organ/internal/cyberimp/bci)
var/obj/item/organ/internal/cyberimp/bci/bci_to_implant_resolved = bci_to_implant?.resolve()
if (bci_organ)
bci_organ.Remove(carbon_occupant)
if (isnull(bci_to_implant_resolved))
if (isnull(bci_to_implant))
say("Occupant's previous brain-computer interface has been transferred to internal storage unit.")
bci_organ.moveToNullspace()
bci_to_implant = WEAKREF(bci_organ)
carbon_occupant.transferItemToLoc(bci_organ, src)
bci_to_implant = bci_organ
else
say("Occupant's previous brain-computer interface has been ejected.")
bci_organ.forceMove(drop_location())
else if (!isnull(bci_to_implant_resolved))
say("Occupant has been injected with [bci_to_implant_resolved].")
bci_to_implant_resolved.Insert(carbon_occupant)
bci_to_implant = null
else if (!isnull(bci_to_implant))
say("Occupant has been injected with [bci_to_implant].")
bci_to_implant.Insert(carbon_occupant)
/obj/machinery/bci_implanter/open_machine()
if(state_open)
@@ -459,8 +451,8 @@
var/mob/living/carbon/carbon_occupant = occupant
if (istype(occupant))
var/obj/item/organ/internal/cyberimp/bci/existing_bci_organ = carbon_occupant.getorgan(/obj/item/organ/internal/cyberimp/bci)
if (isnull(existing_bci_organ) && isnull(bci_to_implant?.resolve()))
var/obj/item/organ/internal/cyberimp/bci/bci_organ = carbon_occupant.getorgan(/obj/item/organ/internal/cyberimp/bci)
if (isnull(bci_organ) && isnull(bci_to_implant))
say("No brain-computer interface inserted, and occupant does not have one. Insert a BCI to implant one.")
playsound(src, 'sound/machines/buzz-sigh.ogg', 30, TRUE)
return FALSE
@@ -495,6 +487,21 @@
open_machine()
/obj/machinery/bci_implanter/proc/drop_stored_bci()
if (isnull(bci_to_implant))
return
bci_to_implant.forceMove(drop_location())
/obj/machinery/bci_implanter/dump_inventory_contents(list/subset)
// Prevents opening the machine dropping the BCI.
// "dump_contents()" still drops the BCI.
return ..(contents - bci_to_implant)
/obj/machinery/bci_implanter/Exited(atom/movable/gone, direction)
if (gone == bci_to_implant)
bci_to_implant = null
return ..()
/obj/item/circuitboard/machine/bci_implanter
name = "Brain-Computer Interface Manipulation Chamber (Machine Board)"
greyscale_colors = CIRCUIT_COLOR_SCIENCE