[MIRROR] Countdown effect + couple of components (#12093)

Co-authored-by: Guti <32563288+TheCaramelion@users.noreply.github.com>
Co-authored-by: Cameron Lennox <killer65311@gmail.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2025-12-10 09:25:33 -05:00
committed by GitHub
co-authored by Guti Cameron Lennox
parent f840ab70d4
commit f5be2c5020
5 changed files with 213 additions and 7 deletions
@@ -1,6 +1,6 @@
/// This component behaves similar to connect_loc_behalf, but it's nested and hooks a signal onto all MOVABLES containing this atom.
/datum/component/connect_containers
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
dupe_mode = COMPONENT_DUPE_SELECTIVE
/// An assoc list of signal -> procpath to register to the loc this object is on.
var/list/connections
@@ -22,18 +22,18 @@
set_tracked(null)
return ..()
/datum/component/connect_containers/InheritComponent(datum/component/component, original, atom/movable/tracked, list/connections)
/datum/component/connect_containers/CheckDupeComponent(datum/component/connect_containers/new_component, atom/movable/tracked, list/connections)
// Not equivalent. Checks if they are not the same list via shallow comparison.
if(!compare_list(src.connections, connections))
stack_trace("connect_containers component attached to [parent] tried to inherit another connect_containers component with different connections")
return
return FALSE // Different set of connections.
if(src.tracked != tracked)
set_tracked(tracked)
set_tracked(tracked) // Different target for the same set of connections, track the new target.
return TRUE // No new component.
/datum/component/connect_containers/proc/set_tracked(atom/movable/new_tracked)
if(tracked)
UnregisterSignal(tracked, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING))
unregister_signals(tracked.loc)
unregister_signals(tracked)
tracked = new_tracked
if(!tracked)
return
+66
View File
@@ -0,0 +1,66 @@
/datum/component/effect_remover
dupe_mode = COMPONENT_DUPE_ALLOWED
/// Line sent to the user on successful removal.
var/success_feedback
/// Line forcesaid by the user on successful removal.
var/success_forcesay
/// Callback invoked with removal is done.
var/datum/callback/on_clear_callback
/// A typecache of all effects we can clear with our item.
var/list/obj/effect/effects_we_clear
/// If above 0, how long it takes while standing still to remove the effect.
var/time_to_remove = 0 SECONDS
/datum/component/effect_remover/Initialize(success_forcesay, success_feedback, on_clear_callback, effects_we_clear, time_to_remove)
. = ..()
if(!isitem(parent))
return COMPONENT_INCOMPATIBLE
if(!effects_we_clear)
stack_trace("[type] was instantiated without any valid removable effects!")
return COMPONENT_INCOMPATIBLE
//src.success_feedback = success_feedback
//src.success_forcesay = success_forcesay
src.on_clear_callback = on_clear_callback
src.effects_we_clear = typecacheof(effects_we_clear)
src.time_to_remove = time_to_remove
/datum/component/effect_remover/Destroy(force)
on_clear_callback = null
return ..()
/datum/component/effect_remover/RegisterWithParent()
RegisterSignal(parent, COMSIG_ITEM_PRE_ATTACK, PROC_REF(try_remove_effect))
/datum/component/effect_remover/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_ITEM_PRE_ATTACK)
/datum/component/effect_remover/proc/try_remove_effect(datum/source, atom/target, mob/living/user, params)
SIGNAL_HANDLER
if(!isliving(user))
return NONE
if(is_type_in_typecache(target, effects_we_clear))
do_remove_effects(target, user)
return
/datum/component/effect_remover/proc/do_remove_effects(obj/effect/target, mob/living/user)
/* Grah- Might have to get this revised, later on.
if(time_to_remove && !do_after(user, time_to_remove, target))
return
var/obj/item/item_parent = parent
if(success_forcesay)
user.say(success_forcesay)
if(success_feedback)
var/real_feedback = replacetext(success_feedback, "%THEEFFECT", "\the [target]")
real_feedback = replacetext(real_feedback, "%THEWEAPON", "\the [item_parent]")
user.balloon_alert()
to_chat(user, span_notice(real_feedback))
*/
on_clear_callback?.Invoke(target, user)
if(!QDELETED(target))
qdel(target)