mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-30 16:47:13 +01:00
[MIRROR] More circuit components. Restructures the circuit components folder to be more organised. (#6142)
* More circuit components. Restructures the circuit components folder to be more organised. * Mirror! Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Co-authored-by: Funce <funce.973@gmail.com>
This commit is contained in:
co-authored by
Watermelon914
Funce
parent
6e52d05e2e
commit
cc5cf407b0
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* # Delay Component
|
||||
*
|
||||
* Delays a signal by a specified duration.
|
||||
*/
|
||||
/obj/item/circuit_component/delay
|
||||
display_name = "Delay"
|
||||
|
||||
/// Amount to delay by
|
||||
var/datum/port/input/delay_amount
|
||||
/// Input signal to fire the delay
|
||||
var/datum/port/input/trigger
|
||||
|
||||
/// The output of the signal
|
||||
var/datum/port/output/output
|
||||
|
||||
/obj/item/circuit_component/delay/Initialize()
|
||||
. = ..()
|
||||
delay_amount = add_input_port("Delay", PORT_TYPE_NUMBER, FALSE)
|
||||
trigger = add_input_port("Trigger", PORT_TYPE_SIGNAL)
|
||||
|
||||
output = add_output_port("Result", PORT_TYPE_SIGNAL)
|
||||
|
||||
/obj/item/circuit_component/delay/Destroy()
|
||||
output = null
|
||||
trigger = null
|
||||
delay_amount = null
|
||||
return ..()
|
||||
|
||||
/obj/item/circuit_component/delay/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
if(!COMPONENT_TRIGGERED_BY(trigger, port))
|
||||
return
|
||||
|
||||
var/delay = delay_amount.input_value
|
||||
if(delay > COMP_DELAY_MIN_VALUE)
|
||||
// Convert delay into deciseconds
|
||||
addtimer(CALLBACK(output, /datum/port/output.proc/set_output, trigger.input_value), delay*10, timer_subsystem =SScircuit_component)
|
||||
else
|
||||
output.set_output(trigger.input_value)
|
||||
Reference in New Issue
Block a user