Files
Bubberstation/code/modules/wiremod/components/utility/delay.dm
SkyratBot 9e74cd4a03 [MIRROR] Input ports now connect to multiple output ports. Remove combiner. (#7505)
* Input ports now connect to multiple output ports. Remove combiner. (#60494)

* tgui bsod

* debug disconnections

* prelim

* recomment

* set_value -> put ._.

* DAMN IT

* reinsert subsystem

* prepare

* unditch signals

* remove combiner

* remove combiner some more

* how did router.dm get here? deleting.

* These two COMSIGS should be one.

* critical typo

* inline cast

* have your signals

* Have your set_input & set_output.

* make compile

* upgrade save/load to n-to-n-wires

* have your documentation

* have your unsafe proc

* pay no attention to the compile errors

* unlist the ref

* paste my for block back in ._.

* fix manual input

* oops pushed too soon

* Have your !port.connected_to?.length

Co-authored-by: Watermelon914 <37270891+Watermelon914@ users.noreply.github.com>

Co-authored-by: Watermelon914 <37270891+Watermelon914@ users.noreply.github.com>

* Input ports now connect to multiple output ports. Remove combiner.

Co-authored-by: Gurkenglas <gurkenglas@hotmail.de>
Co-authored-by: Watermelon914 <37270891+Watermelon914@ users.noreply.github.com>
2021-08-11 20:27:29 +01:00

44 lines
1.1 KiB
Plaintext

/// The minimum delay value that the delay component can have.
#define COMP_DELAY_MIN_VALUE 0.1
/**
* # Delay Component
*
* Delays a signal by a specified duration.
*/
/obj/item/circuit_component/delay
display_name = "Delay"
desc = "A component that delays a signal by a specified duration."
/// 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/input_received(datum/port/input/port)
. = ..()
if(.)
return
if(!COMPONENT_TRIGGERED_BY(trigger, port))
return
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)
else
output.set_output(trigger.value)
#undef COMP_DELAY_MIN_VALUE