mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-30 08:37:43 +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,47 @@
|
||||
/**
|
||||
* # Logic Component
|
||||
*
|
||||
* General logic unit with AND OR capabilities
|
||||
*/
|
||||
/obj/item/circuit_component/compare/logic
|
||||
display_name = "Logic"
|
||||
|
||||
|
||||
GLOBAL_LIST_INIT(comp_logic_options, list(
|
||||
COMP_LOGIC_AND,
|
||||
COMP_LOGIC_OR,
|
||||
COMP_LOGIC_XOR
|
||||
))
|
||||
|
||||
/obj/item/circuit_component/compare/logic/Initialize()
|
||||
options = GLOB.comp_logic_options
|
||||
return ..()
|
||||
|
||||
/obj/item/circuit_component/compare/logic/do_comparisons(list/ports)
|
||||
. = FALSE
|
||||
// Used by XOR
|
||||
var/total_ports = 0
|
||||
var/total_true_ports = 0
|
||||
for(var/datum/port/input/port as anything in ports)
|
||||
if(isnull(port.input_value) && isnull(port.connected_port))
|
||||
continue
|
||||
|
||||
total_ports += 1
|
||||
switch(current_option)
|
||||
if(COMP_LOGIC_AND)
|
||||
if(!port.input_value)
|
||||
return FALSE
|
||||
. = TRUE
|
||||
if(COMP_LOGIC_OR)
|
||||
if(port.input_value)
|
||||
return TRUE
|
||||
if(COMP_LOGIC_XOR)
|
||||
if(port.input_value)
|
||||
. = TRUE
|
||||
total_true_ports += 1
|
||||
|
||||
if(current_option == COMP_LOGIC_XOR)
|
||||
if(total_ports == total_true_ports)
|
||||
return FALSE
|
||||
if(.)
|
||||
return TRUE
|
||||
Reference in New Issue
Block a user