From 3611e61de3123b244d05873505dcf0543e2f848f Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Sun, 2 Jun 2024 14:53:44 +0300 Subject: [PATCH] [FIX] update gunhud on cranks (#286) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## About The Pull Request Ручная перезарядка теперь обновляет счетчик патронов ## Changelog :cl: fix: Ручная перезарядка теперь обновляет счетчик патронов /:cl: --- modular_bandastation/_defines220/_defines220.dme | 1 + modular_bandastation/_defines220/code/signals_item.dm | 2 ++ modular_bandastation/_signals220/_signals220.dme | 1 + modular_bandastation/_signals220/code/signals_item.dm | 3 +++ modular_bandastation/gunhud/code/gunhud_component.dm | 8 ++++++++ 5 files changed, 15 insertions(+) create mode 100644 modular_bandastation/_defines220/code/signals_item.dm create mode 100644 modular_bandastation/_signals220/code/signals_item.dm diff --git a/modular_bandastation/_defines220/_defines220.dme b/modular_bandastation/_defines220/_defines220.dme index a9ec1bda68950..c41c71b2be2a6 100644 --- a/modular_bandastation/_defines220/_defines220.dme +++ b/modular_bandastation/_defines220/_defines220.dme @@ -1,6 +1,7 @@ #include "_defines220.dm" #include "code/signals_atom.dm" +#include "code/signals_item.dm" #include "code/defines/keybindings.dm" #include "code/defines/misc.dm" #include "code/defines/spans.dm" diff --git a/modular_bandastation/_defines220/code/signals_item.dm b/modular_bandastation/_defines220/code/signals_item.dm new file mode 100644 index 0000000000000..815e17895d9f3 --- /dev/null +++ b/modular_bandastation/_defines220/code/signals_item.dm @@ -0,0 +1,2 @@ +///from base of obj/item/stock_parts/cell/give(): (power_used) +#define COMSIG_CELL_GIVE "cell_give" diff --git a/modular_bandastation/_signals220/_signals220.dme b/modular_bandastation/_signals220/_signals220.dme index 26671df7a7f98..bd802123107f3 100644 --- a/modular_bandastation/_signals220/_signals220.dme +++ b/modular_bandastation/_signals220/_signals220.dme @@ -1,5 +1,6 @@ #include "_signals220.dm" +#include "code/signals_item.dm" #include "code/signals_mob/signals_mob_ai.dm" #include "code/signals_mob/signals_mob_carbon.dm" #include "code/signals_mob/signals_mob_living.dm" diff --git a/modular_bandastation/_signals220/code/signals_item.dm b/modular_bandastation/_signals220/code/signals_item.dm new file mode 100644 index 0000000000000..918deb48a9187 --- /dev/null +++ b/modular_bandastation/_signals220/code/signals_item.dm @@ -0,0 +1,3 @@ +/obj/item/stock_parts/cell/give(amount) + . = ..() + SEND_SIGNAL(src, COMSIG_CELL_GIVE, .) diff --git a/modular_bandastation/gunhud/code/gunhud_component.dm b/modular_bandastation/gunhud/code/gunhud_component.dm index d24885f9002df..8f89869cdf875 100644 --- a/modular_bandastation/gunhud/code/gunhud_component.dm +++ b/modular_bandastation/gunhud/code/gunhud_component.dm @@ -28,6 +28,10 @@ RegisterSignals(parent, list(COMSIG_PREQDELETED, COMSIG_ITEM_DROPPED), PROC_REF(turn_off)) RegisterSignals(parent, list(COMSIG_UPDATE_GUNHUD, COMSIG_GUN_CHAMBER_PROCESSED), PROC_REF(update_hud)) + if(istype(parent, /obj/item/gun/energy)) + var/obj/item/gun/energy/energy_gun = parent + if(energy_gun.cell) + RegisterSignal(energy_gun.cell, COMSIG_CELL_GIVE, PROC_REF(update_hud)) hud.turn_on() update_hud() @@ -36,6 +40,10 @@ SIGNAL_HANDLER UnregisterSignal(parent, list(COMSIG_PREQDELETED, COMSIG_ITEM_DROPPED, COMSIG_UPDATE_GUNHUD, COMSIG_GUN_CHAMBER_PROCESSED)) + if(istype(parent, /obj/item/gun/energy)) + var/obj/item/gun/energy/energy_gun = parent + if(energy_gun.cell) + UnregisterSignal(energy_gun.cell, COMSIG_CELL_GIVE) if(hud) hud.turn_off()