MODules don't create visual overlays when their required part isn't deployed (#87452)

## About The Pull Request
#86825 allowed MODsuits to only have a few of their parts deployed but
didn't change MODule overlay code, resulting in modules like welding
visor showing up even if you only have your gloves active.

## Why It's Good For The Game

Glitchy visuals begone.

## Changelog
🆑
fix: MODules don't create visual overlays when their required part isn't
deployed
/🆑

---------

Co-authored-by: Fikou <23585223+Fikou@users.noreply.github.com>
Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
This commit is contained in:
SmArtKar
2024-10-27 22:01:45 +00:00
committed by GitHub
co-authored by Fikou LemonInTheDark
parent cd3fc8a67f
commit 7247928ec4
8 changed files with 74 additions and 20 deletions
+4 -2
View File
@@ -226,7 +226,8 @@
part.heat_protection = NONE
part.cold_protection = NONE
part.alternate_worn_layer = part_datum.unsealed_layer
wearer.update_clothing(part.slot_flags)
generate_suit_mask()
wearer.update_clothing(part.slot_flags | slot_flags)
wearer.update_obscured_slots(part.visor_flags_inv)
if((part.clothing_flags & (MASKINTERNALS|HEADINTERNALS)) && wearer.invalid_internals())
wearer.cutoff_internals()
@@ -263,8 +264,9 @@
continue
module.on_suit_deactivation()
update_speed()
update_appearance(UPDATE_ICON_STATE)
update_charge_alert()
update_appearance(UPDATE_ICON_STATE)
generate_suit_mask()
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.
+24
View File
@@ -475,6 +475,30 @@
wearer.update_spacesuit_hud_icon("0")
wearer = null
/obj/item/mod/control/proc/get_sealed_slots(list/parts)
var/covered_slots = NONE
for(var/obj/item/part as anything in parts)
if(!get_part_datum(part).sealed)
parts -= part
continue
covered_slots |= part.slot_flags
return covered_slots
/obj/item/mod/control/proc/generate_suit_mask()
var/list/parts = get_parts(all = TRUE)
var/covered_slots = get_sealed_slots(parts)
if(GLOB.mod_masks[skin])
if(GLOB.mod_masks[skin]["[covered_slots]"])
return GLOB.mod_masks[skin]["[covered_slots]"]
else
GLOB.mod_masks[skin] = list()
var/icon/slot_mask = icon('icons/blanks/32x32.dmi', "nothing")
for(var/obj/item/part as anything in parts)
slot_mask.Blend(icon(part.worn_icon, part.icon_state), ICON_OVERLAY)
slot_mask.Blend("#fff", ICON_ADD)
GLOB.mod_masks[skin]["[covered_slots]"] = slot_mask
return GLOB.mod_masks[skin]["[covered_slots]"]
/obj/item/mod/control/proc/clean_up()
if(QDELING(src))
unset_wearer()
+36 -10
View File
@@ -45,6 +45,8 @@
var/allow_flags = NONE
/// A list of slots required in the suit to work. Formatted like list(x|y, z, ...) where either x or y are required and z is required.
var/list/required_slots = list()
/// If TRUE worn overlay will be masked with the suit, preventing any bits from poking out of its controur
var/mask_worn_overlay = FALSE
/// Timer for the cooldown
COOLDOWN_DECLARE(cooldown_timer)
@@ -335,23 +337,47 @@
/// Generates an icon to be used for the suit's worn overlays
/obj/item/mod/module/proc/generate_worn_overlay(mutable_appearance/standing)
. = list()
if(!mod.active)
if(!mod.active || !has_required_parts(mod.mod_parts, need_extended = TRUE))
return
var/used_overlay
if(overlay_state_use && !COOLDOWN_FINISHED(src, cooldown_timer))
used_overlay = overlay_state_use
else if(overlay_state_active && active)
used_overlay = overlay_state_active
else if(overlay_state_inactive)
used_overlay = overlay_state_inactive
var/used_overlay = get_current_overlay_state()
if (!used_overlay)
return
var/mutable_appearance/module_icon
if(mask_worn_overlay)
module_icon = mutable_appearance(get_module_icon_cache(used_overlay), layer = standing.layer + 0.1)
else
return
var/mutable_appearance/module_icon = mutable_appearance(overlay_icon_file, used_overlay, layer = standing.layer + 0.1)
module_icon = mutable_appearance(overlay_icon_file, used_overlay, layer = standing.layer + 0.1)
if(!use_mod_colors)
module_icon.appearance_flags |= RESET_COLOR
. += module_icon
SEND_SIGNAL(src, COMSIG_MODULE_GENERATE_WORN_OVERLAY, ., standing)
/obj/item/mod/module/proc/get_current_overlay_state()
if(overlay_state_use && !COOLDOWN_FINISHED(src, cooldown_timer))
return overlay_state_use
if(overlay_state_active && active)
return overlay_state_active
if(overlay_state_inactive)
return overlay_state_inactive
return null
/obj/item/mod/module/proc/get_module_icon_cache(used_overlay)
var/covered_slots = mod.get_sealed_slots(mod.get_parts(all = TRUE))
if (GLOB.mod_module_overlays[mod.skin])
if (GLOB.mod_module_overlays[mod.skin]["[covered_slots]"])
if (GLOB.mod_module_overlays[mod.skin]["[covered_slots]"][used_overlay])
return GLOB.mod_module_overlays[mod.skin]["[covered_slots]"][used_overlay]
else
GLOB.mod_module_overlays[mod.skin]["[covered_slots]"] = list()
else
GLOB.mod_module_overlays[mod.skin] = list()
GLOB.mod_module_overlays[mod.skin]["[covered_slots]"] = list()
var/icon/mod_mask = icon(mod.generate_suit_mask())
mod_mask.Blend(icon(overlay_icon_file, used_overlay), ICON_MULTIPLY)
GLOB.mod_module_overlays[mod.skin]["[covered_slots]"][used_overlay] = mod_mask
return GLOB.mod_module_overlays[mod.skin]["[covered_slots]"][used_overlay]
/// Updates the signal used by active modules to be activated
/obj/item/mod/module/proc/update_signal(value)
switch(value)
+3 -6
View File
@@ -16,6 +16,7 @@
overlay_state_inactive = "module_armorbooster_off"
overlay_state_active = "module_armorbooster_on"
use_mod_colors = TRUE
mask_worn_overlay = TRUE
/// Whether or not this module removes pressure protection.
var/remove_pressure_protection = TRUE
/// Speed added to the control unit.
@@ -213,6 +214,7 @@
removable = FALSE
incompatible_modules = list(/obj/item/mod/module/insignia)
overlay_state_inactive = "module_insignia"
mask_worn_overlay = TRUE
/obj/item/mod/module/insignia/generate_worn_overlay(mutable_appearance/standing)
overlay_state_inactive = "[initial(overlay_state_inactive)]-[mod.skin]"
@@ -266,6 +268,7 @@
//Bite of 87 Springlock - Equips faster, disguised as DNA lock.
/obj/item/mod/module/springlock/bite_of_87
step_change = 0.1
/obj/item/mod/module/springlock/bite_of_87/Initialize(mapload)
. = ..()
@@ -276,12 +279,6 @@
complexity = initial(the_dna_lock_behind_the_slaughter.complexity)
use_energy_cost = initial(the_dna_lock_behind_the_slaughter.use_energy_cost)
/obj/item/mod/module/springlock/bite_of_87/on_install()
mod.activation_step_time *= 0.1
/obj/item/mod/module/springlock/bite_of_87/on_uninstall(deleting = FALSE)
mod.activation_step_time *= 10
/obj/item/mod/module/springlock/bite_of_87/on_suit_activation()
..()
if(check_holidays(APRIL_FOOLS) || prob(1))
+3 -2
View File
@@ -14,12 +14,13 @@
var/static/list/gas_connections = list(
COMSIG_TURF_EXPOSE = PROC_REF(on_wearer_exposed_gas),
)
var/step_change = 0.5
/obj/item/mod/module/springlock/on_install()
mod.activation_step_time *= 0.5
mod.activation_step_time *= step_change
/obj/item/mod/module/springlock/on_uninstall(deleting = FALSE)
mod.activation_step_time *= 2
mod.activation_step_time /= step_change
/obj/item/mod/module/springlock/on_suit_activation()
RegisterSignal(mod.wearer, COMSIG_ATOM_EXPOSE_REAGENTS, PROC_REF(on_wearer_exposed))