mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +01:00
[MIRROR] Refactored fundamental circuit components that have varying inputs. Improvements to the integrated circuit UI. Improves and rebalances the drone shell [MDB IGNORE] (#15264)
* 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>
This commit is contained in:
co-authored by
Watermelon914
Watermelon914
parent
e2c4318f29
commit
856ea9c79a
@@ -1,72 +0,0 @@
|
||||
/**
|
||||
* # Binary Decimal Component
|
||||
*
|
||||
* Has a bit array on one side and a decimal number on the other.
|
||||
*/
|
||||
/obj/item/circuit_component/binary_decimal
|
||||
display_name = "Decimal - Bit Array"
|
||||
desc = "Splits a decimal number into an array of binary digits and vicecersa."
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
|
||||
|
||||
/// One number
|
||||
var/datum/port/output/number
|
||||
|
||||
/// Many binary digits
|
||||
var/list/datum/port/bit_array = list()
|
||||
|
||||
var/array_size = 0
|
||||
|
||||
var/default_array_size = 8
|
||||
|
||||
var/min_size = 1 //Who in their right mind would use a 1-bit array for circuits anyway?
|
||||
var/max_size = MAX_BITFIELD_SIZE
|
||||
|
||||
ui_buttons = list(
|
||||
"plus" = "increase",
|
||||
"minus" = "decrease"
|
||||
)
|
||||
|
||||
/obj/item/circuit_component/binary_decimal/save_data_to_list(list/component_data)
|
||||
. = ..()
|
||||
component_data["array_size"] = array_size
|
||||
|
||||
/obj/item/circuit_component/binary_decimal/load_data_from_list(list/component_data)
|
||||
set_array_size(component_data["array_size"])
|
||||
return ..()
|
||||
|
||||
/obj/item/circuit_component/binary_decimal/proc/set_array_size(new_size)
|
||||
if(new_size <= 0)
|
||||
for(var/datum/port/port in bit_array)
|
||||
remove_bit_port(port)
|
||||
bit_array = list()
|
||||
array_size = 0
|
||||
return
|
||||
|
||||
while(array_size > new_size)
|
||||
var/index = length(bit_array)
|
||||
var/datum/port/output = bit_array[index]
|
||||
bit_array -= output
|
||||
remove_bit_port(output)
|
||||
array_size--
|
||||
|
||||
while(array_size < new_size)
|
||||
array_size++
|
||||
var/index = length(bit_array)
|
||||
bit_array += add_bit_port(index)
|
||||
|
||||
/obj/item/circuit_component/binary_decimal/proc/add_bit_port(index)
|
||||
return
|
||||
|
||||
/obj/item/circuit_component/binary_decimal/proc/remove_bit_port(datum/port/to_remove)
|
||||
return
|
||||
|
||||
/obj/item/circuit_component/binary_decimal/populate_ports()
|
||||
set_array_size(default_array_size)
|
||||
|
||||
// Increase or decrease the array size
|
||||
/obj/item/circuit_component/binary_decimal/ui_perform_action(mob/user, action)
|
||||
switch(action)
|
||||
if("increase")
|
||||
set_array_size(min(array_size + 1, max_size))
|
||||
if("decrease")
|
||||
set_array_size(max(array_size - 1, min_size))
|
||||
@@ -6,9 +6,6 @@
|
||||
/obj/item/circuit_component/compare
|
||||
display_name = "Compare"
|
||||
|
||||
/// The amount of input ports to have
|
||||
var/input_port_amount = 4
|
||||
|
||||
/// The trigger for the true/false signals
|
||||
var/datum/port/input/compare
|
||||
|
||||
@@ -19,13 +16,7 @@
|
||||
/// The result from the output
|
||||
var/datum/port/output/result
|
||||
|
||||
var/list/datum/port/input/compare_ports = list()
|
||||
|
||||
/obj/item/circuit_component/compare/populate_ports()
|
||||
for(var/port_id in 1 to input_port_amount)
|
||||
var/letter = ascii2text(text2ascii("A") + (port_id-1))
|
||||
compare_ports += add_input_port(letter, PORT_TYPE_ANY)
|
||||
|
||||
populate_custom_ports()
|
||||
compare = add_input_port("Compare", PORT_TYPE_SIGNAL)
|
||||
|
||||
@@ -41,7 +32,7 @@
|
||||
|
||||
/obj/item/circuit_component/compare/input_received(datum/port/input/port)
|
||||
|
||||
var/logic_result = do_comparisons(compare_ports)
|
||||
var/logic_result = do_comparisons()
|
||||
if(COMPONENT_TRIGGERED_BY(compare, port))
|
||||
if(logic_result)
|
||||
true.set_output(COMPONENT_SIGNAL)
|
||||
@@ -50,5 +41,5 @@
|
||||
result.set_output(logic_result)
|
||||
|
||||
/// Do the comparisons and return a result
|
||||
/obj/item/circuit_component/compare/proc/do_comparisons(list/ports)
|
||||
/obj/item/circuit_component/compare/proc/do_comparisons()
|
||||
return FALSE
|
||||
|
||||
Reference in New Issue
Block a user