mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-12 02:32:10 +00:00
* Refactored fundamental circuit components that have varying inputs. Improvements to the integrated circuit UI. Improves and rebalances the drone shell (#68586) * Refactored fundamental circuit components that have varying inputs. Made the integrated circuit UI slightly better. * Fixes with UI * Removes logger * Ran prettier * Fixed documentation * Rebalances drone circuit * Drones can now charge in chargers Co-authored-by: Watermelon914 <hidden@ hidden.com> * Refactored fundamental circuit components that have varying inputs. Improvements to the integrated circuit UI. Improves and rebalances the drone shell Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Co-authored-by: Watermelon914 <hidden@ hidden.com>
43 lines
1.2 KiB
Plaintext
43 lines
1.2 KiB
Plaintext
/**
|
|
* # Binary Conversion Component
|
|
*
|
|
* Return an array of binary digits from a number input.
|
|
*/
|
|
/obj/item/circuit_component/binary_conversion
|
|
display_name = "Binary Conversion"
|
|
desc = "Splits a decimal number into an array of binary digits, or bits, represented as 1 or 0 and often used in boolean or binary operations like AND, OR and XOR."
|
|
category = "Math"
|
|
|
|
/// One number
|
|
var/datum/port/input/number
|
|
|
|
/// Many binary digits
|
|
var/list/datum/port/bit_array = list()
|
|
|
|
ui_buttons = list(
|
|
"plus" = "add",
|
|
"minus" = "remove"
|
|
)
|
|
|
|
|
|
/obj/item/circuit_component/binary_conversion/populate_ports()
|
|
AddComponent(/datum/component/circuit_component_add_port, \
|
|
port_list = bit_array, \
|
|
add_action = "add", \
|
|
remove_action = "remove", \
|
|
is_output = TRUE, \
|
|
port_type = PORT_TYPE_NUMBER, \
|
|
prefix = "Bit", \
|
|
minimum_amount = 1, \
|
|
maximum_amount = MAX_BITFIELD_SIZE \
|
|
)
|
|
number = add_input_port("Number", PORT_TYPE_NUMBER, order = 1.1)
|
|
|
|
/obj/item/circuit_component/binary_conversion/input_received(datum/port/input/port)
|
|
if(!length(bit_array))
|
|
return
|
|
|
|
for(var/iteration in 1 to length(bit_array))
|
|
var/datum/port/output/bit = bit_array[iteration]
|
|
bit.set_output(number.value & (2 ** (iteration - 1)))
|