diff --git a/code/__DEFINES/dcs/datum_signals.dm b/code/__DEFINES/dcs/datum_signals.dm
index 1851311a8ab..e6e15a052db 100644
--- a/code/__DEFINES/dcs/datum_signals.dm
+++ b/code/__DEFINES/dcs/datum_signals.dm
@@ -122,3 +122,8 @@
/// Sent when bodies transfer between shades/shards and constructs
/// from base of /datum/component/construct_held_body/proc/transfer_held_body()
#define COMSIG_SHADE_TO_CONSTRUCT_TRANSFER "shade_to_construct_transfer"
+
+
+/// /datum/component/label
+/// Called when a handlabeler is used on an item when off
+#define COMSIG_LABEL_REMOVE "label_remove"
diff --git a/code/datums/components/label.dm b/code/datums/components/label.dm
index dcc7a3fc73b..876a5bb9874 100644
--- a/code/datums/components/label.dm
+++ b/code/datums/components/label.dm
@@ -22,12 +22,12 @@
apply_label()
/datum/component/label/RegisterWithParent()
- RegisterSignal(parent, COMSIG_ATTACK_BY, PROC_REF(on_attack_by))
+ RegisterSignal(parent, COMSIG_LABEL_REMOVE, PROC_REF(on_remove))
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, PROC_REF(on_examine))
RegisterSignal(parent, COMSIG_ATOM_UPDATE_NAME, PROC_REF(on_update_name))
/datum/component/label/UnregisterFromParent()
- UnregisterSignal(parent, list(COMSIG_ATTACK_BY, COMSIG_PARENT_EXAMINE, COMSIG_ATOM_UPDATE_NAME))
+ UnregisterSignal(parent, list(COMSIG_LABEL_REMOVE, COMSIG_PARENT_EXAMINE, COMSIG_ATOM_UPDATE_NAME))
/**
This proc will fire after the parent is hit by a hand labeler which is trying to apply another label.
@@ -41,29 +41,10 @@
label_name = _label_name
apply_label()
-/**
- This proc will trigger when any object is used to attack the parent.
-
- If the attacking object is not a hand labeler, it will return.
- If the attacking object is a hand labeler it will restore the name of the parent to what it was before this component was added to it, and the component will be deleted.
-
- Arguments:
- * source: The parent.
- * attacker: The object that is hitting the parent.
- * user: The mob who is wielding the attacking object.
-*/
-/datum/component/label/proc/on_attack_by(datum/source, obj/item/attacker, mob/user)
- SIGNAL_HANDLER // COMSIG_ATTACK_BY
- // If the attacking object is not a hand labeler or it's not off (has a label ready to apply), return.
- // The hand labeler should be off in order to remove a label.
- var/obj/item/hand_labeler/labeler = attacker
- if(!istype(labeler) || labeler.mode)
- return
-
+/datum/component/label/proc/on_remove(datum/source)
remove_label()
- playsound(parent, 'sound/items/poster_ripped.ogg', 20, TRUE)
- to_chat(user, "You remove the label from [parent].")
qdel(src) // Remove the component from the object.
+ return TRUE
/**
This proc will trigger when someone examines the parent.
diff --git a/code/modules/paperwork/handlabeler.dm b/code/modules/paperwork/handlabeler.dm
index 6e6a50806b3..81ea787089e 100644
--- a/code/modules/paperwork/handlabeler.dm
+++ b/code/modules/paperwork/handlabeler.dm
@@ -11,44 +11,62 @@
var/label = null
var/labels_left = 30
var/mode = LABEL_MODE_OFF
+ new_attack_chain = TRUE
-/obj/item/hand_labeler/afterattack__legacy__attackchain(atom/A, mob/user, proximity)
- if(!proximity)
- return
- if(mode == LABEL_MODE_OFF) //if it's off, give up.
- return
+/obj/item/hand_labeler/examine(mob/user)
+ . = ..()
+ . += "There [labels_left == 1 ? "is" : "are"] [labels_left] label\s remaining."
+ if(label)
+ . += "The label is currently set to \"[label]\"."
+/obj/item/hand_labeler/interact_with_atom(atom/target, mob/living/user, list/modifiers)
+ if(!mode == LABEL_MODE_OFF)
+ apply_label(target, user)
+ return ITEM_INTERACT_COMPLETE
+ if(remove_label(target, user))
+ return ITEM_INTERACT_COMPLETE
+
+/obj/item/hand_labeler/proc/remove_label(atom/target, mob/living/user)
+ if(SEND_SIGNAL(target, COMSIG_LABEL_REMOVE)) // sends a signal to label.dm
+ playsound(target, 'sound/items/poster_ripped.ogg', 20, TRUE)
+ to_chat(user, "You remove the label from [target].")
+ return TRUE
+
+/obj/item/hand_labeler/proc/apply_label(atom/target, mob/living/user)
if(!labels_left)
to_chat(user, "No labels left!")
return
if(!label || !length(label))
to_chat(user, "No text set!")
return
- if(ismob(A))
+ if(ismob(target))
to_chat(user, "You can't label creatures!") // use a collar
return
if(mode == LABEL_MODE_GOAL)
- if(istype(A, /obj/item))
+ if(istype(target, /obj/item))
to_chat(user, "Put it in a personal crate instead!")
return
- user.visible_message("[user] labels [A] as part of a secondary goal for [label].", \
- "You label [A] as part of a secondary goal for [label].")
- A.AddComponent(/datum/component/label/goal, label)
+ user.visible_message("[user] labels [target] as part of a secondary goal for [label].", \
+ "You label [target] as part of a secondary goal for [label].")
+ target.AddComponent(/datum/component/label/goal, label)
return
- if(length(A.name) + length(label) > 64)
+ if(length(target.name) + length(label) > 64)
to_chat(user, "Label too big!")
return
- user.visible_message("[user] labels [A] as [label].", \
- "You label [A] as [label].")
- investigate_log("[key_name(user)] ([ADMIN_FLW(user,"FLW")]) labelled \"[A]\" ([ADMIN_VV(A, "VV")]) with \"[label]\" at [COORD(A.loc)] [ADMIN_JMP(A)].", INVESTIGATE_RENAME) // Investigate goes BEFORE rename so the original name is preserved in the log
- A.AddComponent(/datum/component/label, label)
- playsound(A, 'sound/items/handling/component_pickup.ogg', 20, TRUE)
+ user.visible_message("[user] labels [target] as [label].", \
+ "You label [target] as [label].")
+ investigate_log("[key_name(user)] ([ADMIN_FLW(user,"FLW")]) labelled \"[target]\" ([ADMIN_VV(target, "VV")]) with \"[label]\" at [COORD(target.loc)] [ADMIN_JMP(target)].", INVESTIGATE_RENAME) // Investigate goes BEFORE rename so the original name is preserved in the log
+ target.AddComponent(/datum/component/label, label)
+ playsound(target, 'sound/items/handling/component_pickup.ogg', 20, TRUE)
labels_left--
-/obj/item/hand_labeler/attack_self__legacy__attackchain(mob/user as mob)
+/obj/item/hand_labeler/activate_self(mob/user)
+ if(..())
+ return
+
// off -> normal
// normal or goal -> off
mode = !mode
@@ -65,22 +83,27 @@
else
to_chat(user, "You turn off \the [src].")
-/obj/item/hand_labeler/attackby__legacy__attackchain(obj/item/I, mob/user, params)
- if(istype(I, /obj/item/hand_labeler_refill))
- to_chat(user, "You insert [I] into [src].")
+/obj/item/hand_labeler/item_interaction(mob/living/user, obj/item/used, list/modifiers)
+ if(..())
+ return ITEM_INTERACT_COMPLETE
+
+ if(istype(used, /obj/item/hand_labeler_refill))
+ to_chat(user, "You insert [used] into [src].")
user.drop_item()
- qdel(I)
+ qdel(used)
labels_left = initial(labels_left) //Yes, it's capped at its initial value
- else if(istype(I, /obj/item/card/id))
- var/obj/item/card/id/id = I
+ return ITEM_INTERACT_COMPLETE
+ else if(istype(used, /obj/item/card/id))
+ var/obj/item/card/id/id = used
if(istype(id, /obj/item/card/id/guest) || !id.registered_name)
to_chat(user, "Invalid ID card.")
- return
- label = id.registered_name
- mode = LABEL_MODE_GOAL
- to_chat(user, "You configure the hand labeler with [I].")
- icon_state = "labeler1"
-
+ return ITEM_INTERACT_COMPLETE
+ else
+ label = id.registered_name
+ mode = LABEL_MODE_GOAL
+ to_chat(user, "You configure the hand labeler with [used].")
+ icon_state = "labeler1"
+ return ITEM_INTERACT_COMPLETE
/obj/item/hand_labeler_refill
name = "hand labeler paper roll"