From 99ff0ad3de8edb64f6caad29f70713f50f6d2016 Mon Sep 17 00:00:00 2001 From: Alan Date: Sat, 4 Oct 2025 13:18:59 -0400 Subject: [PATCH] Proof of concept/proposal: Add offset capability for monitor headwear, demonstrated by berets (#30555) * Add offset capability for monitor headwear, offset berets * test * Update code in line with warriorstar-orion's element method * Apply suggestions from code review Incorporate warriorstar-orion's updates Co-authored-by: warriorstar-orion Signed-off-by: Alan * Autodoc properly Co-authored-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com> Signed-off-by: Alan --------- Signed-off-by: Alan Co-authored-by: warriorstar-orion Co-authored-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com> --- code/datums/elements/clothing_adjustment.dm | 62 +++++++++++++++++++ code/modules/clothing/clothing.dm | 3 +- code/modules/clothing/head/beret.dm | 4 ++ code/modules/clothing/suits/wiz_robe.dm | 4 ++ .../living/carbon/human/human_update_icons.dm | 2 +- paradise.dme | 1 + 6 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 code/datums/elements/clothing_adjustment.dm diff --git a/code/datums/elements/clothing_adjustment.dm b/code/datums/elements/clothing_adjustment.dm new file mode 100644 index 00000000000..4cf9141a51c --- /dev/null +++ b/code/datums/elements/clothing_adjustment.dm @@ -0,0 +1,62 @@ +/// An element for making visual modifications to items when worn externally by +/// a carbon mob. This could range to anything from changing its pixel offsets +/// to its color or size. +/datum/element/clothing_adjustment + element_flags = ELEMENT_BESPOKE + argument_hash_start_idx = 2 + +/datum/element/clothing_adjustment/Attach(datum/target) + . = ..() + if(!isatom(target)) + return ELEMENT_INCOMPATIBLE + + RegisterSignal(target, COMSIG_ITEM_EQUIPPED, PROC_REF(on_item_equipped)) + RegisterSignal(target, COMSIG_ITEM_DROPPED, PROC_REF(on_item_dropped)) + +/datum/element/clothing_adjustment/proc/on_item_equipped(datum/source, mob/target) + SIGNAL_HANDLER // COMSIG_ITEM_DROPPED + return + +/datum/element/clothing_adjustment/proc/on_item_dropped(datum/source, mob/target) + SIGNAL_HANDLER // COMSIG_ITEM_DROPPED + return + +/datum/element/clothing_adjustment/Detach(datum/target) + . = ..() + UnregisterSignal(target, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED)) + +/datum/element/clothing_adjustment/monitor_headgear + var/pixel_x + var/pixel_y + +/datum/element/clothing_adjustment/monitor_headgear/Attach(datum/target, pixel_x_ = 0, pixel_y_ = 0) + if(pixel_x_ == 0 && pixel_y_ == 0) + return ELEMENT_INCOMPATIBLE + + . = ..() + + pixel_x = pixel_x_ + pixel_y = pixel_y_ + +/datum/element/clothing_adjustment/monitor_headgear/on_item_equipped(datum/source, mob/target) + RegisterSignal(target, COMSIG_CARBON_APPLY_OVERLAY, PROC_REF(on_carbon_apply_overlay), override = TRUE) + +/datum/element/clothing_adjustment/monitor_headgear/on_item_dropped(datum/source, mob/target) + UnregisterSignal(target, COMSIG_CARBON_APPLY_OVERLAY) + +/datum/element/clothing_adjustment/monitor_headgear/proc/on_carbon_apply_overlay(mob/living/carbon/source, cache_index, mutable_appearance/overlay) + SIGNAL_HANDLER // COMSIG_CARBON_APPLY_OVERLAY + if(cache_index != HEAD_LAYER || !istype(source)) + return + + var/obj/item/organ/external/head/head = source.get_organ(BODY_ZONE_HEAD) + + if(!istype(head)) + return + + var/datum/robolimb/robohead = GLOB.all_robolimbs[head.model] + if(!robohead?.is_monitor) + return + + overlay.pixel_x = pixel_x + overlay.pixel_y = pixel_y diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index 154379811a5..475216c7d74 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -8,7 +8,8 @@ permeability_coefficient = 0.8 /// Only these species can wear this kit. var/list/species_restricted - var/icon_monitor = null //If set to a sprite path, replaces the sprite for monitor heads + /// If set to a sprite path, replaces the sprite for monitor heads + var/icon_monitor = null /// Can the wearer see reagents inside transparent containers while it's equipped? var/scan_reagents = FALSE /// Can the wearer see reagents inside any container and identify blood types while it's equipped? diff --git a/code/modules/clothing/head/beret.dm b/code/modules/clothing/head/beret.dm index 5abdb2f5557..fc6cedd1271 100644 --- a/code/modules/clothing/head/beret.dm +++ b/code/modules/clothing/head/beret.dm @@ -11,6 +11,10 @@ "Vox" = 'icons/mob/clothing/species/vox/head/beret.dmi' ) +/obj/item/clothing/head/beret/Initialize(mapload) + . = ..() + AddElement(/datum/element/clothing_adjustment/monitor_headgear, 0, 1) + /obj/item/clothing/head/beret/blue icon_state = "beret_blue" diff --git a/code/modules/clothing/suits/wiz_robe.dm b/code/modules/clothing/suits/wiz_robe.dm index b990ed4277d..99b9c022b2a 100644 --- a/code/modules/clothing/suits/wiz_robe.dm +++ b/code/modules/clothing/suits/wiz_robe.dm @@ -41,6 +41,10 @@ "Grey" = 'icons/mob/clothing/species/grey/head.dmi' ) +/obj/item/clothing/head/wizard/mime/Initialize(mapload) + . = ..() + AddElement(/datum/element/clothing_adjustment/monitor_headgear, 0, 1) + /obj/item/clothing/head/wizard/fake desc = "It has WIZZARD written across it in sequins. Comes with a cool beard." icon_state = "wizard-fake" diff --git a/code/modules/mob/living/carbon/human/human_update_icons.dm b/code/modules/mob/living/carbon/human/human_update_icons.dm index 7fb4ac3e404..0c4ab7f1fe1 100644 --- a/code/modules/mob/living/carbon/human/human_update_icons.dm +++ b/code/modules/mob/living/carbon/human/human_update_icons.dm @@ -105,9 +105,9 @@ Please contact me on #coderbus IRC. ~Carn x /mob/living/carbon/human/proc/apply_overlay(cache_index) . = overlays_standing[cache_index] + SEND_SIGNAL(src, COMSIG_CARBON_APPLY_OVERLAY, cache_index, .) if(.) add_overlay(.) - SEND_SIGNAL(src, COMSIG_CARBON_APPLY_OVERLAY, cache_index, .) /mob/living/carbon/human/proc/remove_overlay(cache_index) var/I = overlays_standing[cache_index] diff --git a/paradise.dme b/paradise.dme index 4ff5bcba9d2..27edbdaafc6 100644 --- a/paradise.dme +++ b/paradise.dme @@ -654,6 +654,7 @@ #include "code\datums\elements\body_temperature.dm" #include "code\datums\elements\bombable_turf.dm" #include "code\datums\elements\butchers_humans.dm" +#include "code\datums\elements\clothing_adjustment.dm" #include "code\datums\elements\connect_loc.dm" #include "code\datums\elements\decal_element.dm" #include "code\datums\elements\earhealing.dm"