mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-05 22:43:46 +00:00
## About The Pull Request The first argument of `Hear` is `message`, the message heard OR SO YOU'D THINK Actually the first argument doesn't do anything but get overridden by ALL implementations of `Hear` No other uses as far as I and Ephe can tell. Removing it makes it a ton easier to understand and gives us some free performance in radio code by not rendering messages twice ## Changelog 🆑 Melbert code: Removed some redundant code from core hearing code. Report if you hear anything weird. /🆑
59 lines
2.1 KiB
Plaintext
59 lines
2.1 KiB
Plaintext
/**
|
|
* # Hear Component
|
|
*
|
|
* Listens for messages. Requires a shell.
|
|
*/
|
|
/obj/item/circuit_component/hear
|
|
display_name = "Voice Activator"
|
|
desc = "A component that listens for messages. Requires a shell."
|
|
category = "Entity"
|
|
|
|
/// The on/off port
|
|
var/datum/port/input/on
|
|
|
|
/// The message heard
|
|
var/datum/port/output/message_port
|
|
/// The language heard
|
|
var/datum/port/output/language_port
|
|
/// The speaker name port, usually the name of the person who spoke.
|
|
var/datum/port/output/speaker_name
|
|
/// The speaker entity that is currently speaking. Not necessarily the person who is speaking.
|
|
var/datum/port/output/speaker_port
|
|
/// The trigger sent when this event occurs
|
|
var/datum/port/output/trigger_port
|
|
|
|
/obj/item/circuit_component/hear/populate_ports()
|
|
on = add_input_port("On", PORT_TYPE_NUMBER, default = 1)
|
|
message_port = add_output_port("Message", PORT_TYPE_STRING)
|
|
language_port = add_output_port("Language", PORT_TYPE_STRING)
|
|
speaker_port = add_output_port("Speaker", PORT_TYPE_ATOM)
|
|
speaker_name = add_output_port("Speaker Name", PORT_TYPE_STRING)
|
|
trigger_port = add_output_port("Triggered", PORT_TYPE_SIGNAL)
|
|
become_hearing_sensitive(ROUNDSTART_TRAIT)
|
|
|
|
/obj/item/circuit_component/hear/register_shell(atom/movable/shell)
|
|
if(parent.loc != shell)
|
|
shell.become_hearing_sensitive(CIRCUIT_HEAR_TRAIT)
|
|
RegisterSignal(shell, COMSIG_MOVABLE_HEAR, PROC_REF(on_shell_hear))
|
|
|
|
/obj/item/circuit_component/hear/unregister_shell(atom/movable/shell)
|
|
REMOVE_TRAIT(shell, TRAIT_HEARING_SENSITIVE, CIRCUIT_HEAR_TRAIT)
|
|
|
|
/obj/item/circuit_component/hear/proc/on_shell_hear(datum/source, list/arguments)
|
|
SIGNAL_HANDLER
|
|
return Hear(arglist(arguments))
|
|
|
|
/obj/item/circuit_component/hear/Hear(atom/movable/speaker, datum/language/message_language, raw_message, radio_freq, radio_freq_name, radio_freq_color, list/spans, list/message_mods, message_range)
|
|
if(!on.value)
|
|
return FALSE
|
|
if(speaker == parent?.shell)
|
|
return FALSE
|
|
|
|
message_port.set_output(raw_message)
|
|
if(message_language)
|
|
language_port.set_output(initial(message_language.name))
|
|
speaker_port.set_output(speaker)
|
|
speaker_name.set_output(speaker.get_voice())
|
|
trigger_port.set_output(COMPONENT_SIGNAL)
|
|
return TRUE
|