Skip to content

Commit

Permalink
worn overlays proc sends a signal (tgstation#73101)
Browse files Browse the repository at this point in the history
what the title says, it sends the list of overlays to be edited and some
other stuff
makes modsuits use this
  • Loading branch information
Fikou authored Feb 2, 2023
1 parent 0ac4149 commit a11517e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
2 changes: 2 additions & 0 deletions code/__DEFINES/dcs/signals/signals_object.dm
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@
#define COMPONENT_OFFER_TAKE_INTERRUPT (1<<0)
/// sent from obj/effect/attackby(): (/obj/effect/hit_effect, /mob/living/attacker, params)
#define COMSIG_ITEM_ATTACK_EFFECT "item_effect_attacked"
/// Called by /obj/item/proc/worn_overlays(list/overlays, mutable_appearance/standing, isinhands, icon_file)
#define COMSIG_ITEM_GET_WORN_OVERLAYS "item_get_worn_overlays"

///from base of [/obj/item/proc/tool_check_callback]: (mob/living/user)
#define COMSIG_TOOL_IN_USE "tool_in_use"
Expand Down
7 changes: 3 additions & 4 deletions code/modules/mob/living/carbon/carbon_update_icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,9 @@
RETURN_TYPE(/list)

. = list()
if(!blocks_emissive)
return

. += emissive_blocker(standing.icon, standing.icon_state, src, alpha = standing.alpha)
if(blocks_emissive)
. += emissive_blocker(standing.icon, standing.icon_state, src, alpha = standing.alpha)
SEND_SIGNAL(src, COMSIG_ITEM_GET_WORN_OVERLAYS, ., standing, isinhands, icon_file)

///Checks to see if any bodyparts need to be redrawn, then does so. update_limb_data = TRUE redraws the limbs to conform to the owner.
/mob/living/carbon/proc/update_body_parts(update_limb_data)
Expand Down
10 changes: 2 additions & 8 deletions code/modules/mod/mod_control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -433,14 +433,6 @@
retract(null, part)
return ..()

/obj/item/mod/control/worn_overlays(mutable_appearance/standing, isinhands = FALSE, icon_file)
. = ..()
for(var/obj/item/mod/module/module as anything in modules)
var/list/module_icons = module.generate_worn_overlay(standing)
if(!length(module_icons))
continue
. += module_icons

/obj/item/mod/control/update_icon_state()
icon_state = "[skin]-[base_icon_state][active ? "-sealed" : ""]"
return ..()
Expand Down Expand Up @@ -553,6 +545,7 @@
modules += new_module
complexity += new_module.complexity
new_module.mod = src
new_module.RegisterSignal(src, COMSIG_ITEM_GET_WORN_OVERLAYS, TYPE_PROC_REF(/obj/item/mod/module, add_module_overlay))
new_module.on_install()
if(wearer)
new_module.on_equip()
Expand All @@ -571,6 +564,7 @@
old_module.on_suit_deactivation(deleting = deleting)
if(old_module.active)
old_module.on_deactivation(display_message = !deleting, deleting = deleting)
old_module.UnregisterSignal(src, COMSIG_ITEM_GET_WORN_OVERLAYS)
old_module.on_uninstall(deleting = deleting)
QDEL_LIST_ASSOC_VAL(old_module.pinned_to)
old_module.mod = null
Expand Down
6 changes: 6 additions & 0 deletions code/modules/mod/modules/_module.dm
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@
device = null
qdel(src)

/// Adds the worn overlays to the suit.
/obj/item/mod/module/proc/add_module_overlay(obj/item/source, list/overlays, mutable_appearance/standing, isinhands, icon_file)
SIGNAL_HANDLER

overlays += generate_worn_overlay(standing)

/// Generates an icon to be used for the suit's worn overlays
/obj/item/mod/module/proc/generate_worn_overlay(mutable_appearance/standing)
. = list()
Expand Down

0 comments on commit a11517e

Please sign in to comment.