Files
Bubberstation/code/modules/wiremod/components/action/speech.dm
SkyratBot fcacccc459 [MIRROR] Fixes bypassing integrated circuit cooldowns with module components. [MDB IGNORE] (#21374)
* Fixes bypassing integrated circuit cooldowns with module components. (#75581)

## About The Pull Request
See title.
In order for this change to work, these components will not work if
there is no shell, but this will change nothing user-facing because all
player-facing circuits require shells to function in the first place
anyways.

## Why It's Good For The Game
Fixes a cooldown bypass bug.

Closes #75580

## Changelog
🆑
fix: Fixed bypassing component cooldowns with module components.
/🆑

---------

Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com>

* Fixes bypassing integrated circuit cooldowns with module components.

---------

Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com>
Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com>
2023-05-23 11:54:18 +01:00

36 lines
1.1 KiB
Plaintext

/**
* # Speech Component
*
* Sends a message. Requires a shell.
*/
/obj/item/circuit_component/speech
display_name = "Speech"
desc = "A component that sends a message. Requires a shell."
category = "Action"
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
/// The message to send
var/datum/port/input/message
/// The cooldown for this component of how often it can send speech messages.
var/speech_cooldown = 1 SECONDS
/obj/item/circuit_component/speech/get_ui_notices()
. = ..()
. += create_ui_notice("Speech Cooldown: [DisplayTimeText(speech_cooldown)]", "orange", "stopwatch")
/obj/item/circuit_component/speech/populate_ports()
message = add_input_port("Message", PORT_TYPE_STRING, trigger = null)
/obj/item/circuit_component/speech/input_received(datum/port/input/port)
if(!parent.shell)
return
if(TIMER_COOLDOWN_CHECK(parent.shell, COOLDOWN_CIRCUIT_SPEECH))
return
if(message.value)
var/atom/movable/shell = parent.shell
shell.say(message.value, forced = "circuit speech | [key_name(parent.get_creator())]")
TIMER_COOLDOWN_START(shell, COOLDOWN_CIRCUIT_SPEECH, speech_cooldown)