[MIRROR] More circuit components. Restructures the circuit components folder to be more organised. (#6142)

* More circuit components. Restructures the circuit components folder to be more organised.

* Mirror!

Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com>
Co-authored-by: Funce <funce.973@gmail.com>
This commit is contained in:
SkyratBot
2021-06-05 07:15:43 +02:00
committed by GitHub
parent 6e52d05e2e
commit cc5cf407b0
42 changed files with 630 additions and 106 deletions
@@ -0,0 +1,49 @@
/**
* # Speech Component
*
* Sends a message. Requires a shell.
*/
/obj/item/circuit_component/speech
display_name = "Speech"
/// The message to send
var/datum/port/input/message
/// The trigger to send the message
var/datum/port/input/trigger
/// The cooldown for this component of how often it can send speech messages.
var/speech_cooldown = 1 SECONDS
COOLDOWN_DECLARE(next_speech)
/obj/item/circuit_component/speech/Initialize()
. = ..()
message = add_input_port("Message", PORT_TYPE_STRING, FALSE)
trigger = add_input_port("Trigger", PORT_TYPE_SIGNAL)
/obj/item/circuit_component/speech/Destroy()
message = null
trigger = null
return ..()
/obj/item/circuit_component/speech/input_received(datum/port/input/port)
. = ..()
if(.)
return
if(!COMPONENT_TRIGGERED_BY(trigger, port))
return
if(!COOLDOWN_FINISHED(src, next_speech))
return
if(message.input_value)
var/atom/movable/shell = parent.shell
// Prevents appear as the individual component if there is a shell.
if(shell)
shell.say(message.input_value)
else
say(message.input_value)
COOLDOWN_START(src, next_speech, speech_cooldown)