mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-17 21:24:01 +00:00
* 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>
63 lines
1.9 KiB
Plaintext
63 lines
1.9 KiB
Plaintext
/**
|
|
* # Comparison Component
|
|
*
|
|
* Compares two objects
|
|
*/
|
|
/obj/item/circuit_component/compare/comparison
|
|
display_name = "Comparison"
|
|
desc = "A component that compares two objects."
|
|
|
|
var/datum/port/input/option/comparison_option
|
|
|
|
input_port_amount = 2
|
|
var/current_type = PORT_TYPE_ANY
|
|
|
|
/obj/item/circuit_component/compare/comparison/populate_options()
|
|
var/static/component_options = list(
|
|
COMP_COMPARISON_EQUAL,
|
|
COMP_COMPARISON_NOT_EQUAL,
|
|
COMP_COMPARISON_GREATER_THAN,
|
|
COMP_COMPARISON_LESS_THAN,
|
|
COMP_COMPARISON_GREATER_THAN_OR_EQUAL,
|
|
COMP_COMPARISON_LESS_THAN_OR_EQUAL,
|
|
)
|
|
comparison_option = add_option_port("Comparison Option", component_options)
|
|
|
|
/obj/item/circuit_component/compare/comparison/input_received(datum/port/input/port)
|
|
switch(comparison_option.value)
|
|
if(COMP_COMPARISON_EQUAL, COMP_COMPARISON_NOT_EQUAL)
|
|
if(current_type != PORT_TYPE_ANY)
|
|
current_type = PORT_TYPE_ANY
|
|
compare_ports[1].set_datatype(PORT_TYPE_ANY)
|
|
compare_ports[2].set_datatype(PORT_TYPE_ANY)
|
|
else
|
|
if(current_type != PORT_TYPE_NUMBER)
|
|
current_type = PORT_TYPE_NUMBER
|
|
compare_ports[1].set_datatype(PORT_TYPE_NUMBER)
|
|
compare_ports[2].set_datatype(PORT_TYPE_NUMBER)
|
|
return ..()
|
|
|
|
|
|
/obj/item/circuit_component/compare/comparison/do_comparisons(list/ports)
|
|
if(length(ports) < input_port_amount)
|
|
return FALSE
|
|
|
|
// Comparison component only compares the first two ports
|
|
var/input1 = compare_ports[1].value
|
|
var/input2 = compare_ports[2].value
|
|
var/current_option = comparison_option.value
|
|
|
|
switch(current_option)
|
|
if(COMP_COMPARISON_EQUAL)
|
|
return input1 == input2
|
|
if(COMP_COMPARISON_NOT_EQUAL)
|
|
return input1 != input2
|
|
if(COMP_COMPARISON_GREATER_THAN)
|
|
return input1 > input2
|
|
if(COMP_COMPARISON_GREATER_THAN_OR_EQUAL)
|
|
return input1 >= input2
|
|
if(COMP_COMPARISON_LESS_THAN)
|
|
return input1 < input2
|
|
if(COMP_COMPARISON_LESS_THAN_OR_EQUAL)
|
|
return input1 <= input2
|