Merge pull request #2647 from CHOMPStationBot/upstream-merge-11224

[MIRROR] Add recycling machinery
This commit is contained in:
Nadyr
2021-07-24 23:44:49 -04:00
committed by GitHub
7 changed files with 285 additions and 1 deletions

View File

@@ -214,7 +214,7 @@
/obj/item/weapon/rms/attack_self(mob/user) /obj/item/weapon/rms/attack_self(mob/user)
var/list/choices = list( var/list/choices = list(
"Steel" = radial_image_steel, "Steel" = radial_image_steel,
MAT_GLASS = radial_image_glass, "Glass" = radial_image_glass,
"Cloth" = radial_image_cloth, "Cloth" = radial_image_cloth,
"Plastic" = radial_image_plastic, "Plastic" = radial_image_plastic,
"Stone" = radial_image_stone, "Stone" = radial_image_stone,

View File

@@ -0,0 +1,41 @@
#ifndef T_BOARD
#error T_BOARD macro is not defined but we need it!
#endif
/obj/item/weapon/circuitboard/recycler_crusher
name = T_BOARD("recycler - crusher")
build_path = /obj/machinery/recycling/crusher
board_type = new /datum/frame/frame_types/machine
origin_tech = list(TECH_MATERIAL = 2)
matter = list(MAT_STEEL = 50, MAT_GLASS = 50)
req_components = list(
/obj/item/stack/cable_coil = 2,
/obj/item/weapon/stock_parts/motor = 1,
/obj/item/weapon/stock_parts/gear = 1,
/obj/item/weapon/stock_parts/matter_bin = 1,
/obj/item/weapon/stock_parts/manipulator = 1
)
/obj/item/weapon/circuitboard/recycler_sorter
name = T_BOARD("recycler - sorter")
build_path = /obj/machinery/recycling/sorter
board_type = new /datum/frame/frame_types/machine
origin_tech = list(TECH_MATERIAL = 2)
matter = list(MAT_STEEL = 50, MAT_GLASS = 50)
req_components = list(
/obj/item/stack/cable_coil = 2,
/obj/item/weapon/stock_parts/motor = 1,
/obj/item/weapon/stock_parts/gear = 3
)
/obj/item/weapon/circuitboard/recycler_stamper
name = T_BOARD("recycler - stamper")
build_path = /obj/machinery/recycling/stamper
board_type = new /datum/frame/frame_types/machine
origin_tech = list(TECH_MATERIAL = 2)
matter = list(MAT_STEEL = 50, MAT_GLASS = 50)
req_components = list(
/obj/item/stack/cable_coil = 2,
/obj/item/weapon/stock_parts/gear = 2,
/obj/item/weapon/stock_parts/motor = 2
)

View File

@@ -0,0 +1,220 @@
/obj/machinery/recycling
idle_power_usage = 5
active_power_usage = 500
density = TRUE
anchored = TRUE
var/working = FALSE
/obj/machinery/recycling/process()
return PROCESS_KILL // these are all stateful
/obj/machinery/recycling/update_icon()
. = ..()
cut_overlays()
if(panel_open)
add_overlay("[initial(icon_state)]-panel")
/**
* Generic procs common to all
*/
/obj/machinery/recycling/attackby(obj/item/O, mob/user)
if(!isliving(user) || !Adjacent(user))
return
if(working)
to_chat("<span class='warning'>\The [src] is busy! Wait until it's idle.</span>")
return
if(default_deconstruction_screwdriver(user, O))
return
if(default_deconstruction_crowbar(user, O))
return
if(default_part_replacement(user, O))
return
var/mob/living/M = user
if(can_accept_item(O))
M.drop_from_inventory(O)
take_item(O)
M.visible_message("<b>[M]</b> inserts [O] into [src].", "You insert [O] into [src].")
else
to_chat(user, "<span class='warning'>\The [src] can't accept [O] for recycling.</span>")
// Conveyors etc
/obj/machinery/recycling/Bumped(atom/A)
if(isitem(A) && can_accept_item(A))
take_item(A)
/obj/machinery/recycling/proc/can_accept_item(obj/item/O)
if(stat & (NOPOWER|BROKEN))
return FALSE
if(panel_open)
return FALSE
return !working
/obj/machinery/recycling/proc/take_item(obj/item/O)
O.forceMove(src)
/**
* This machine takes items and turns them into heaps of junk.
*/
/obj/machinery/recycling/crusher
name = "recycling crusher"
desc = "This machine is designed to break things into their constituient parts via the application of directed kinetic force. A.K.A. it crushes things into bits."
description_info = "This machine is the first step in turning things back into their materials. There's a bit of loss, depending on how upgraded it is. The output of this machine goes into the sorter."
icon = 'icons/obj/recycling.dmi'
icon_state = "crusher"
circuit = /obj/item/weapon/circuitboard/recycler_crusher
working = FALSE
var/effic_factor = 0.5
/obj/machinery/recycling/crusher/RefreshParts()
. = ..()
var/total_rating = 0
for(var/obj/item/weapon/stock_parts/matter_bin/M in component_parts)
total_rating += M.rating
for(var/obj/item/weapon/stock_parts/manipulator/M in component_parts)
total_rating += M.rating
total_rating *= 0.1
effic_factor = CLAMP01(initial(effic_factor)+total_rating)
/obj/machinery/recycling/crusher/can_accept_item(obj/item/O)
if(LAZYLEN(O.matter))
return ..()
return FALSE
/obj/machinery/recycling/crusher/take_item(obj/item/O)
. = ..()
working = TRUE
icon_state = "crusher-process"
update_use_power(USE_POWER_ACTIVE)
sleep(5 SECONDS)
var/list/modified_mats = list()
for(var/mat in O.matter)
modified_mats[mat] = O.matter[mat]*effic_factor
new /obj/item/debris_pack(get_step(src, dir), modified_mats)
update_use_power(USE_POWER_IDLE)
icon_state = "crusher"
qdel(O)
working = FALSE
/**
* This machine takes heaps of junk and holds onto them until it has enough of one material to make a sheet.
*/
/obj/machinery/recycling/sorter
name = "debris sorter"
desc = "A machine for retaining debris and sorting it until enough of a similar material have accumulated to warrant conversion into sheets or ingots."
description_info = "The output of the recycling crusher should go into this machine, and it will output material dust, which can go into the sheet stamper to make sheets."
icon = 'icons/obj/recycling.dmi'
icon_state = "sorter"
circuit = /obj/item/weapon/circuitboard/recycler_sorter
var/list/materials = list()
working = FALSE
/obj/machinery/recycling/sorter/can_accept_item(obj/item/O)
if(istype(O, /obj/item/debris_pack))
return ..()
return FALSE
/obj/machinery/recycling/sorter/take_item(obj/item/O)
. = ..()
working = TRUE
icon_state = "sorter-process"
update_use_power(USE_POWER_ACTIVE)
sleep(5 SECONDS)
sort_item(O)
dispense_if_possible()
update_use_power(USE_POWER_IDLE)
icon_state = "sorter"
working = FALSE
/obj/machinery/recycling/sorter/proc/sort_item(obj/item/O)
for(var/mat in O.matter)
if(mat in materials)
materials[mat] += O.matter[mat]
else
materials[mat] = O.matter[mat]
qdel(O)
/obj/machinery/recycling/sorter/proc/dispense_if_possible()
for(var/mat in materials)
while(materials[mat] >= SHEET_MATERIAL_AMOUNT)
materials[mat] -= SHEET_MATERIAL_AMOUNT
new /obj/item/material_dust(get_step(src, dir), mat)
sleep(2 SECONDS)
/**
* This machine makes sheets after being provided with material dust from a sorter.
*/
/obj/machinery/recycling/stamper
name = "sheet stamper"
desc = "A machine to press homogenous material particulate into more solid portable units of production. A.K.A. it compacts dust into sheets."
description_info = "This machine is the last step in the recycling process. The output of a debris sorter should be fed into this machine and it will produce material sheets."
icon = 'icons/obj/recycling.dmi'
icon_state = "stamper"
circuit = /obj/item/weapon/circuitboard/recycler_stamper
/obj/machinery/recycling/stamper/can_accept_item(obj/item/O)
if(istype(O, /obj/item/material_dust))
return ..()
return FALSE
/obj/machinery/recycling/stamper/take_item(obj/item/O)
. = ..()
working = TRUE
icon_state = "stamper-process"
update_use_power(USE_POWER_ACTIVE)
sleep(64)
dust_to_sheet(O)
icon_state = "stamper"
update_use_power(USE_POWER_IDLE)
working = FALSE
/obj/machinery/recycling/stamper/proc/dust_to_sheet(obj/item/material_dust/D)
if(!istype(D))
return
var/datum/material/M = get_material_by_name(D.material_name)
if(!M)
D.forceMove(get_step(src, dir))
playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0)
warning("Dust in [src] had material_name [D.material_name], which can't be made into stacks")
return
var/stacktype = M.stack_type
var/turf/T = get_step(src, dir)
var/obj/item/stack/S = locate(stacktype) in T
if(S)
S.amount++
else
new stacktype(T)
/obj/item/debris_pack
name = "debris"
desc = "Some ground-up parts of ... something. Might be useful for recycling."
icon = 'icons/obj/recycling.dmi'
icon_state = "debris"
w_class = ITEMSIZE_NORMAL
/obj/item/debris_pack/New(newloc, list/matter)
..()
src.matter = matter.Copy()
/obj/item/material_dust
name = "dust"
desc = "A homogenous powder of some material or another. Might be useful for recycling."
icon = 'icons/obj/recycling.dmi'
icon_state = "matdust"
w_class = ITEMSIZE_SMALL
var/material_name
/obj/item/material_dust/New(loc, mat)
..()
material_name = mat
name = "[material_name] [initial(name)]"
var/datum/material/M = get_material_by_name(material_name)
color = M?.icon_colour

View File

@@ -689,3 +689,24 @@ CIRCUITS BELOW
req_tech = list(TECH_DATA = 4, TECH_ENGINEERING = 3, TECH_COMBAT = 2) req_tech = list(TECH_DATA = 4, TECH_ENGINEERING = 3, TECH_COMBAT = 2)
build_path = /obj/item/weapon/circuitboard/pointdefense_control build_path = /obj/item/weapon/circuitboard/pointdefense_control
sort_string = "OAABB" sort_string = "OAABB"
/datum/design/circuit/recycler_crusher
name = "recycler - crusher"
id = "recycler_crusher"
req_tech = list(TECH_MATERIAL = 2)
build_path = /obj/item/weapon/circuitboard/recycler_crusher
sort_string = "OAABC"
/datum/design/circuit/recycler_sorter
name = "recycler - sorter"
id = "recycler_sorter"
req_tech = list(TECH_MATERIAL = 2)
build_path = /obj/item/weapon/circuitboard/recycler_sorter
sort_string = "OAABD"
/datum/design/circuit/recycler_stamper
name = "recycler - stamper"
id = "recycler_stamper"
req_tech = list(TECH_MATERIAL = 2)
build_path = /obj/item/weapon/circuitboard/recycler_stamper
sort_string = "OAABE"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 73 KiB

View File

@@ -1384,6 +1384,7 @@
#include "code\game\objects\items\weapons\circuitboards\machinery\papershredder.dm" #include "code\game\objects\items\weapons\circuitboards\machinery\papershredder.dm"
#include "code\game\objects\items\weapons\circuitboards\machinery\power.dm" #include "code\game\objects\items\weapons\circuitboards\machinery\power.dm"
#include "code\game\objects\items\weapons\circuitboards\machinery\recharge_station.dm" #include "code\game\objects\items\weapons\circuitboards\machinery\recharge_station.dm"
#include "code\game\objects\items\weapons\circuitboards\machinery\recycling.dm"
#include "code\game\objects\items\weapons\circuitboards\machinery\research.dm" #include "code\game\objects\items\weapons\circuitboards\machinery\research.dm"
#include "code\game\objects\items\weapons\circuitboards\machinery\shieldgen.dm" #include "code\game\objects\items\weapons\circuitboards\machinery\shieldgen.dm"
#include "code\game\objects\items\weapons\circuitboards\machinery\ships.dm" #include "code\game\objects\items\weapons\circuitboards\machinery\ships.dm"
@@ -3893,6 +3894,7 @@
#include "code\modules\recycling\conveyor2.dm" #include "code\modules\recycling\conveyor2.dm"
#include "code\modules\recycling\disposal-construction.dm" #include "code\modules\recycling\disposal-construction.dm"
#include "code\modules\recycling\disposal.dm" #include "code\modules\recycling\disposal.dm"
#include "code\modules\recycling\recycling.dm"
#include "code\modules\recycling\sortingmachinery.dm" #include "code\modules\recycling\sortingmachinery.dm"
#include "code\modules\research\circuitprinter.dm" #include "code\modules\research\circuitprinter.dm"
#include "code\modules\research\designs.dm" #include "code\modules\research\designs.dm"