Files
Bubberstation/code/modules/wiremod/components/atom/hear.dm
SkyratBot 13cd1f18df [MIRROR] Circuit editor QoL and new circuit components (#27722)
* Circuit editor QoL and new circuit components (#82969)

## About The Pull Request

This PR introduces a number of minor quality of life improvements to
already existing circuit components, and adds three new components.

<img width="600" alt="preview"
src="https://github.com/tgstation/tgstation/assets/80724828/85d39b6d-b055-430e-8996-0da088616887">

## Why It's Good For The Game

This improves the overall experience for circuits.

### UI changes

<img width="550" alt="grid aligned"
src="https://github.com/tgstation/tgstation/assets/80724828/cc7b43b5-292f-4643-beab-e01ae675fb19">

Grid align is now an option for circuit designers. It will round objects
to the nearest 10px units internally, and can be toggled on/off by the
new additional button beside the component menu button. This makes
circuits easier on the eyes as things are pixel perfect aligned.

<img width="814" alt="tooltips"
src="https://github.com/tgstation/tgstation/assets/80724828/0d31c98f-3be9-46e0-ab37-20bac3799112">

All three buttons have been given tool tips.

### Tweaked Components

<img width="136" alt="voice activator"
src="https://github.com/tgstation/tgstation/assets/80724828/21dd0f65-cb98-4bd5-aeb0-63315e842cb6">

* Adds a on/off flag to the voice activator component
-- This saves power for circuits as you're not forced to use a compare
flag check to turn off voice activation

<img width="136" alt="speech"
src="https://github.com/tgstation/tgstation/assets/80724828/9137b76c-3077-4597-8411-2d9694b39e9e">

* Adds a quiet mode flag to speech component
-- This is ideal when you want a device to speak, but don't want other
people to hear. A good example would be a handheld translator that you
only want to hear yourself.

### New Components

<img width="136" alt="ntnet list literal"
src="https://github.com/tgstation/tgstation/assets/80724828/657c851b-d442-4a63-8650-410cb8e76089">

* An NTNet Send component that allows everything to be input much like
the list literal component
-- This makes sending stuff over NTNet easier for the user, and use less
power as it won't require an additional list literal component

<img width="136" alt="compare health state"
src="https://github.com/tgstation/tgstation/assets/80724828/0bed076c-3aa1-4931-af90-2b9eb8e1ae9a">

* A health comparison component that checks the entity's health state,
and can return true or false depending if the entity is alive, sleeping,
unconscious, critical or dead
-- This could be achieved by using a health sensor and a compare
component, however it lacks the ability to know when a entity is
unconscious or sleeping

<img width="136" alt="toggle"
src="https://github.com/tgstation/tgstation/assets/80724828/7017b6bf-937a-42ad-87f3-4f1134853ac3">

* A quick toggle component to allow the switching between a true and
false state
-- This could be achieved by using a logic component and self linking,
however this makes it far easier for newcomers to make something as
simple as an on/off switch (such as a handheld translator which uses the
front button to turn on/off)

## Changelog
🆑
qol: Add tooltips to circuit editor buttons
qol: Add grid alignment mode to circuit editor
add: Added new compare health state component
add: Added new NTNet send list literal component
add: Added new toggle component
qol: Added activity toggle to voice activator component
qol: Added quiet mode to speech component
qol: NTNet send component will not use power/trigger if NTNet is offline
/🆑

* Circuit editor QoL and new circuit components

---------

Co-authored-by: tmyqlfpir <80724828+tmyqlfpir@users.noreply.github.com>
2024-05-16 06:34:03 +02:00

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(message, atom/movable/speaker, datum/language/message_language, raw_message, radio_freq, 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.GetVoice())
trigger_port.set_output(COMPONENT_SIGNAL)
return TRUE