mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-29 16:18:01 +01:00
[MIRROR] Circuit components can now be recycles in circuit printers, and automatically do so upon being removed if a circuit has a linked printer (#29316)
* Circuit components can now be recycles in circuit printers, and automatically do so upon being removed if a circuit has a linked printer (#85648) ## About The Pull Request Added support for remote material insertion type whitelists and utilized it to allow circuit printers to recycle components. Removing a component from UI while the circuit has a linked printer will automatically recycle it. Also fixed a rogue space appearing when recycling a single item ## Why It's Good For The Game You literally cannot do anything with components you remove/do not need anymore so usually they end up littering circuit lab's floors. This should make developing circuits slightly less annoying. ## Changelog 🆑 qol: Circuit components can now be recycles in circuit printers, and automatically do so upon being removed if a circuit has a linked printer spellcheck: Recycling a single item no longer outputs a line with a rogue space infront of it /🆑 * Circuit components can now be recycles in circuit printers, and automatically do so upon being removed if a circuit has a linked printer --------- Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com>
This commit is contained in:
@@ -259,7 +259,7 @@
|
||||
* * user - the mob inserting this item
|
||||
* * context - the atom performing the operation, this is the last argument sent in COMSIG_MATCONTAINER_ITEM_CONSUMED and is used mostly for silo logging
|
||||
*/
|
||||
/datum/component/material_container/proc/user_insert(obj/item/held_item, mob/living/user, atom/context = parent)
|
||||
/datum/component/material_container/proc/user_insert(obj/item/held_item, mob/living/user, atom/context = parent, forced_type = FALSE)
|
||||
set waitfor = FALSE
|
||||
. = 0
|
||||
|
||||
@@ -297,7 +297,7 @@
|
||||
if(SEND_SIGNAL(src, COMSIG_MATCONTAINER_PRE_USER_INSERT, target_item, user) & MATCONTAINER_BLOCK_INSERT)
|
||||
continue
|
||||
//item is either indestructible, not allowed for redemption or not in the allowed types
|
||||
if((target_item.resistance_flags & INDESTRUCTIBLE) || (target_item.item_flags & NO_MAT_REDEMPTION) || (allowed_item_typecache && !is_type_in_typecache(target_item, allowed_item_typecache)))
|
||||
if((target_item.resistance_flags & INDESTRUCTIBLE) || (target_item.item_flags & NO_MAT_REDEMPTION) || (allowed_item_typecache && !is_type_in_typecache(target_item, allowed_item_typecache) && !forced_type))
|
||||
if(!(mat_container_flags & MATCONTAINER_SILENT))
|
||||
var/list/status_data = chat_msgs["[MATERIAL_INSERT_ITEM_FAILURE]"] || list()
|
||||
var/list/item_data = status_data[target_item.name] || list()
|
||||
@@ -455,9 +455,9 @@
|
||||
if(MATERIAL_INSERT_ITEM_SUCCESS) //no problems full item was consumed
|
||||
if(chat_data["stack"])
|
||||
var/sheets = min(count, amount) //minimum between sheets inserted vs sheets consumed(values differ for alloys)
|
||||
to_chat(user, span_notice("[sheets > 1 ? sheets : ""] [item_name][sheets > 1 ? "s were" : " was"] added to [parent]."))
|
||||
to_chat(user, span_notice("[sheets > 1 ? "[sheets] " : ""][item_name][sheets > 1 ? "s were" : " was"] added to [parent]."))
|
||||
else
|
||||
to_chat(user, span_notice("[count > 1 ? count : ""] [item_name][count > 1 ? "s" : ""], worth [amount] sheets, [count > 1 ? "were" : "was"] added to [parent]."))
|
||||
to_chat(user, span_notice("[count > 1 ? "[count] " : ""][item_name][count > 1 ? "s" : ""], worth [amount] sheets, [count > 1 ? "were" : "was"] added to [parent]."))
|
||||
if(MATERIAL_INSERT_ITEM_NO_SPACE) //no space
|
||||
to_chat(user, span_warning("[parent] has no space to accept [item_name]!"))
|
||||
if(MATERIAL_INSERT_ITEM_NO_MATS) //no materials inside these items
|
||||
|
||||
@@ -23,13 +23,16 @@ handles linking back and forth.
|
||||
var/mat_container_flags = NONE
|
||||
///List of signals to hook onto the local container
|
||||
var/list/mat_container_signals
|
||||
///Typecache for items that the silo will accept through this remote no matter what
|
||||
var/list/whitelist_typecache
|
||||
|
||||
/datum/component/remote_materials/Initialize(
|
||||
mapload,
|
||||
allow_standalone = TRUE,
|
||||
force_connect = FALSE,
|
||||
mat_container_flags = NONE,
|
||||
list/mat_container_signals = null
|
||||
list/mat_container_signals = null,
|
||||
list/whitelist_typecache = null
|
||||
)
|
||||
if (!isatom(parent))
|
||||
return COMPONENT_INCOMPATIBLE
|
||||
@@ -37,6 +40,7 @@ handles linking back and forth.
|
||||
src.allow_standalone = allow_standalone
|
||||
src.mat_container_flags = mat_container_flags
|
||||
src.mat_container_signals = mat_container_signals
|
||||
src.whitelist_typecache = whitelist_typecache
|
||||
|
||||
RegisterSignal(parent, COMSIG_ATOM_TOOL_ACT(TOOL_MULTITOOL), PROC_REF(OnMultitool))
|
||||
|
||||
@@ -93,6 +97,9 @@ handles linking back and forth.
|
||||
allowed_items = /obj/item/stack \
|
||||
)
|
||||
|
||||
if (whitelist_typecache)
|
||||
mat_container.allowed_item_typecache |= whitelist_typecache
|
||||
|
||||
/datum/component/remote_materials/proc/toggle_holding(force_hold = FALSE)
|
||||
if(isnull(silo))
|
||||
return
|
||||
@@ -140,7 +147,7 @@ handles linking back and forth.
|
||||
return
|
||||
|
||||
if(silo)
|
||||
mat_container.user_insert(target, user, parent)
|
||||
mat_container.user_insert(target, user, parent, (whitelist_typecache && is_type_in_typecache(target, whitelist_typecache)))
|
||||
|
||||
return COMPONENT_NO_AFTERATTACK
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
name = "Component ( NULL ENTRY )"
|
||||
desc = "A component that goes into an integrated circuit."
|
||||
build_type = COMPONENT_PRINTER
|
||||
materials = list(/datum/material/glass =HALF_SHEET_MATERIAL_AMOUNT)
|
||||
materials = list(/datum/material/glass = HALF_SHEET_MATERIAL_AMOUNT)
|
||||
departmental_flags = DEPARTMENT_BITFLAG_SCIENCE
|
||||
category = list(
|
||||
RND_CATEGORY_CIRCUITRY + RND_SUBCATEGORY_CIRCUITRY_COMPONENTS
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
inhand_icon_state = "electronic"
|
||||
lefthand_file = 'icons/mob/inhands/items/devices_lefthand.dmi'
|
||||
righthand_file = 'icons/mob/inhands/items/devices_righthand.dmi'
|
||||
custom_materials = list(/datum/material/glass = HALF_SHEET_MATERIAL_AMOUNT)
|
||||
|
||||
/// The name of the component shown on the UI
|
||||
var/display_name = "Generic"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
/obj/machinery/component_printer/Initialize(mapload)
|
||||
. = ..()
|
||||
materials = AddComponent(/datum/component/remote_materials, mapload)
|
||||
materials = AddComponent(/datum/component/remote_materials, mapload, whitelist_typecache = typecacheof(/obj/item/circuit_component))
|
||||
|
||||
/obj/machinery/component_printer/post_machine_initialize()
|
||||
. = ..()
|
||||
|
||||
@@ -509,6 +509,9 @@ GLOBAL_LIST_EMPTY_TYPED(integrated_circuits, /obj/item/integrated_circuit)
|
||||
remove_component(component)
|
||||
if(component.loc == src)
|
||||
usr.put_in_hands(component)
|
||||
var/obj/machinery/component_printer/printer = linked_component_printer?.resolve()
|
||||
if (!isnull(printer))
|
||||
printer.attackby(component, usr)
|
||||
. = TRUE
|
||||
if("set_component_coordinates")
|
||||
var/component_id = text2num(params["component_id"])
|
||||
|
||||
Reference in New Issue
Block a user