mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +01:00
[MIRROR] BCI component expansion [MDB IGNORE] (#12275)
* BCI component expansion (#65616) This PR adds 2 new BCI components: VOX component which allows to play vox announcements(for the user only!) and Thought Listener component which allows user to input a string upon activation. I've also added a rotation port for the object overlay component so you can make pinpointers using it. This PR requires #65604 * BCI component expansion Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com>
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
|
||||
var/datum/port/input/image_pixel_x
|
||||
var/datum/port/input/image_pixel_y
|
||||
var/datum/port/input/image_rotation
|
||||
|
||||
/// On/Off signals
|
||||
var/datum/port/input/signal_on
|
||||
@@ -38,6 +39,7 @@
|
||||
|
||||
image_pixel_x = add_input_port("X-Axis Shift", PORT_TYPE_NUMBER)
|
||||
image_pixel_y = add_input_port("Y-Axis Shift", PORT_TYPE_NUMBER)
|
||||
image_rotation = add_input_port("Overlay Rotation", PORT_TYPE_NUMBER)
|
||||
|
||||
/obj/item/circuit_component/object_overlay/Destroy()
|
||||
for(var/active_overlay in active_overlays)
|
||||
@@ -106,6 +108,11 @@
|
||||
if(image_pixel_y.value != null)
|
||||
cool_overlay.pixel_y = image_pixel_y.value
|
||||
|
||||
if(image_rotation.value != null)
|
||||
var/matrix/turn_matrix = cool_overlay.transform
|
||||
turn_matrix.Turn(image_rotation.value)
|
||||
cool_overlay.transform = turn_matrix
|
||||
|
||||
var/datum/atom_hud/alternate_appearance/basic/one_person/alt_appearance = target_atom.add_alt_appearance(
|
||||
/datum/atom_hud/alternate_appearance/basic/one_person,
|
||||
"object_overlay_[REF(src)]",
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* # Thought Listener Component
|
||||
*
|
||||
* Allows user to input a string.
|
||||
* Requires a BCI shell.
|
||||
*/
|
||||
|
||||
/obj/item/circuit_component/thought_listener
|
||||
display_name = "Thought Listener"
|
||||
desc = "A component that allows the user to input a string using their mind. Requires a BCI shell."
|
||||
category = "BCI"
|
||||
|
||||
required_shells = list(/obj/item/organ/cyberimp/bci)
|
||||
|
||||
var/datum/port/input/input_name
|
||||
var/datum/port/input/input_desc
|
||||
|
||||
var/datum/port/output/output
|
||||
var/datum/port/output/failure
|
||||
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL
|
||||
|
||||
var/obj/item/organ/cyberimp/bci/bci
|
||||
var/ready = TRUE
|
||||
|
||||
/obj/item/circuit_component/thought_listener/populate_ports()
|
||||
input_name = add_input_port("Input Name", PORT_TYPE_STRING)
|
||||
input_desc = add_input_port("Input Description", PORT_TYPE_STRING)
|
||||
output = add_output_port("Recieved Thought", PORT_TYPE_STRING)
|
||||
trigger_output = add_output_port("Triggered", PORT_TYPE_SIGNAL)
|
||||
failure = add_output_port("On Failure", PORT_TYPE_SIGNAL)
|
||||
|
||||
/obj/item/circuit_component/thought_listener/register_shell(atom/movable/shell)
|
||||
if(istype(shell, /obj/item/organ/cyberimp/bci))
|
||||
bci = shell
|
||||
|
||||
/obj/item/circuit_component/thought_listener/unregister_shell(atom/movable/shell)
|
||||
bci = null
|
||||
|
||||
/obj/item/circuit_component/thought_listener/input_received(datum/port/input/port)
|
||||
if(!ready)
|
||||
failure.set_output(COMPONENT_SIGNAL)
|
||||
return
|
||||
|
||||
if(!bci)
|
||||
failure.set_output(COMPONENT_SIGNAL)
|
||||
return
|
||||
|
||||
var/mob/living/owner = bci.owner
|
||||
|
||||
if(!owner || !istype(owner) || !owner.client)
|
||||
failure.set_output(COMPONENT_SIGNAL)
|
||||
return
|
||||
|
||||
INVOKE_ASYNC(src, .proc/thought_listen, owner)
|
||||
ready = FALSE
|
||||
|
||||
/obj/item/circuit_component/thought_listener/proc/thought_listen(mob/living/owner)
|
||||
var/message = tgui_input_text(owner, input_desc.value ? input_desc.value : "", input_name.value ? input_name.value : "Thought Listener", "")
|
||||
output.set_output(message)
|
||||
trigger_output.set_output(COMPONENT_SIGNAL)
|
||||
ready = TRUE
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* # VOX Announcement Component
|
||||
*
|
||||
* These play a VOX announcement with inputed words from either a string or a list.
|
||||
* Requires a BCI shell.
|
||||
*/
|
||||
|
||||
/obj/item/circuit_component/vox
|
||||
display_name = "VOX Announcement"
|
||||
desc = "A component that plays a local VOX Announcement for the user. Requires a BCI shell."
|
||||
category = "BCI"
|
||||
|
||||
required_shells = list(/obj/item/organ/cyberimp/bci)
|
||||
|
||||
var/datum/port/input/option/type_option
|
||||
var/current_type
|
||||
|
||||
var/datum/port/input/word_list
|
||||
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL
|
||||
|
||||
var/obj/item/organ/cyberimp/bci/bci
|
||||
|
||||
/obj/item/circuit_component/vox/populate_options()
|
||||
type_option = add_option_port("VOX Type", list(PORT_TYPE_LIST(PORT_TYPE_STRING), PORT_TYPE_STRING))
|
||||
|
||||
/obj/item/circuit_component/vox/populate_ports()
|
||||
word_list = add_input_port("Word List", PORT_TYPE_LIST(PORT_TYPE_STRING))
|
||||
|
||||
/obj/item/circuit_component/vox/register_shell(atom/movable/shell)
|
||||
if(istype(shell, /obj/item/organ/cyberimp/bci))
|
||||
bci = shell
|
||||
|
||||
/obj/item/circuit_component/vox/unregister_shell(atom/movable/shell)
|
||||
bci = null
|
||||
|
||||
/obj/item/circuit_component/vox/pre_input_received(datum/port/input/port)
|
||||
var/current_option = type_option.value
|
||||
if(current_type != current_option)
|
||||
current_type = current_option
|
||||
word_list.set_datatype(current_type)
|
||||
|
||||
/obj/item/circuit_component/vox/input_received(datum/port/input/port)
|
||||
if(!bci)
|
||||
return
|
||||
|
||||
var/mob/living/owner = bci.owner
|
||||
|
||||
if(!owner || !istype(owner) || !owner.client || !word_list.value)
|
||||
return
|
||||
|
||||
if(current_type == PORT_TYPE_STRING)
|
||||
var/words_list = splittext(trim(word_list.value), " ")
|
||||
|
||||
for(var/word in words_list)
|
||||
play_vox_word(word, only_listener = owner)
|
||||
else
|
||||
for(var/word in word_list.value)
|
||||
play_vox_word(word, only_listener = owner)
|
||||
Reference in New Issue
Block a user