diff --git a/code/modules/modular_computers/hardware/_hardware.dm b/code/modules/modular_computers/hardware/_hardware.dm
index 0fc0b11fbdf..a82f18c8ca6 100644
--- a/code/modules/modular_computers/hardware/_hardware.dm
+++ b/code/modules/modular_computers/hardware/_hardware.dm
@@ -93,8 +93,9 @@
return
// Called when component is removed from PC.
-/obj/item/computer_hardware/proc/on_remove(obj/item/modular_computer/M, mob/living/user = null)
- try_eject(forced = TRUE)
+/obj/item/computer_hardware/proc/on_remove(obj/item/modular_computer/M, mob/living/user)
+ if(M.physical || !QDELETED(M))
+ try_eject(forced = TRUE)
// Called when someone tries to insert something in it - paper in printer, card in card reader, etc.
/obj/item/computer_hardware/proc/try_insert(obj/item/I, mob/living/user = null)
diff --git a/code/modules/modular_computers/hardware/ai_slot.dm b/code/modules/modular_computers/hardware/ai_slot.dm
index 5d42747308e..c0eecefcb6d 100644
--- a/code/modules/modular_computers/hardware/ai_slot.dm
+++ b/code/modules/modular_computers/hardware/ai_slot.dm
@@ -7,13 +7,14 @@
device_type = MC_AI
expansion_hw = TRUE
- var/obj/item/aicard/stored_card = null
+ var/obj/item/aicard/stored_card
var/locked = FALSE
-/obj/item/computer_hardware/ai_slot/handle_atom_del(atom/A)
+///What happens when the intellicard is removed (or deleted) from the module, through try_eject() or not.
+/obj/item/computer_hardware/ai_slot/Exited(atom/A, atom/newloc)
if(A == stored_card)
- try_eject(forced = TRUE)
- . = ..()
+ stored_card = null
+ return ..()
/obj/item/computer_hardware/ai_slot/examine(mob/user)
. = ..()
@@ -55,7 +56,6 @@
user.put_in_hands(stored_card)
else
stored_card.forceMove(drop_location())
- stored_card = null
return TRUE
return FALSE
diff --git a/code/modules/modular_computers/hardware/battery_module.dm b/code/modules/modular_computers/hardware/battery_module.dm
index 0668248315b..5c046ddeaf0 100644
--- a/code/modules/modular_computers/hardware/battery_module.dm
+++ b/code/modules/modular_computers/hardware/battery_module.dm
@@ -4,25 +4,28 @@
icon_state = "cell_con"
critical = 1
malfunction_probability = 1
- var/obj/item/stock_parts/cell/battery = null
+ var/obj/item/stock_parts/cell/battery
device_type = MC_CELL
/obj/item/computer_hardware/battery/get_cell()
return battery
-/obj/item/computer_hardware/battery/New(loc, battery_type = null)
+/obj/item/computer_hardware/battery/Initialize(mapload, battery_type)
+ . = ..()
if(battery_type)
battery = new battery_type(src)
- ..()
/obj/item/computer_hardware/battery/Destroy()
- . = ..()
- QDEL_NULL(battery)
+ battery = null
+ return ..()
-/obj/item/computer_hardware/battery/handle_atom_del(atom/A)
+///What happens when the battery is removed (or deleted) from the module, through try_eject() or not.
+/obj/item/computer_hardware/battery/Exited(atom/A, atom/newloc)
if(A == battery)
- try_eject(forced = TRUE)
- . = ..()
+ battery = null
+ if(holder?.enabled && !holder.use_power())
+ holder.shutdown_computer()
+ return ..()
/obj/item/computer_hardware/battery/try_insert(obj/item/I, mob/living/user = null)
if(!holder)
@@ -47,31 +50,18 @@
return TRUE
-
-/obj/item/computer_hardware/battery/try_eject(mob/living/user = null, forced = FALSE)
+/obj/item/computer_hardware/battery/try_eject(mob/living/user, forced = FALSE)
if(!battery)
to_chat(user, "There is no power cell connected to \the [src].")
return FALSE
else
if(user)
user.put_in_hands(battery)
+ to_chat(user, "You detach \the [battery] from \the [src].")
else
battery.forceMove(drop_location())
- to_chat(user, "You detach \the [battery] from \the [src].")
- battery = null
-
- if(holder)
- if(holder.enabled && !holder.use_power())
- holder.shutdown_computer()
-
return TRUE
-
-
-
-
-
-
/obj/item/stock_parts/cell/computer
name = "standard battery"
desc = "A standard power cell, commonly seen in high-end portable microcomputers or low-end laptops."
@@ -80,7 +70,6 @@
w_class = WEIGHT_CLASS_TINY
maxcharge = 750
-
/obj/item/stock_parts/cell/computer/advanced
name = "advanced battery"
desc = "An advanced power cell, often used in most laptops. It is too large to be fitted into smaller devices."
diff --git a/code/modules/modular_computers/hardware/card_slot.dm b/code/modules/modular_computers/hardware/card_slot.dm
index 5b58c0f2899..4c985c4b3ba 100644
--- a/code/modules/modular_computers/hardware/card_slot.dm
+++ b/code/modules/modular_computers/hardware/card_slot.dm
@@ -6,12 +6,26 @@
w_class = WEIGHT_CLASS_TINY
device_type = MC_CARD
- var/obj/item/card/id/stored_card = null
+ var/obj/item/card/id/stored_card
-/obj/item/computer_hardware/card_slot/handle_atom_del(atom/A)
+///What happens when the ID card is removed (or deleted) from the module, through try_eject() or not.
+/obj/item/computer_hardware/card_slot/Exited(atom/A, atom/newloc)
if(A == stored_card)
- try_eject(null, TRUE)
- . = ..()
+ stored_card = null
+ if(holder)
+ if(holder.active_program)
+ holder.active_program.event_idremoved(0)
+ for(var/p in holder.idle_threads)
+ var/datum/computer_file/program/computer_program = p
+ computer_program.event_idremoved(1)
+
+ holder.update_slot_icon()
+
+ if(ishuman(holder.loc))
+ var/mob/living/carbon/human/human_wearer = holder.loc
+ if(human_wearer.wear_id == holder)
+ human_wearer.sec_hud_set_ID()
+ return ..()
/obj/item/computer_hardware/card_slot/Destroy()
try_eject(forced = TRUE)
@@ -81,23 +95,6 @@
user.put_in_hands(stored_card)
else
stored_card.forceMove(drop_location())
- stored_card = null
-
- if(holder)
- if(holder.active_program)
- holder.active_program.event_idremoved(0)
-
- for(var/p in holder.idle_threads)
- var/datum/computer_file/program/computer_program = p
- computer_program.event_idremoved(1)
-
- holder.update_slot_icon()
-
- var/holder_loc = holder.loc
- if(ishuman(holder_loc))
- var/mob/living/carbon/human/human_wearer = holder_loc
- if(human_wearer.wear_id == holder)
- human_wearer.sec_hud_set_ID()
to_chat(user, "You remove the card from \the [src].")
playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE)