Skip to content

Commit

Permalink
[FIX] update gunhud on cranks (#286)
Browse files Browse the repository at this point in the history
## About The Pull Request
Ручная перезарядка теперь обновляет счетчик патронов

## Changelog
:cl:
fix: Ручная перезарядка теперь обновляет счетчик патронов
/:cl:
  • Loading branch information
larentoun authored Jun 2, 2024
1 parent 2960f94 commit 3611e61
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions modular_bandastation/_defines220/_defines220.dme
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 2 additions & 0 deletions modular_bandastation/_defines220/code/signals_item.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
///from base of obj/item/stock_parts/cell/give(): (power_used)
#define COMSIG_CELL_GIVE "cell_give"
1 change: 1 addition & 0 deletions modular_bandastation/_signals220/_signals220.dme
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 3 additions & 0 deletions modular_bandastation/_signals220/code/signals_item.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/obj/item/stock_parts/cell/give(amount)
. = ..()
SEND_SIGNAL(src, COMSIG_CELL_GIVE, .)
8 changes: 8 additions & 0 deletions modular_bandastation/gunhud/code/gunhud_component.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 3611e61

Please sign in to comment.