mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-20 12:35:33 +01:00
21b4095dfd
Upstream 04/17/2026 fixes https://github.com/Bubberstation/Bubberstation/issues/5549 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com> Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com> Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com> Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com> Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com> Co-authored-by: loganuk <fakeemail123@aol.com> Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com> Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com> Co-authored-by: Lucy <lucy@absolucy.moe> Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com> Co-authored-by: Isratosh <Isratosh@hotmail.com> Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com> Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com> Co-authored-by: Alexander V. <volas@ya.ru> Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com> Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com> Co-authored-by: Tim <timothymtorres@gmail.com> Co-authored-by: Iamgoofball <iamgoofball@gmail.com> Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com> Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com> Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com> Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com> Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com> Co-authored-by: Josh <josh.adam.powell@gmail.com> Co-authored-by: Josh Powell <josh.powell@softwire.com> Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com> Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com> Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com> Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
205 lines
7.0 KiB
Plaintext
205 lines
7.0 KiB
Plaintext
//File with the circuitboard and circuitboard/machine class definitions and procs
|
|
|
|
|
|
// Circuitboard
|
|
|
|
/obj/item/circuitboard
|
|
name = "circuit board"
|
|
/// extension that is applied after the initial name AKA (Computer/Machine Board)
|
|
var/name_extension = null
|
|
icon = 'icons/obj/devices/circuitry_n_data.dmi'
|
|
icon_state = "circuit_map"
|
|
inhand_icon_state = "electronic"
|
|
lefthand_file = 'icons/mob/inhands/items/devices_lefthand.dmi'
|
|
righthand_file = 'icons/mob/inhands/items/devices_righthand.dmi'
|
|
abstract_type = /obj/item/circuitboard
|
|
custom_materials = list(/datum/material/glass = HALF_SHEET_MATERIAL_AMOUNT)
|
|
w_class = WEIGHT_CLASS_SMALL
|
|
greyscale_colors = CIRCUIT_COLOR_GENERIC
|
|
var/build_path = null
|
|
/// whether or not the circuit board will build into a vendor whose products cost nothing (used for offstation vending machines mostly)
|
|
var/all_products_free = FALSE
|
|
///determines if the board requires specific levels of parts. (ie specifically a femto menipulator vs generic manipulator)
|
|
var/specific_parts = FALSE
|
|
|
|
/obj/item/circuitboard/Initialize(mapload)
|
|
if(name_extension)
|
|
name = "[initial(name)] [name_extension]"
|
|
if(icon_state == "circuit_map") // some circuitboards have cool custom sprites
|
|
set_greyscale(new_config = /datum/greyscale_config/circuit)
|
|
return ..()
|
|
|
|
/obj/item/circuitboard/grind_results()
|
|
return list(/datum/reagent/silicon = 20)
|
|
|
|
/obj/item/circuitboard/proc/apply_default_parts(obj/machinery/machine)
|
|
if(LAZYLEN(machine.component_parts))
|
|
// This really shouldn't happen. If it somehow does, print out a stack trace and gracefully handle it.
|
|
stack_trace("apply_defauly_parts called on machine that already had component_parts: [machine]")
|
|
|
|
// Remove references of components so it doesn't trigger Exited logic and remove existing parts.
|
|
for(var/obj/item/part as anything in machine.component_parts)
|
|
machine.component_parts -= part
|
|
qdel(part)
|
|
|
|
// List of components always contains the circuit board used to build it.
|
|
machine.component_parts = list(src)
|
|
forceMove(machine)
|
|
|
|
if(machine.circuit != src)
|
|
// This really shouldn't happen. If it somehow does, print out a stack trace and gracefully handle it.
|
|
stack_trace("apply_default_parts called from a circuit board that does not belong to machine: [machine]")
|
|
|
|
QDEL_NULL(machine.circuit)
|
|
machine.circuit = src
|
|
|
|
return
|
|
|
|
/**
|
|
* Used to allow the circuitboard to configure a machine in some way, shape or form.
|
|
*
|
|
* Arguments:
|
|
* * machine - The machine to attempt to configure.
|
|
*/
|
|
/obj/item/circuitboard/proc/configure_machine(obj/machinery/machine)
|
|
return
|
|
|
|
/**
|
|
* This proc is called during /obj/structure/frame/machine/finalize_construction in case there's anything else that needs to be met before completion.
|
|
* Arguments:
|
|
* * install_frame - The frame the circuit has been installed into for reference.
|
|
*/
|
|
/obj/item/circuitboard/proc/completion_requirements(obj/structure/frame/install_frame)
|
|
return TRUE
|
|
|
|
// Circuitboard/machine
|
|
/*Common Parts: Parts List: Ignitor, Timer, Infra-red laser, Infra-red sensor, t_scanner, Capacitor, Valve, sensor unit,
|
|
micro-manipulator, console screen, beaker, Microlaser, matter bin, power cells.
|
|
*/
|
|
|
|
/obj/item/circuitboard/machine
|
|
abstract_type = /obj/item/circuitboard/machine
|
|
name_extension = "(Machine Board)"
|
|
/// Whether this machine must be anchored to be constructed.
|
|
var/needs_anchored = TRUE
|
|
/// Components required by the machine.
|
|
/// Example: list(/obj/item/stock_parts/matter_bin = 5)
|
|
var/list/req_components
|
|
/// Default replacements for req_components, to be used in apply_default_parts instead of req_components types
|
|
/// Example: list(/obj/item/stock_parts/matter_bin = /obj/item/stock_parts/matter_bin/super)
|
|
var/list/def_components
|
|
/// List of atoms/datums to replace the default components placed inside the machine
|
|
var/list/replacement_parts
|
|
/// Components that need to be flatpacked along with the circuitboard so as to replace the defaults
|
|
var/list/obj/item/flatpack_components
|
|
|
|
/**
|
|
* Converts req_components map into a linear list with its datum components resolved
|
|
*
|
|
* Arguments
|
|
* * obj/machinery/machine - if not null adds the parts to the machine directly & will not return anything
|
|
*/
|
|
/obj/item/circuitboard/machine/proc/flatten_component_list(obj/machinery/machine)
|
|
SHOULD_NOT_OVERRIDE(TRUE)
|
|
|
|
. = NONE
|
|
if(QDELETED(machine))
|
|
. = list()
|
|
|
|
for(var/comp_path in req_components)
|
|
var/comp_amt = req_components[comp_path]
|
|
if(!comp_amt)
|
|
continue
|
|
|
|
if(def_components && def_components[comp_path])
|
|
comp_path = def_components[comp_path]
|
|
|
|
if(ispath(comp_path, /obj/item/stack))
|
|
continue
|
|
else if (ispath(comp_path, /datum/stock_part))
|
|
var/stock_part_datum = GLOB.stock_part_datums[comp_path]
|
|
if (isnull(stock_part_datum))
|
|
CRASH("[comp_path] didn't have a matching stock part datum")
|
|
for (var/_ in 1 to comp_amt)
|
|
if(!.)
|
|
machine.component_parts += stock_part_datum
|
|
else
|
|
. += stock_part_datum
|
|
else
|
|
for(var/_ in 1 to comp_amt)
|
|
if(!.)
|
|
machine.component_parts += new comp_path(machine)
|
|
else
|
|
. += comp_path
|
|
|
|
/**
|
|
* Applies the default component parts for this machine
|
|
*
|
|
* Arguments
|
|
* * obj/machinery/machine - the machine to apply the default parts to
|
|
*/
|
|
/obj/item/circuitboard/machine/apply_default_parts(obj/machinery/machine)
|
|
if(!req_components && !length(replacement_parts))
|
|
return
|
|
|
|
. = ..()
|
|
|
|
if(replacement_parts)
|
|
for(var/part in replacement_parts)
|
|
if(ispath(part, /obj/item))
|
|
part = new part(machine)
|
|
else if(ismovable(part))
|
|
var/atom/movable/thing = part
|
|
thing.forceMove(machine)
|
|
machine.component_parts += part
|
|
replacement_parts = null
|
|
else
|
|
flatten_component_list(machine)
|
|
|
|
machine.RefreshParts()
|
|
|
|
/obj/item/circuitboard/machine/examine(mob/user)
|
|
. = ..()
|
|
if(!LAZYLEN(req_components))
|
|
. += span_info("It requires no components.")
|
|
return
|
|
|
|
var/list/nice_list = list()
|
|
for(var/component_path in req_components)
|
|
if(!ispath(component_path))
|
|
continue
|
|
|
|
var/component_name
|
|
var/component_amount = req_components[component_path]
|
|
|
|
//e.g. "glass sheet" vs. "glass"
|
|
if(ispath(component_path, /obj/item/stack))
|
|
var/obj/item/stack/stack_path = component_path
|
|
component_name = initial(stack_path.singular_name)
|
|
|
|
//stock parts in datum or obj form
|
|
else if(ispath(component_path, /obj/item/stock_parts) || ispath(component_path, /datum/stock_part))
|
|
var/obj/item/stock_parts/stock_part
|
|
if(ispath(component_path, /obj/item/stock_parts))
|
|
stock_part = component_path
|
|
else
|
|
var/datum/stock_part/datum_part = component_path
|
|
stock_part = initial(datum_part.physical_object_type)
|
|
|
|
if(!specific_parts)
|
|
component_name = initial(stock_part.base_name)
|
|
if(!component_name)
|
|
component_name = initial(stock_part.name)
|
|
|
|
//beakers, any non conventional part
|
|
else if(ispath(component_path, /atom))
|
|
var/atom/stock_part = component_path
|
|
component_name = initial(stock_part.name)
|
|
|
|
//append decoded name to final result
|
|
if (isnull(component_name))
|
|
stack_trace("[component_path] was an invalid component")
|
|
nice_list += list("[component_amount] [component_name]\s")
|
|
|
|
. += span_info("It requires [english_list(nice_list)].")
|