Skip to content

Commit

Permalink
Fixes a few things
Browse files Browse the repository at this point in the history
  • Loading branch information
morrowwolf committed Apr 6, 2024
1 parent 3846b4e commit 02c42ab
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
5 changes: 5 additions & 0 deletions code/__DEFINES/dcs/signals/atom/signals_item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

///from base of obj/item/dropped(): (mob/user)
#define COMSIG_ITEM_DROPPED "item_drop"

///from base of /mob/living/carbon/human/equip_to_slot_if_possible : (/obj/item/equipping_item, mob/living/carbon/human/user, slot)
#define COMSIG_ITEM_ATTEMPTING_HUMAN_EQUIP "item_attempting_human_equip"
#define COMPONENT_ITEM_CANCEL_ATTEMPTING_HUMAN_EQUIP (1<<0)

/// From base of /obj/item/proc/equipped(): (mob/user, slot)
#define COMSIG_ITEM_EQUIPPED "item_equipped"
/// From base of /obj/item/proc/unequipped(): (mob/user, slot)
Expand Down
16 changes: 7 additions & 9 deletions code/datums/components/attached_headset.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

/datum/component/attached_headset/Destroy()
. = ..()
if(!headset.loc && !QDELETED(headset))
if(!QDELETED(headset) && !headset.loc)
qdel(headset)

headset = null
Expand All @@ -54,22 +54,20 @@

/datum/component/attached_headset/RegisterWithParent()
. = ..()
RegisterSignal(parent, COMSIG_HUMAN_ATTEMPTING_EQUIP, PROC_REF(on_attempted_equip))
RegisterSignal(parent, COMSIG_ITEM_ATTEMPTING_HUMAN_EQUIP, PROC_REF(on_attempted_equip))
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, PROC_REF(on_equipped))
RegisterSignal(parent, COMSIG_ITEM_ATTACKED, PROC_REF(attackby))
RegisterSignal(parent, COMSIG_ITEM_DROPPED, PROC_REF(dropped))
RegisterSignal(headset, COMSIG_PARENT_QDELETING, PROC_REF(headset_deletion))

/datum/component/attached_headset/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_HUMAN_ATTEMPTING_EQUIP)
UnregisterSignal(parent, COMSIG_ITEM_ATTEMPTING_HUMAN_EQUIP)
UnregisterSignal(parent, COMSIG_ITEM_EQUIPPED)
UnregisterSignal(parent, COMSIG_ITEM_ATTACKED)
UnregisterSignal(parent, COMSIG_ITEM_DROPPED)
UnregisterSignal(headset, COMSIG_PARENT_QDELETING)
. = ..()

//Unregister your shit - Morrow

/datum/component/attached_headset/InheritComponent(datum/component/C, i_am_original)
if(!istype(item_parent.loc, /mob))
return
Expand All @@ -78,15 +76,15 @@
to_chat(user, SPAN_NOTICE("[parent] already has [headset] attached to it. Looks like you could remove it with a screwdriver."))

/// Cancels equipping parent if there's a headset already on the left ear
/datum/component/attached_headset/proc/on_attempted_equip(mob/living/carbon/human/user, obj/item/equipping_item, slot)
/datum/component/attached_headset/proc/on_attempted_equip(obj/item/equipping_item, mob/living/carbon/human/user, slot)
SIGNAL_HANDLER

if(slot != parent_activation_slot)
return

if(user.wear_l_ear)
to_chat(user, SPAN_NOTICE("[equipping_item] has [headset] attached to it. It can't fit while you're wearing [user.wear_l_ear]."))
return COMPONENT_HUMAN_CANCEL_ATTEMPT_EQUIP
if(user.wear_l_ear || istype(user.wear_r_ear, /obj/item/device/radio/headset))
to_chat(user, SPAN_NOTICE("[equipping_item] has [headset] attached to it. It can't fit while you're wearing [user.wear_l_ear ? user.wear_l_ear : user.wear_r_ear]."))
return COMPONENT_ITEM_CANCEL_ATTEMPTING_HUMAN_EQUIP

/// When parent is equipped we check if it's the right slot, if so then we deploy our headset
/datum/component/attached_headset/proc/on_equipped(obj/item/equipping_item, mob/user, slot)
Expand Down
3 changes: 3 additions & 0 deletions code/modules/mob/living/carbon/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1653,6 +1653,9 @@
if(SEND_SIGNAL(src, COMSIG_HUMAN_ATTEMPTING_EQUIP, equipping_item, slot) & COMPONENT_HUMAN_CANCEL_ATTEMPT_EQUIP)
return FALSE

if(SEND_SIGNAL(equipping_item, COMSIG_ITEM_ATTEMPTING_HUMAN_EQUIP, src, slot) & COMPONENT_ITEM_CANCEL_ATTEMPTING_HUMAN_EQUIP)
return FALSE

. = ..()

/mob/living/carbon/human/make_dizzy(amount)
Expand Down

0 comments on commit 02c42ab

Please sign in to comment.