Files
Bubberstation/code/modules/wiremod/components/bci/hud/target_intercept.dm
SkyratBot 3a1925b4d1 [MIRROR] fixes signal circuit not working | refactors name of timer cooldown macros to be inherent, also docs them [MDB IGNORE] (#24675)
* fixes signal circuit not working | refactors name of timer cooldown macros to be inherent, also docs them (#79367)

## About The Pull Request

Title
## Why It's Good For The Game

Less headache in the future for a macro thats not really obvious in what
it does
## Changelog
🆑
fix: signals in circuits now actually function
/🆑

* fixes signal circuit not working | refactors name of timer cooldown macros to be inherent, also docs them

---------

Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com>
2023-10-31 18:31:52 -04:00

67 lines
2.3 KiB
Plaintext

/**
* # Target Intercept Component
*
* When activated intercepts next click and outputs clicked atom.
* Requires a BCI shell.
*/
/obj/item/circuit_component/target_intercept
display_name = "Target Intercept"
desc = "Requires a BCI shell. When activated, this component will allow user to target an object using their brain and will output the reference to said object."
category = "BCI"
required_shells = list(/obj/item/organ/internal/cyberimp/bci)
var/datum/port/output/clicked_atom
var/obj/item/organ/internal/cyberimp/bci/bci
var/intercept_cooldown = 1 SECONDS
/obj/item/circuit_component/target_intercept/populate_ports()
trigger_input = add_input_port("Activate", PORT_TYPE_SIGNAL)
trigger_output = add_output_port("Triggered", PORT_TYPE_SIGNAL)
clicked_atom = add_output_port("Targeted Object", PORT_TYPE_ATOM)
/obj/item/circuit_component/target_intercept/register_shell(atom/movable/shell)
if(istype(shell, /obj/item/organ/internal/cyberimp/bci))
bci = shell
RegisterSignal(shell, COMSIG_ORGAN_REMOVED, PROC_REF(on_organ_removed))
/obj/item/circuit_component/target_intercept/unregister_shell(atom/movable/shell)
bci = null
UnregisterSignal(shell, COMSIG_ORGAN_REMOVED)
/obj/item/circuit_component/target_intercept/input_received(datum/port/input/port)
if(!bci)
return
if(!parent.shell)
return
var/mob/living/owner = bci.owner
if(!owner || !istype(owner) || !owner.client)
return
if(TIMER_COOLDOWN_RUNNING(parent.shell, COOLDOWN_CIRCUIT_TARGET_INTERCEPT))
return
to_chat(owner, "<B>Left-click to trigger target interceptor!</B>")
owner.client.click_intercept = src
/obj/item/circuit_component/target_intercept/proc/on_organ_removed(datum/source, mob/living/carbon/owner)
SIGNAL_HANDLER
if(owner.client && owner.client.click_intercept == src)
owner.client.click_intercept = null
/obj/item/circuit_component/target_intercept/proc/InterceptClickOn(mob/user, params, atom/object)
user.client.click_intercept = null
clicked_atom.set_output(object)
trigger_output.set_output(COMPONENT_SIGNAL)
if(parent.shell)
TIMER_COOLDOWN_START(parent.shell, COOLDOWN_CIRCUIT_TARGET_INTERCEPT, intercept_cooldown)
/obj/item/circuit_component/target_intercept/get_ui_notices()
. = ..()
. += create_ui_notice("Target Interception Cooldown: [DisplayTimeText(intercept_cooldown)]", "orange", "stopwatch")