Files
Bubberstation/code/modules/wiremod/shell/bot.dm
SkyratBot 2b5cfd484f [MIRROR] Adds a user type to integrated circuits, refactors the list pick component. [MDB IGNORE] (#24827)
* Adds a user type to integrated circuits, refactors the list pick component. (#79412)

## About The Pull Request
Added a user type to integrated circuits that can't be stored as a user
type but can be typecasted to entity. Useful for components that
directly ask for an input from the user, like the list pick component.

Refactored the list pick component to use this user port and to also
send failure signals whenever a success signal is not sent.
Removed the triggered port for the list pick component.

Also fixes a runtime that occurs with the list pick component if the
list passed in only contains null values.

## Why It's Good For The Game
Can't force a prompt onto people who haven't interacted with your
circuit.

## Changelog
🆑
add: Added a user type to integrated circuits
/🆑

---------

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

* Adds a user type to integrated circuits, refactors the list pick component.

---------

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

49 lines
1.4 KiB
Plaintext

/**
* # Bot
*
* Immobile (but not dense) shells that can interact with world.
*/
/obj/structure/bot
name = "bot"
icon = 'icons/obj/science/circuits.dmi'
icon_state = "setup_medium_box"
density = FALSE
light_system = MOVABLE_LIGHT
light_on = FALSE
/obj/structure/bot/Initialize(mapload)
. = ..()
AddComponent( \
/datum/component/shell, \
unremovable_circuit_components = list(new /obj/item/circuit_component/bot), \
capacity = SHELL_CAPACITY_LARGE, \
shell_flags = SHELL_FLAG_USB_PORT, \
)
/obj/item/circuit_component/bot
display_name = "Bot"
desc = "Triggers when someone interacts with the bot."
/// Called when attack_hand is called on the shell.
var/datum/port/output/signal
/// The user who used the bot
var/datum/port/output/entity
/obj/item/circuit_component/bot/populate_ports()
entity = add_output_port("User", PORT_TYPE_USER)
signal = add_output_port("Signal", PORT_TYPE_SIGNAL)
/obj/item/circuit_component/bot/register_shell(atom/movable/shell)
RegisterSignal(shell, COMSIG_ATOM_ATTACK_HAND, PROC_REF(on_attack_hand))
/obj/item/circuit_component/bot/unregister_shell(atom/movable/shell)
UnregisterSignal(shell, COMSIG_ATOM_ATTACK_HAND)
/obj/item/circuit_component/bot/proc/on_attack_hand(atom/source, mob/user)
SIGNAL_HANDLER
source.balloon_alert(user, "pushed button")
playsound(source, get_sfx(SFX_TERMINAL_TYPE), 25, FALSE)
entity.set_output(user)
signal.set_output(COMPONENT_SIGNAL)