mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-26 22:50:26 +01:00
[MIRROR] Refactors port types completely and adds the option type. Refactors options to use this new type (#7386)
* Refactors port types completely and adds the option type. Refactors options to use this new type (#60571) Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com> * Refactors port types completely and adds the option type. Refactors options to use this new type Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com>
This commit is contained in:
co-authored by
Watermelon914
Watermelon914
parent
742f11f0d8
commit
3ab1e7ebe2
@@ -7,6 +7,8 @@
|
||||
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
|
||||
|
||||
@@ -19,20 +21,20 @@
|
||||
COMP_COMPARISON_GREATER_THAN_OR_EQUAL,
|
||||
COMP_COMPARISON_LESS_THAN_OR_EQUAL,
|
||||
)
|
||||
options = component_options
|
||||
comparison_option = add_option_port("Comparison Option", component_options)
|
||||
|
||||
/obj/item/circuit_component/compare/comparison/input_received(datum/port/input/port)
|
||||
switch(current_option)
|
||||
switch(comparison_option.input_value)
|
||||
if(COMP_COMPARISON_EQUAL, COMP_COMPARISON_NOT_EQUAL)
|
||||
if(current_type != PORT_TYPE_ANY)
|
||||
current_type = PORT_TYPE_ANY
|
||||
input_ports[1].set_datatype(PORT_TYPE_ANY)
|
||||
input_ports[2].set_datatype(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
|
||||
input_ports[1].set_datatype(PORT_TYPE_NUMBER)
|
||||
input_ports[2].set_datatype(PORT_TYPE_NUMBER)
|
||||
compare_ports[1].set_datatype(PORT_TYPE_NUMBER)
|
||||
compare_ports[2].set_datatype(PORT_TYPE_NUMBER)
|
||||
return ..()
|
||||
|
||||
|
||||
@@ -41,8 +43,9 @@
|
||||
return FALSE
|
||||
|
||||
// Comparison component only compares the first two ports
|
||||
var/input1 = input_ports[1].input_value
|
||||
var/input2 = input_ports[2].input_value
|
||||
var/input1 = compare_ports[1].input_value
|
||||
var/input2 = compare_ports[2].input_value
|
||||
var/current_option = comparison_option.input_value
|
||||
|
||||
switch(current_option)
|
||||
if(COMP_COMPARISON_EQUAL)
|
||||
|
||||
Reference in New Issue
Block a user