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 <orion@snowfrost.garden>
Signed-off-by: Alan <alfalfascout@users.noreply.github.com>

* Autodoc properly

Co-authored-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com>
Signed-off-by: Alan <alfalfascout@users.noreply.github.com>

---------

Signed-off-by: Alan <alfalfascout@users.noreply.github.com>
Co-authored-by: warriorstar-orion <orion@snowfrost.garden>
Co-authored-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com>
This commit is contained in:
Alan
2025-10-04 13:18:59 -04:00
committed by GitHub
parent 6344721e90
commit 99ff0ad3de
6 changed files with 74 additions and 2 deletions
@@ -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
+2 -1
View File
@@ -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?
+4
View File
@@ -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"
+4
View File
@@ -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"
@@ -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]
+1
View File
@@ -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"