Files
Bubberstation/code/datums/components/soapbox.dm
Bloop 2ca8d59247 Fixes soapbox hard dels (#85044)
## About The Pull Request


![firefox_P8rmiESgN1](https://github.com/user-attachments/assets/1c8b565f-3b3d-4264-b35a-79d1d056deaf)

Fixes this recently introduced hard del.

## Why It's Good For The Game

Spurious runtimes bgone.

## Changelog

🆑
fix: fixed a hard del with soapboxes
/🆑
2024-07-19 00:57:08 +02:00

45 lines
1.7 KiB
Plaintext

/datum/component/soapbox
/// List of our current soapboxxer(s) who are gaining loud speech
var/list/soapboxers = list()
/// Gives atoms moving over us the soapbox speech and takes it away when they leave
var/static/list/loc_connections = list(
COMSIG_ATOM_ENTERED = PROC_REF(on_loc_entered),
COMSIG_ATOM_EXITED = PROC_REF(on_loc_exited),
)
/datum/component/soapbox/Initialize(...)
if(!ismovable(parent))
return COMPONENT_INCOMPATIBLE
add_connect_loc_behalf_to_parent()
RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(parent_moved))
///Applies loud speech to our movable when entering the turf our parent is on
/datum/component/soapbox/proc/on_loc_entered(datum/source, atom/movable/soapbox_arrive)
SIGNAL_HANDLER
if(QDELETED(soapbox_arrive))
return
RegisterSignal(soapbox_arrive, COMSIG_MOB_SAY, PROC_REF(soapbox_speech))
soapboxers += soapbox_arrive
///Takes away loud speech from our movable when it leaves the turf our parent is on
/datum/component/soapbox/proc/on_loc_exited(datum/source, atom/movable/soapbox_leave)
SIGNAL_HANDLER
if(soapbox_leave in soapboxers)
UnregisterSignal(soapbox_leave, COMSIG_MOB_SAY)
soapboxers -= soapbox_leave
///We don't want our soapboxxer to keep their loud say if the parent is moved out from under them
/datum/component/soapbox/proc/parent_moved(datum/source)
SIGNAL_HANDLER
for(var/atom/movable/loud as anything in soapboxers)
UnregisterSignal(loud, COMSIG_MOB_SAY)
soapboxers = list()
///Gives a mob a unique say span
/datum/component/soapbox/proc/soapbox_speech(datum/source, list/speech_args)
SIGNAL_HANDLER
speech_args[SPEECH_SPANS] |= SPAN_SOAPBOX
/datum/component/soapbox/proc/add_connect_loc_behalf_to_parent()
AddComponent(/datum/component/connect_loc_behalf, parent, loc_connections)