save shell component properly loads shells that come with their own circuit (#63628)

Attempting to load a BCI or circuit MODsuit module with the save shell component yields an empty circuit. This PR fixes that by making the save shell component check for and delete any pre-existing circuit in the loaded shell.
This commit is contained in:
Y0SH1M4S73R
2021-12-26 17:37:29 -05:00
committed by GitHub
parent 1503990809
commit 9653fa06e0
@@ -28,7 +28,12 @@
/obj/item/circuit_component/save_shell/proc/on_post_load(datum/source)
SIGNAL_HANDLER
loaded_shell.AddComponent(/datum/component/shell, starting_circuit = parent)
var/datum/component/shell/shell_component = loaded_shell.GetComponent(/datum/component/shell)
if(!istype(shell_component))
loaded_shell.AddComponent(/datum/component/shell, starting_circuit = parent)
else
QDEL_NULL(shell_component.attached_circuit)
shell_component.attach_circuit(parent)
on_loaded.set_output(COMPONENT_SIGNAL)
/obj/item/circuit_component/save_shell/proc/on_pre_save_to_json(datum/source, list/general_data)