diff --git a/code/__DEFINES/alerts.dm b/code/__DEFINES/alerts.dm index 3d09a3e5a22..e6f4feb259a 100644 --- a/code/__DEFINES/alerts.dm +++ b/code/__DEFINES/alerts.dm @@ -47,7 +47,6 @@ #define ALERT_HACKING_APC "hackingapc" /** MODsuit/Mech related */ -#define ALERT_MODSUIT_CHARGE "mod_charge" #define ALERT_MECH_DAMAGE "mech_damage" /** Food related */ diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index ec03414abfc..ed11f592472 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -808,8 +808,7 @@ hud_used.stamina.icon_state = "stamina_full" /mob/living/carbon/proc/update_spacesuit_hud_icon(cell_state = "empty") - if(hud_used?.spacesuit) - hud_used.spacesuit.icon_state = "spacesuit_[cell_state]" + hud_used?.spacesuit?.icon_state = "spacesuit_[cell_state]" /mob/living/carbon/set_health(new_value) . = ..() diff --git a/code/modules/mod/mod_activation.dm b/code/modules/mod/mod_activation.dm index c45752769a5..9e5b8ea5277 100644 --- a/code/modules/mod/mod_activation.dm +++ b/code/modules/mod/mod_activation.dm @@ -238,7 +238,8 @@ for(var/obj/item/mod/module/module as anything in modules) module.on_suit_deactivation() update_speed() - update_icon_state() + update_appearance(UPDATE_ICON_STATE) + update_charge_alert() wearer.update_clothing(slot_flags) /// Quickly deploys all the suit parts and if successful, seals them and turns on the suit. Intended mostly for outfits. diff --git a/code/modules/mod/mod_control.dm b/code/modules/mod/mod_control.dm index 81a31ee0f84..e113bbb5531 100644 --- a/code/modules/mod/mod_control.dm +++ b/code/modules/mod/mod_control.dm @@ -243,7 +243,6 @@ if(malfunctioning) malfunctioning_charge_drain = rand(1,20) subtract_charge((charge_drain + malfunctioning_charge_drain) * seconds_per_tick) - update_charge_alert() for(var/obj/item/mod/module/module as anything in modules) if(malfunctioning && module.active && SPT_PROB(5, seconds_per_tick)) module.on_deactivation(display_message = TRUE) @@ -319,7 +318,6 @@ wrench.play_tool_sound(src, 100) balloon_alert(user, "core removed") core.forceMove(drop_location()) - update_charge_alert() return TRUE return ..() @@ -402,7 +400,6 @@ attacking_core.install(src) balloon_alert(user, "core installed") playsound(src, 'sound/machines/click.ogg', 50, TRUE, SILENCED_SOUND_EXTRARANGE) - update_charge_alert() return TRUE else if(is_wire_tool(attacking_item) && open) wires.interact(user) @@ -487,8 +484,8 @@ for(var/obj/item/mod/module/module as anything in modules) module.on_unequip() UnregisterSignal(wearer, list(COMSIG_ATOM_EXITED, COMSIG_SPECIES_GAIN)) - wearer.clear_alert(ALERT_MODSUIT_CHARGE) SEND_SIGNAL(src, COMSIG_MOD_WEARER_UNSET, wearer) + wearer.update_spacesuit_hud_icon("0") wearer = null /obj/item/mod/control/proc/clean_up() @@ -631,13 +628,21 @@ /obj/item/mod/control/proc/check_charge(amount) return core?.check_charge(amount) || FALSE +/** + * Updates the wearer's hud according to the current state of the MODsuit + */ /obj/item/mod/control/proc/update_charge_alert() - if(!wearer) + if(isnull(wearer)) return - if(!core) - wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/nocore) - return - core.update_charge_alert() + var/state_to_use + if(!active) + state_to_use = "0" + else if(isnull(core)) + state_to_use = "coreless" + else + state_to_use = core.get_charge_icon_state() + + wearer.update_spacesuit_hud_icon(state_to_use || "0") /obj/item/mod/control/proc/update_speed() var/list/all_parts = mod_parts + src @@ -703,7 +708,6 @@ return if(part == core) core.uninstall() - update_charge_alert() return if(part.loc == wearer) return diff --git a/code/modules/mod/mod_core.dm b/code/modules/mod/mod_core.dm index d8138f6f291..5e7183e2563 100644 --- a/code/modules/mod/mod_core.dm +++ b/code/modules/mod/mod_core.dm @@ -18,9 +18,11 @@ mod = mod_unit mod.core = src forceMove(mod) + mod.update_charge_alert() /obj/item/mod/core/proc/uninstall() mod.core = null + mod.update_charge_alert() mod = null /obj/item/mod/core/proc/charge_source() @@ -41,8 +43,11 @@ /obj/item/mod/core/proc/check_charge(amount) return FALSE -/obj/item/mod/core/proc/update_charge_alert() - mod.wearer.clear_alert(ALERT_MODSUIT_CHARGE) +/** + * Gets what icon state to display on the HUD for the charge level of this core + */ +/obj/item/mod/core/proc/get_charge_icon_state() + return "0" /obj/item/mod/core/infinite name = "MOD infinite core" @@ -68,6 +73,9 @@ /obj/item/mod/core/infinite/check_charge(amount) return TRUE +/obj/item/mod/core/infinite/get_charge_icon_state() + return "high" + /obj/item/mod/core/standard name = "MOD standard core" icon_state = "mod-core-standard" @@ -80,8 +88,7 @@ var/obj/item/stock_parts/cell/cell /obj/item/mod/core/standard/Destroy() - if(cell) - QDEL_NULL(cell) + QDEL_NULL(cell) return ..() /obj/item/mod/core/standard/install(obj/item/mod/control/mod_unit) @@ -116,54 +123,57 @@ /obj/item/mod/core/standard/add_charge(amount) var/obj/item/stock_parts/cell/charge_source = charge_source() - if(!charge_source) + if(isnull(charge_source)) return FALSE - return charge_source.give(amount) + . = charge_source.give(amount) + if(.) + mod.update_charge_alert() + return . /obj/item/mod/core/standard/subtract_charge(amount) var/obj/item/stock_parts/cell/charge_source = charge_source() - if(!charge_source) + if(isnull(charge_source)) return FALSE - return charge_source.use(amount, TRUE) + . = charge_source.use(amount, TRUE) + if(.) + mod.update_charge_alert() + return . /obj/item/mod/core/standard/check_charge(amount) return charge_amount() >= amount -/obj/item/mod/core/standard/update_charge_alert() - var/obj/item/stock_parts/cell/charge_source = charge_source() - if(!charge_source) - mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/nocell) - return - var/remaining_cell = charge_amount() / max_charge_amount() - switch(remaining_cell) +/obj/item/mod/core/standard/get_charge_icon_state() + if(isnull(charge_source())) + return "missing" + + switch(round(charge_amount() / max_charge_amount(), 0.01)) if(0.75 to INFINITY) - mod.wearer.clear_alert(ALERT_MODSUIT_CHARGE) + return "high" if(0.5 to 0.75) - mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/lowcell, 1) + return "mid" if(0.25 to 0.5) - mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/lowcell, 2) - if(0.01 to 0.25) - mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/lowcell, 3) - else - mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/emptycell) + return "low" + if(0.02 to 0.25) + return "very_low" + + return "empty" /obj/item/mod/core/standard/proc/install_cell(new_cell) cell = new_cell cell.forceMove(src) - RegisterSignal(src, COMSIG_ATOM_EXITED, PROC_REF(on_exit)) + mod.update_charge_alert() /obj/item/mod/core/standard/proc/uninstall_cell() if(!cell) return + cell.update_appearance() cell = null - UnregisterSignal(src, COMSIG_ATOM_EXITED) + mod.update_charge_alert() -/obj/item/mod/core/standard/proc/on_exit(datum/source, obj/item/stock_parts/cell, direction) - SIGNAL_HANDLER - - if(!istype(cell) || cell.loc == src) - return - uninstall_cell() +/obj/item/mod/core/standard/Exited(atom/movable/gone, direction) + . = ..() + if(gone == cell) + uninstall_cell() /obj/item/mod/core/standard/proc/on_examine(datum/source, mob/examiner, list/examine_text) SIGNAL_HANDLER @@ -195,7 +205,6 @@ var/obj/item/cell_to_move = cell cell_to_move.forceMove(drop_location()) user.put_in_hands(cell_to_move) - mod.update_charge_alert() /obj/item/mod/core/standard/proc/on_attackby(datum/source, obj/item/attacking_item, mob/user) SIGNAL_HANDLER @@ -212,7 +221,6 @@ install_cell(attacking_item) mod.balloon_alert(user, "cell installed") playsound(mod, 'sound/machines/click.ogg', 50, TRUE, SILENCED_SOUND_EXTRARANGE) - mod.update_charge_alert() return COMPONENT_NO_AFTERATTACK return NONE @@ -232,7 +240,6 @@ SIGNAL_HANDLER add_charge(amount) - mod.update_charge_alert() /obj/item/mod/core/ethereal name = "MOD ethereal core" @@ -272,12 +279,8 @@ /obj/item/mod/core/ethereal/check_charge(amount) return charge_amount() >= amount*charge_modifier -/obj/item/mod/core/ethereal/update_charge_alert() - var/obj/item/organ/internal/stomach/ethereal/charge_source = charge_source() - if(charge_source) - mod.wearer.clear_alert(ALERT_MODSUIT_CHARGE) - return - mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/nocell) +/obj/item/mod/core/ethereal/get_charge_icon_state() + return charge_source() ? "0" : "missing" #define PLASMA_CORE_ORE_CHARGE 1500 #define PLASMA_CORE_SHEET_CHARGE 2000 @@ -318,28 +321,29 @@ /obj/item/mod/core/plasma/add_charge(amount) charge = min(maxcharge, charge + amount) + mod.update_charge_alert() return TRUE /obj/item/mod/core/plasma/subtract_charge(amount) charge = max(0, charge - amount) + mod.update_charge_alert() return TRUE /obj/item/mod/core/plasma/check_charge(amount) return charge_amount() >= amount -/obj/item/mod/core/plasma/update_charge_alert() - var/remaining_plasma = charge_amount() / max_charge_amount() - switch(remaining_plasma) +/obj/item/mod/core/plasma/get_charge_icon_state() + switch(round(charge_amount() / max_charge_amount(), 0.01)) if(0.75 to INFINITY) - mod.wearer.clear_alert(ALERT_MODSUIT_CHARGE) + return "high" if(0.5 to 0.75) - mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/lowcell/plasma, 1) + return "mid" if(0.25 to 0.5) - mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/lowcell/plasma, 2) - if(0.01 to 0.25) - mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/lowcell/plasma, 3) - else - mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/emptycell/plasma) + return "low" + if(0.02 to 0.25) + return "very_low" + + return "empty" /obj/item/mod/core/plasma/proc/on_attackby(datum/source, obj/item/attacking_item, mob/user) SIGNAL_HANDLER diff --git a/code/modules/mod/modules/_module.dm b/code/modules/mod/modules/_module.dm index aabd872a40f..32a8f2e6cbd 100644 --- a/code/modules/mod/modules/_module.dm +++ b/code/modules/mod/modules/_module.dm @@ -225,7 +225,6 @@ if(!check_power(amount)) return FALSE mod.subtract_charge(amount) - mod.update_charge_alert() return TRUE /// Checks if there is enough power in the suit diff --git a/icons/hud/screen_gen.dmi b/icons/hud/screen_gen.dmi index 2f4dd60b5d7..9792124d1b6 100644 Binary files a/icons/hud/screen_gen.dmi and b/icons/hud/screen_gen.dmi differ