mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 13:10:02 +01:00
Refactors how circuit size is calculated. Fixed module circuit size not taking up capacity equal to the amount of circuit components inside of it. (#61554)
Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com>
This commit is contained in:
co-authored by
Watermelon914
parent
f109d9d654
commit
1a507d23ed
@@ -45,12 +45,15 @@
|
||||
/// The power usage whenever this component receives an input
|
||||
var/power_usage_per_input = 1
|
||||
|
||||
// Whether the component is removable or not. Only affects user UI
|
||||
/// Whether the component is removable or not. Only affects user UI
|
||||
var/removable = TRUE
|
||||
|
||||
// Defines which shells support this component. Only used as an informational guide, does not restrict placing these components in circuits.
|
||||
/// Defines which shells support this component. Only used as an informational guide, does not restrict placing these components in circuits.
|
||||
var/required_shells = null
|
||||
|
||||
/// Determines the amount of space this circuit occupies in an integrated circuit.
|
||||
var/circuit_size = 1
|
||||
|
||||
/// The UI buttons of this circuit component. An assoc list that has this format: "button_icon" = "action_name"
|
||||
var/ui_buttons = null
|
||||
|
||||
@@ -216,6 +219,14 @@
|
||||
trigger_output.set_output(COMPONENT_SIGNAL)
|
||||
return TRUE
|
||||
|
||||
/obj/item/circuit_component/proc/set_circuit_size(new_size)
|
||||
if(parent)
|
||||
parent.current_size -= circuit_size
|
||||
|
||||
circuit_size = new_size
|
||||
|
||||
if(parent)
|
||||
parent.current_size += circuit_size
|
||||
|
||||
/**
|
||||
* Called whether this circuit component should receive an input.
|
||||
|
||||
@@ -69,6 +69,9 @@ GLOBAL_LIST_EMPTY_TYPED(integrated_circuits, /obj/item/integrated_circuit)
|
||||
/// The Y position of the screen. Used for adding components.
|
||||
var/screen_y = 0
|
||||
|
||||
/// The current size of the circuit.
|
||||
var/current_size = 0
|
||||
|
||||
/obj/item/integrated_circuit/Initialize(mapload)
|
||||
. = ..()
|
||||
|
||||
@@ -224,6 +227,7 @@ GLOBAL_LIST_EMPTY_TYPED(integrated_circuits, /obj/item/integrated_circuit)
|
||||
to_add.rel_y = rand(COMPONENT_MIN_RANDOM_POS, COMPONENT_MAX_RANDOM_POS) - screen_y
|
||||
to_add.parent = src
|
||||
attached_components += to_add
|
||||
current_size += to_add.circuit_size
|
||||
RegisterSignal(to_add, COMSIG_MOVABLE_MOVED, .proc/component_move_handler)
|
||||
SStgui.update_uis(src)
|
||||
|
||||
@@ -255,6 +259,7 @@ GLOBAL_LIST_EMPTY_TYPED(integrated_circuits, /obj/item/integrated_circuit)
|
||||
to_remove.unregister_shell(shell)
|
||||
|
||||
UnregisterSignal(to_remove, COMSIG_MOVABLE_MOVED)
|
||||
current_size -= to_remove.circuit_size
|
||||
attached_components -= to_remove
|
||||
to_remove.disconnect()
|
||||
to_remove.parent = null
|
||||
|
||||
Reference in New Issue
Block a user