/
Lachklen
/
MYtgstation
Обзор
Документация
Войти
/
Lachklen
/
MYtgstation
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
code/modules/wiremod/components/abstract/variable.dm
64 строки
2 KB
LemonInTheDark
Pulls apart the vestiges of components still hanging onto signals (#75914)
09 июн 2023, 09:14
Не верифицирован
09 июн 2023, 09:14
ae5a4f9
Код
Авторство
О чём код?
/** * # Variable Component * * Abstract component for handling variables */ /obj/item/circuit_component/variable display_name = "Abstract Variable Component" desc = "You shouldn't be seeing this." /// Variable name var/datum/port/input/option/variable_name var/datum/circuit_variable/current_variable circuit_size = 0 var/should_listen = FALSE /obj/item/circuit_component/variable/populate_options() variable_name = add_option_port("Variable", null) /obj/item/circuit_component/variable/add_to(obj/item/integrated_circuit/added_to) . = ..() variable_name.possible_options = get_variable_list(added_to) /obj/item/circuit_component/variable/proc/get_variable_list(obj/item/integrated_circuit/integrated_circuit) return integrated_circuit.circuit_variables /obj/item/circuit_component/variable/removed_from(obj/item/integrated_circuit/removed_from) variable_name.possible_options = null return ..() /obj/item/circuit_component/variable/pre_input_received(datum/port/input/port) if(!parent) return var/variable_string = variable_name.value if(!variable_string) remove_current_variable() return var/datum/circuit_variable/variable = parent.circuit_variables[variable_string] if(!variable) remove_current_variable() return set_current_variable(variable) /obj/item/circuit_component/variable/proc/remove_current_variable() SIGNAL_HANDLER if(current_variable) if(should_listen) current_variable.remove_listener(src) UnregisterSignal(current_variable, COMSIG_QDELETING) current_variable = null /obj/item/circuit_component/variable/proc/set_current_variable(datum/circuit_variable/variable) if(variable == current_variable) return remove_current_variable() current_variable = variable if(should_listen) current_variable.add_listener(src) RegisterSignal(current_variable, COMSIG_QDELETING, PROC_REF(remove_current_variable))