mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-18 11:36:24 +01:00
Adds the interrupt signal to the delay component, reorganises BCI files and circuit code improvements (#61393)
Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com>
This commit is contained in:
@@ -8,32 +8,43 @@
|
||||
*/
|
||||
/obj/item/circuit_component/delay
|
||||
display_name = "Delay"
|
||||
desc = "A component that delays a signal by a specified duration."
|
||||
desc = "A component that delays a signal by a specified duration. Timer gets reset when triggered again."
|
||||
|
||||
/// Amount to delay by
|
||||
var/datum/port/input/delay_amount
|
||||
/// Input signal to fire the delay
|
||||
var/datum/port/input/trigger
|
||||
/// Interrupts the delay before it fires
|
||||
var/datum/port/input/interrupt
|
||||
|
||||
var/timer_id = TIMER_ID_NULL
|
||||
|
||||
/// The output of the signal
|
||||
var/datum/port/output/output
|
||||
|
||||
/obj/item/circuit_component/delay/populate_ports()
|
||||
delay_amount = add_input_port("Delay", PORT_TYPE_NUMBER, trigger = null)
|
||||
trigger = add_input_port("Trigger", PORT_TYPE_SIGNAL)
|
||||
trigger = add_input_port("Trigger", PORT_TYPE_SIGNAL, trigger = .proc/trigger_delay)
|
||||
interrupt = add_input_port("Interrupt", PORT_TYPE_SIGNAL, trigger = .proc/interrupt_timer)
|
||||
|
||||
output = add_output_port("Result", PORT_TYPE_SIGNAL)
|
||||
|
||||
/obj/item/circuit_component/delay/input_received(datum/port/input/port)
|
||||
|
||||
if(!COMPONENT_TRIGGERED_BY(trigger, port))
|
||||
return
|
||||
|
||||
/obj/item/circuit_component/delay/proc/trigger_delay(datum/port/input/port)
|
||||
CIRCUIT_TRIGGER
|
||||
var/delay = delay_amount.value
|
||||
if(delay > COMP_DELAY_MIN_VALUE)
|
||||
// Convert delay into deciseconds
|
||||
addtimer(CALLBACK(output, /datum/port/output.proc/set_output, trigger.value), delay*10)
|
||||
timer_id = addtimer(CALLBACK(output, /datum/port/output.proc/set_output, trigger.value), delay*10, TIMER_UNIQUE|TIMER_STOPPABLE|TIMER_OVERRIDE)
|
||||
else
|
||||
if(timer_id != TIMER_ID_NULL)
|
||||
deltimer(timer_id)
|
||||
timer_id = TIMER_ID_NULL
|
||||
output.set_output(trigger.value)
|
||||
|
||||
/obj/item/circuit_component/delay/proc/interrupt_timer(datum/port/input/port)
|
||||
CIRCUIT_TRIGGER
|
||||
if(timer_id != TIMER_ID_NULL)
|
||||
deltimer(timer_id)
|
||||
timer_id = TIMER_ID_NULL
|
||||
|
||||
#undef COMP_DELAY_MIN_VALUE
|
||||
|
||||
@@ -325,8 +325,20 @@
|
||||
for(var/entry in entries)
|
||||
. += create_ui_notice("Column Name: '[entry]'", "grey", "columns")
|
||||
|
||||
/obj/item/circuit_component/proc/register_usb_parent(atom/movable/parent)
|
||||
/**
|
||||
* Called when a circuit component is added to an object with a USB port.
|
||||
*
|
||||
* Arguments:
|
||||
* * shell - The object that USB cables can connect to
|
||||
*/
|
||||
/obj/item/circuit_component/proc/register_usb_parent(atom/movable/shell)
|
||||
return
|
||||
|
||||
/obj/item/circuit_component/proc/unregister_usb_parent(atom/movable/parent)
|
||||
/**
|
||||
* Called when a circuit component is removed from an object with a USB port.
|
||||
*
|
||||
* Arguments:
|
||||
* * shell - The object that USB cables can connect to
|
||||
*/
|
||||
/obj/item/circuit_component/proc/unregister_usb_parent(atom/movable/shell)
|
||||
return
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
desc = "A gate able to perform mid-depth scans on any organisms who pass under it."
|
||||
icon = 'icons/obj/machines/scangate.dmi'
|
||||
icon_state = "scangate_black"
|
||||
var/scanline_timer
|
||||
|
||||
var/locked = FALSE
|
||||
|
||||
/obj/structure/scanner_gate_shell/Initialize()
|
||||
@@ -34,23 +32,21 @@
|
||||
|
||||
/obj/structure/scanner_gate_shell/proc/set_scanline(type, duration)
|
||||
cut_overlays()
|
||||
deltimer(scanline_timer)
|
||||
add_overlay(type)
|
||||
if(duration)
|
||||
scanline_timer = addtimer(CALLBACK(src, .proc/set_scanline, "passive"), duration, TIMER_STOPPABLE)
|
||||
addtimer(CALLBACK(src, .proc/set_scanline, "passive"), duration, TIMER_UNIQUE|TIMER_OVERRIDE|TIMER_STOPPABLE)
|
||||
|
||||
/obj/item/circuit_component/scanner_gate
|
||||
display_name = "Scanner Gate"
|
||||
desc = "A gate able to perform mid-depth scans on any object that pass through it."
|
||||
|
||||
circuit_flags = CIRCUIT_FLAG_OUTPUT_SIGNAL
|
||||
|
||||
var/datum/port/output/scanned
|
||||
|
||||
var/obj/structure/scanner_gate_shell/attached_gate
|
||||
|
||||
/obj/item/circuit_component/scanner_gate/populate_ports()
|
||||
scanned = add_output_port("Scanned Object", PORT_TYPE_ATOM)
|
||||
trigger_output = add_output_port("Triggered", PORT_TYPE_SIGNAL, order = 2)
|
||||
|
||||
/obj/item/circuit_component/scanner_gate/register_shell(atom/movable/shell)
|
||||
. = ..()
|
||||
|
||||
Reference in New Issue
Block a user