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>
This commit is contained in:
Watermelon914
2023-05-22 18:55:11 -06:00
committed by GitHub
co-authored by Watermelon914
parent 9ba051c857
commit 9fd0b4e770
4 changed files with 21 additions and 13 deletions
@@ -84,7 +84,10 @@
else
ui_color = initial(ui_color)
if(TIMER_COOLDOWN_CHECK(parent, COOLDOWN_CIRCUIT_SOUNDEMITTER))
if(!parent.shell)
return
if(TIMER_COOLDOWN_CHECK(parent.shell, COOLDOWN_CIRCUIT_SOUNDEMITTER))
return
var/sound_to_play = options_map[sound_file.value]
@@ -99,4 +102,4 @@
playsound(src, sound_to_play, actual_volume, TRUE, frequency = actual_frequency)
TIMER_COOLDOWN_START(parent, COOLDOWN_CIRCUIT_SOUNDEMITTER, sound_cooldown)
TIMER_COOLDOWN_START(parent.shell, COOLDOWN_CIRCUIT_SOUNDEMITTER, sound_cooldown)
@@ -23,15 +23,13 @@
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, COOLDOWN_CIRCUIT_SPEECH))
if(TIMER_COOLDOWN_CHECK(parent.shell, COOLDOWN_CIRCUIT_SPEECH))
return
if(message.value)
var/atom/movable/shell = parent.shell
// Prevents appear as the individual component if there is a shell.
if(shell)
shell.say(message.value, forced = "circuit speech | [key_name(parent.get_creator())]")
else
say(message.value, forced = "circuit speech | [parent.get_creator()]")
TIMER_COOLDOWN_START(parent, COOLDOWN_CIRCUIT_SPEECH, speech_cooldown)
shell.say(message.value, forced = "circuit speech | [key_name(parent.get_creator())]")
TIMER_COOLDOWN_START(shell, COOLDOWN_CIRCUIT_SPEECH, speech_cooldown)