ref: Ammo HUD, more modularisation (#21406)

* ref: welding tool ammo hud

* ref: guns ammo_hud

* update readme

* fix: set welding ammo update
This commit is contained in:
larentoun
2023-05-31 11:43:42 -07:00
committed by GitHub
parent 053e29196d
commit 33d73d6988
10 changed files with 45 additions and 13 deletions
@@ -223,7 +223,6 @@
if(get_fuel() >= used)
reagents.remove_reagent(/datum/reagent/fuel, used)
SEND_SIGNAL(src, COMSIG_UPDATE_AMMO_HUD) //SKYRAT EDIT ADDITION
check_fuel()
return TRUE
else
@@ -237,7 +236,6 @@
. = welding
welding = new_value
set_light_on(welding)
SEND_SIGNAL(src, COMSIG_UPDATE_AMMO_HUD) //SKYRAT EDIT ADDITION
/// Turns off the welder if there is no more fuel (does this really need to be its own proc?)
@@ -396,7 +394,6 @@
/obj/item/weldingtool/abductor/process()
if(get_fuel() <= max_fuel)
reagents.add_reagent(/datum/reagent/fuel, 1)
SEND_SIGNAL(src, COMSIG_UPDATE_AMMO_HUD) //SKYRAT EDIT ADDITION
..()
/obj/item/weldingtool/hugetank
@@ -427,7 +424,6 @@
if(get_fuel() < max_fuel && nextrefueltick < world.time)
nextrefueltick = world.time + 10
reagents.add_reagent(/datum/reagent/fuel, 1)
SEND_SIGNAL(src, COMSIG_UPDATE_AMMO_HUD) //SKYRAT EDIT ADDITION
#undef WELDER_FUEL_BURN_INTERVAL
@@ -339,7 +339,6 @@
balloon_alert(user, "[magazine_wording] unloaded")
update_appearance()
SEND_SIGNAL(src, COMSIG_UPDATE_AMMO_HUD) //SKYRAT EDIT ADDITION
/obj/item/gun/ballistic/can_shoot()
return chambered?.loaded_projectile
@@ -452,7 +451,6 @@
bolt_locked = TRUE
playsound(src, bolt_drop_sound, bolt_drop_sound_volume)
update_appearance()
SEND_SIGNAL(src, COMSIG_UPDATE_AMMO_HUD)
///postfire empty checks for bolt locking and sound alarms
/obj/item/gun/ballistic/proc/postfire_empty_checks(last_shot_succeeded)
-2
View File
@@ -152,7 +152,6 @@
cell.give(100)
if(!chambered) //if empty chamber we try to charge a new shot
recharge_newshot(TRUE)
SEND_SIGNAL(src, COMSIG_UPDATE_AMMO_HUD) //SKYRAT EDIT ADDITION
update_appearance()
/obj/item/gun/energy/attack_self(mob/living/user as mob)
@@ -210,7 +209,6 @@
chambered = null
recharge_newshot(TRUE)
update_appearance()
SEND_SIGNAL(src, COMSIG_UPDATE_AMMO_HUD) //SKYRAT EDIT ADDITION
/obj/item/gun/energy/update_icon_state()
var/skip_inhand = initial(inhand_icon_state) //only build if we aren't using a preset inhand icon
@@ -298,7 +298,6 @@
user.visible_message(span_notice("[user] refills [user.p_their()] [W.name]."), span_notice("You refill [W]."))
playsound(src, 'sound/effects/refill.ogg', 50, TRUE)
W.update_appearance()
SEND_SIGNAL(src, COMSIG_UPDATE_AMMO_HUD) //SKYRAT EDIT ADDITION
else
user.visible_message(span_danger("[user] catastrophically fails at refilling [user.p_their()] [I.name]!"), span_userdanger("That was stupid of you."))
log_bomber(user, "detonated a", src, "via welding tool")
@@ -4,3 +4,23 @@
/// How long it takes to weld your own robotic limbs.
var/other_delay = 1 SECONDS
/obj/item/weldingtool/Initialize(mapload)
. = ..()
RegisterSignals(reagents,
list(
COMSIG_REAGENTS_ADD_REAGENT,
COMSIG_REAGENTS_NEW_REAGENT,
COMSIG_REAGENTS_REM_REAGENT,
COMSIG_REAGENTS_DEL_REAGENT,
COMSIG_REAGENTS_CLEAR_REAGENTS,
COMSIG_REAGENTS_REACTED,),
PROC_REF(update_ammo_hud))
/obj/item/weldingtool/set_welding(new_value)
. = ..()
update_ammo_hud()
/obj/item/weldingtool/proc/update_ammo_hud()
SIGNAL_HANDLER
SEND_SIGNAL(src, COMSIG_UPDATE_AMMO_HUD)
@@ -0,0 +1,8 @@
/obj/item/gun/ballistic/eject_magazine(mob/user, display_message, obj/item/ammo_box/magazine/tac_load)
. = ..()
SEND_SIGNAL(src, COMSIG_UPDATE_AMMO_HUD)
/obj/item/gun/ballistic/insert_magazine(mob/user, obj/item/ammo_box/magazine/AM, display_message)
. = ..()
if(.)
SEND_SIGNAL(src, COMSIG_UPDATE_AMMO_HUD)
@@ -0,0 +1,8 @@
/obj/item/gun/energy/process(seconds_per_tick)
. = ..()
if(selfcharge && cell && cell.percent() < 100)
SEND_SIGNAL(src, COMSIG_UPDATE_AMMO_HUD)
/obj/item/gun/energy/select_fire(mob/living/user)
. = ..()
SEND_SIGNAL(src, COMSIG_UPDATE_AMMO_HUD)
@@ -14,8 +14,6 @@
/datum/component/ammo_hud/proc/wake_up(datum/source, mob/user, slot)
SIGNAL_HANDLER
RegisterSignals(parent, list(COMSIG_PARENT_PREQDELETED, COMSIG_ITEM_DROPPED), PROC_REF(turn_off))
if(ishuman(user))
var/mob/living/carbon/human/H = user
if(H.is_holding(parent))
@@ -28,7 +26,8 @@
/datum/component/ammo_hud/proc/turn_on()
SIGNAL_HANDLER
RegisterSignal(parent, COMSIG_UPDATE_AMMO_HUD, PROC_REF(update_hud))
RegisterSignals(parent, list(COMSIG_PARENT_PREQDELETED, COMSIG_ITEM_DROPPED), PROC_REF(turn_off))
RegisterSignals(parent, list(COMSIG_UPDATE_AMMO_HUD, COMSIG_GUN_CHAMBER_PROCESSED), PROC_REF(update_hud))
hud.turn_on()
update_hud()
@@ -36,7 +35,7 @@
/datum/component/ammo_hud/proc/turn_off()
SIGNAL_HANDLER
UnregisterSignal(parent, list(COMSIG_PARENT_PREQDELETED, COMSIG_ITEM_DROPPED, COMSIG_UPDATE_AMMO_HUD))
UnregisterSignal(parent, list(COMSIG_PARENT_PREQDELETED, COMSIG_ITEM_DROPPED, COMSIG_UPDATE_AMMO_HUD, COMSIG_GUN_CHAMBER_PROCESSED))
if(hud)
hud.turn_off()
+4
View File
@@ -17,6 +17,9 @@ Adds a dynamic hud system for energy and some ballistics guns.
### Master file additions
- Hud directory > _defines.dm, human.dm, hud.dm
- `modular_skyrat\master_files\code\game\objects\items\tools\weldingtool.dm`: `proc/Initialize`, `proc/set_welding`
- `modular_skyrat\master_files\code\modules\projectiles\guns\ballistic.dm`: `proc/eject_magazine`, `proc/insert_magazine`
- `modular_skyrat\master_files\code\modules\projectiles\guns\energy.dm`: `proc/process`, `proc/select_fire`
### Included files that are not contained in this module:
@@ -24,3 +27,4 @@ Adds a dynamic hud system for energy and some ballistics guns.
### Credits:
Gandalf2k15 - OG creation.
Larentoun - modularisation
+2
View File
@@ -5597,6 +5597,8 @@
#include "modular_skyrat\master_files\code\modules\power\singularity\containment_field.dm"
#include "modular_skyrat\master_files\code\modules\projectiles\boxes_magazines\external\shotgun.dm"
#include "modular_skyrat\master_files\code\modules\projectiles\boxes_magazines\external\smg.dm"
#include "modular_skyrat\master_files\code\modules\projectiles\guns\ballistic.dm"
#include "modular_skyrat\master_files\code\modules\projectiles\guns\energy.dm"
#include "modular_skyrat\master_files\code\modules\projectiles\guns\ballistic\revolver.dm"
#include "modular_skyrat\master_files\code\modules\projectiles\guns\ballistic\bows\_bow.dm"
#include "modular_skyrat\master_files\code\modules\projectiles\guns\ballistic\bows\bow_quivers.dm"