mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-20 14:45:05 +00:00
* Fixes a decal hard del (#81093) ## About The Pull Request Attempting to fix this hard del here:  I think the cause is from the turf changing, which `/datum/elements/connect_loc` does not seem to take into consideration. Now it should. Also cleans up the signals in `/datum/component/infective/` which may be another potential cause of issues. ## Why It's Good For The Game Code that cleans up after itself is nice. ## Changelog 🆑 fix: fixes a hard del with decals /🆑 * Fixes a decal hard del --------- Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
44 lines
1.5 KiB
Plaintext
44 lines
1.5 KiB
Plaintext
/// This element hooks a signal onto the loc the current object is on.
|
|
/// When the object moves, it will unhook the signal and rehook it to the new object.
|
|
/datum/element/connect_loc
|
|
element_flags = ELEMENT_BESPOKE|ELEMENT_NO_LIST_UNIT_TEST
|
|
argument_hash_start_idx = 2
|
|
|
|
/// An assoc list of signal -> procpath to register to the loc this object is on.
|
|
var/list/connections
|
|
|
|
/datum/element/connect_loc/Attach(atom/movable/listener, list/connections)
|
|
. = ..()
|
|
if (!istype(listener))
|
|
return ELEMENT_INCOMPATIBLE
|
|
|
|
src.connections = connections
|
|
|
|
RegisterSignal(listener, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved), override = TRUE)
|
|
update_signals(listener)
|
|
|
|
/datum/element/connect_loc/Detach(atom/movable/listener)
|
|
. = ..()
|
|
unregister_signals(listener, listener.loc)
|
|
UnregisterSignal(listener, COMSIG_MOVABLE_MOVED)
|
|
|
|
/datum/element/connect_loc/proc/update_signals(atom/movable/listener)
|
|
var/atom/listener_loc = listener.loc
|
|
if(QDELETED(listener) || QDELETED(listener_loc))
|
|
return
|
|
|
|
for (var/signal in connections)
|
|
//override=TRUE because more than one connect_loc element instance tracked object can be on the same loc
|
|
listener.RegisterSignal(listener_loc, signal, connections[signal], override=TRUE)
|
|
|
|
/datum/element/connect_loc/proc/unregister_signals(datum/listener, atom/old_loc)
|
|
if(isnull(old_loc))
|
|
return
|
|
|
|
listener.UnregisterSignal(old_loc, connections)
|
|
|
|
/datum/element/connect_loc/proc/on_moved(atom/movable/listener, atom/old_loc)
|
|
SIGNAL_HANDLER
|
|
unregister_signals(listener, old_loc)
|
|
update_signals(listener)
|