Screentips for anomaly neutralizer / null rod (and other effect removers) (#65221)

This commit is contained in:
MrMelbert
2022-03-09 17:47:40 -08:00
committed by GitHub
parent 6000729e23
commit 8aa42a3833
5 changed files with 33 additions and 1 deletions
+28 -1
View File
@@ -8,6 +8,8 @@
var/success_feedback
/// Line forcesaid by the user on successful removal.
var/success_forcesay
/// The text used in the screentip when our parent is hovering over an item we can clear. Ex "Destroy rune"
var/tip_text
/// Callback invoked with removal is done.
var/datum/callback/on_clear_callback
/// A typecache of all effects we can clear with our item.
@@ -16,6 +18,7 @@
/datum/component/effect_remover/Initialize(
success_forcesay,
success_feedback,
tip_text,
on_clear_callback,
effects_we_clear,
)
@@ -30,14 +33,24 @@
src.success_feedback = success_feedback
src.success_forcesay = success_forcesay
src.tip_text = tip_text
src.on_clear_callback = on_clear_callback
src.effects_we_clear = typecacheof(effects_we_clear)
/datum/component/effect_remover/Destroy(force, silent)
QDEL_NULL(on_clear_callback)
return ..()
/datum/component/effect_remover/RegisterWithParent()
RegisterSignal(parent, COMSIG_ITEM_ATTACK_EFFECT, .proc/try_remove_effect)
if(tip_text)
var/obj/item/item_parent = parent
item_parent.item_flags |= ITEM_HAS_CONTEXTUAL_SCREENTIPS
RegisterSignal(parent, COMSIG_ITEM_REQUESTING_CONTEXT_FOR_TARGET, .proc/add_item_context)
/datum/component/effect_remover/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_ITEM_ATTACK_EFFECT)
UnregisterSignal(parent, list(COMSIG_ITEM_ATTACK_EFFECT, COMSIG_ITEM_REQUESTING_CONTEXT_FOR_TARGET))
/*
* Signal proc for [COMSIG_ITEM_ATTACK_EFFECT].
@@ -67,3 +80,17 @@
if(!QDELETED(target))
qdel(target)
/*
* Signal proc for [COMSIG_ITEM_REQUESTING_CONTEXT_FOR_TARGET].
*
* Adds some context for the target, if we have one set and it's a valid target.
*/
/datum/component/effect_remover/proc/add_item_context(obj/item/source, list/context, atom/target, mob/living/user)
SIGNAL_HANDLER
if(effects_we_clear[target.type])
context[SCREENTIP_CONTEXT_LMB] = tip_text
return CONTEXTUAL_SCREENTIP_SET
return NONE
@@ -17,12 +17,14 @@
// Primarily used to delete and neutralize anomalies.
AddComponent(/datum/component/effect_remover, \
success_feedback = "You neutralize %THEEFFECT with %THEWEAPON, frying its circuitry in the process.", \
tip_text = "Neutralize anomaly", \
on_clear_callback = CALLBACK(src, .proc/on_anomaly_neutralized), \
effects_we_clear = list(/obj/effect/anomaly))
// Can also be used to delete drained heretic influences, to stop fools from losing arms.
AddComponent(/datum/component/effect_remover, \
success_feedback = "You close %THEEFFECT with %THEWEAPON, frying its circuitry in the process.", \
tip_text = "Close rift", \
on_clear_callback = CALLBACK(src, .proc/on_use), \
effects_we_clear = list(/obj/effect/visible_heretic_influence))
+1
View File
@@ -154,6 +154,7 @@
AddComponent(/datum/component/effect_remover, \
success_feedback = "You disrupt the magic of %THEEFFECT with %THEWEAPON.", \
success_forcesay = "BEGONE FOUL MAGIKS!!", \
tip_text = "Clear rune", \
on_clear_callback = CALLBACK(src, .proc/on_cult_rune_removed), \
effects_we_clear = list(/obj/effect/rune, /obj/effect/heretic_rune))
@@ -12,6 +12,7 @@
. = ..()
AddComponent(/datum/component/effect_remover, \
success_feedback = "You remove %THEEFFECT.", \
tip_text = "Clear rune", \
effects_we_clear = list(/obj/effect/heretic_rune))
/obj/item/codex_cicatrix/examine(mob/user)
@@ -21,6 +21,7 @@
. = ..()
AddComponent(/datum/component/effect_remover, \
success_feedback = "You remove %THEEFFECT.", \
tip_text = "Clear rune", \
on_clear_callback = CALLBACK(src, .proc/after_clear_rune), \
effects_we_clear = list(/obj/effect/heretic_rune))