Files
Bubberstation/code/modules/wiremod/components/bci/hud/target_intercept.dm
SkyratBot 35ffae1246 [MIRROR] Fixed being able to activate BCI actions whilst not conscious (#29317)
* Fixed being able to activate BCI actions whilst not conscious (#85544)

## About The Pull Request
As the title says

## Why It's Good For The Game
Shouldn't be able to activate these whilst unconscious, or stall
activation to activate at a convenient time whilst unconsious.

## Changelog
🆑
fix: Fixed activating specific BCI actions whilst unconsious
/🆑

---------

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

* Fixed being able to activate BCI actions whilst not conscious

---------

Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com>
Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com>
2024-08-15 11:54:30 +02: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 || owner.stat >= SOFT_CRIT)
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")