Skip to content

Commit 3f9bd76

Browse files
Adds an industrial centrifuge to replace the honey extractor.
1 parent 6425023 commit 3f9bd76

File tree

13 files changed

+272
-23
lines changed

13 files changed

+272
-23
lines changed

code/game/machinery/centrifuge.dm

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
/datum/storage/hopper/industrial/centrifuge
2+
can_hold = list(
3+
/obj/item/food,
4+
)
5+
expected_type = /obj/machinery/centrifuge
6+
7+
/datum/storage/hopper/industrial/centrifuge/proc/should_ingest(mob/user, obj/item/thing)
8+
if(thing.reagents?.total_volume <= 0)
9+
if(user)
10+
to_chat(user, SPAN_WARNING("\The [thing] is empty."))
11+
return FALSE
12+
return TRUE
13+
14+
/datum/storage/hopper/industrial/centrifuge/can_be_inserted(obj/item/W, mob/user, stop_messages, click_params)
15+
. = ..()
16+
if(. && !should_ingest(user, W))
17+
return FALSE
18+
19+
/obj/machinery/centrifuge
20+
name = "industrial centrifuge"
21+
desc = "A machine used to extract reagents and materials from objects via spinning them at extreme speed."
22+
icon = 'icons/obj/machines/centrifuge.dmi'
23+
icon_state = ICON_STATE_WORLD
24+
anchored = TRUE
25+
density = TRUE
26+
construct_state = /decl/machine_construction/default/panel_closed
27+
uncreated_component_parts = null
28+
storage = /datum/storage/hopper/industrial/centrifuge
29+
base_type = /obj/machinery/centrifuge
30+
stat_immune = 0
31+
32+
// Reference to our reagent container. Set to a path to create on init.
33+
var/obj/item/loaded_beaker
34+
35+
// Stolen from fabricators.
36+
var/sound_id
37+
var/datum/sound_token/sound_token
38+
var/work_sound = 'sound/machines/fabricator_loop.ogg'
39+
40+
/obj/machinery/centrifuge/mapped
41+
loaded_beaker = /obj/item/chems/glass/beaker/large
42+
43+
/obj/machinery/centrifuge/Initialize()
44+
. = ..()
45+
if(ispath(loaded_beaker))
46+
loaded_beaker = new loaded_beaker
47+
48+
/obj/machinery/centrifuge/get_stored_inventory()
49+
. = ..()
50+
if(LAZYLEN(.))
51+
LAZYREMOVE(., loaded_beaker)
52+
53+
/obj/machinery/centrifuge/Destroy()
54+
QDEL_NULL(loaded_beaker)
55+
return ..()
56+
57+
/obj/machinery/centrifuge/dismantle()
58+
if(loaded_beaker)
59+
loaded_beaker.dropInto(loc)
60+
loaded_beaker = null
61+
return ..()
62+
63+
/obj/machinery/centrifuge/components_are_accessible(path)
64+
return use_power != POWER_USE_ACTIVE && ..()
65+
66+
/obj/machinery/centrifuge/cannot_transition_to(state_path, mob/user)
67+
if(use_power == POWER_USE_ACTIVE)
68+
return SPAN_NOTICE("You must wait for \the [src] to finish first!")
69+
return ..()
70+
71+
/obj/machinery/centrifuge/attackby(obj/item/used_item, mob/user)
72+
73+
if(use_power == POWER_USE_ACTIVE)
74+
to_chat(user, SPAN_NOTICE("\The [src] is currently spinning, wait until it's finished."))
75+
return TRUE
76+
77+
if((. = component_attackby(used_item, user)))
78+
return
79+
80+
// Load in a new container for products.
81+
if(istype(used_item, /obj/item/chems/glass/beaker))
82+
if(loaded_beaker)
83+
to_chat(user, SPAN_WARNING("\The [src] already has a beaker loaded."))
84+
return TRUE
85+
if(user.try_unequip(used_item, src))
86+
loaded_beaker = used_item
87+
to_chat(user, SPAN_NOTICE("You load \the [loaded_beaker] into \the [src]."))
88+
return TRUE
89+
90+
// Parent call handles inserting the frame into our contents,
91+
return ..()
92+
93+
/obj/machinery/centrifuge/attack_hand(mob/user)
94+
95+
if(use_power == POWER_USE_ACTIVE)
96+
user.visible_message("\The [user] disengages \the [src].")
97+
update_use_power(POWER_USE_IDLE)
98+
return TRUE
99+
100+
if(use_power == POWER_USE_IDLE)
101+
if(!loaded_beaker || QDELETED(loaded_beaker))
102+
to_chat(user, SPAN_WARNING("\The [src] has no beaker loaded to receive any products."))
103+
loaded_beaker = null // just in case
104+
return TRUE
105+
106+
if(length(get_stored_inventory()))
107+
user.visible_message("\The [user] engages \the [src].")
108+
update_use_power(POWER_USE_ACTIVE)
109+
else
110+
to_chat(user, SPAN_WARNING("\The [src]'s hopper is empty."))
111+
return TRUE
112+
113+
if(use_power == POWER_USE_OFF || !operable())
114+
to_chat(user, SPAN_WARNING("\The [src]'s interface is unresponsive."))
115+
return TRUE
116+
117+
return ..()
118+
119+
/obj/machinery/centrifuge/Process(wait, tick)
120+
..()
121+
122+
if(use_power != POWER_USE_ACTIVE)
123+
return
124+
125+
if(!loaded_beaker)
126+
visible_message("\The [src] stops spinning and flashes a red light.")
127+
update_use_power(POWER_USE_IDLE)
128+
return
129+
130+
var/list/processing_items = get_stored_inventory()
131+
if(!length(processing_items))
132+
visible_message("\The [src] stops spinning and flashes a green light.")
133+
update_use_power(POWER_USE_IDLE)
134+
return
135+
136+
var/obj/item/thing = processing_items[1]
137+
thing.handle_centrifuge_process(src)
138+
if(!QDELETED(thing) && loc)
139+
thing.dropInto(loc)
140+
141+
/obj/machinery/centrifuge/Initialize()
142+
sound_id = "[work_sound]"
143+
return ..()
144+
145+
/obj/machinery/centrifuge/Destroy()
146+
QDEL_NULL(sound_token)
147+
return ..()
148+
149+
/obj/machinery/centrifuge/update_use_power()
150+
. = ..()
151+
if(use_power == POWER_USE_ACTIVE)
152+
if(!sound_token)
153+
sound_token = play_looping_sound(src, sound_id, work_sound, volume = 30)
154+
else
155+
QDEL_NULL(sound_token)
156+
157+
/obj/machinery/centrifuge/on_update_icon()
158+
icon_state = initial(icon_state)
159+
if(stat & BROKEN)
160+
icon_state = "[icon_state]-broken"
161+
else if(use_power == POWER_USE_OFF || !operable())
162+
icon_state = "[icon_state]-off"
163+
else if(use_power == POWER_USE_ACTIVE)
164+
icon_state = "[icon_state]-working"
165+
166+
/obj/machinery/centrifuge/get_quick_interaction_handler(mob/user)
167+
return loaded_beaker ? GET_DECL(/decl/interaction_handler/remove_centrifuge_beaker) : null
168+
169+
/obj/machinery/centrifuge/get_alt_interactions(var/mob/user)
170+
. = ..()
171+
if(loaded_beaker)
172+
LAZYADD(., /decl/interaction_handler/remove_centrifuge_beaker)
173+
174+
/decl/interaction_handler/remove_centrifuge_beaker
175+
name = "Remove Beaker"
176+
expected_target_type = /obj/machinery/centrifuge
177+
178+
/decl/interaction_handler/remove_centrifuge_beaker/invoked(atom/target, mob/user, obj/item/prop)
179+
var/obj/machinery/centrifuge/centrifuge = target
180+
if(centrifuge.loaded_beaker)
181+
centrifuge.loaded_beaker.dropInto(centrifuge.loc)
182+
user.put_in_hands(centrifuge.loaded_beaker)
183+
centrifuge.loaded_beaker = null

code/game/objects/items/__item.dm

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -472,27 +472,11 @@
472472
return ..() && (!strict || loc == user)
473473

474474
/obj/item/proc/squash_item(skip_qdel = FALSE)
475-
476475
if(!istype(material) || material.hardness > MAT_VALUE_MALLEABLE)
477476
return null
478-
479-
var/list/leftover_mats = list()
480-
for(var/mat in matter)
481-
var/decl/material/material_decl = GET_DECL(mat)
482-
if(material_decl.hardness <= MAT_VALUE_MALLEABLE)
483-
var/spawn_amount = round(matter[mat] / SHEET_MATERIAL_AMOUNT)
484-
if(spawn_amount > 0)
485-
var/obj/item/stack/material/lump/lump = new(loc, spawn_amount, mat)
486-
LAZYADD(., lump)
487-
continue
488-
leftover_mats[mat] = matter[mat]
489-
490-
if(length(leftover_mats))
491-
var/obj/item/debris/scraps/remains = new(loc)
492-
remains.matter = leftover_mats?.Copy()
493-
remains.update_primary_material()
494-
LAZYADD(., remains)
495-
477+
var/list/results = convert_matter_to_lumps(skip_qdel)
478+
if(length(results))
479+
. = results
496480
if(!skip_qdel)
497481
matter = null
498482
material = null
@@ -1319,3 +1303,34 @@ modules/mob/living/human/life.dm if you die, you will be zoomed out.
13191303
coating_string = FONT_COLORED(coating.get_color(), coating_string)
13201304
return coating_string
13211305
return ..()
1306+
1307+
// Bespoke proc for handling when a centrifuge smooshes us, only currently used by growns and hive frames.
1308+
/obj/item/proc/handle_centrifuge_process(obj/machinery/centrifuge/centrifuge)
1309+
SHOULD_CALL_PARENT(TRUE)
1310+
return istype(centrifuge) && !QDELETED(centrifuge.loaded_beaker) && istype(centrifuge.loaded_beaker)
1311+
1312+
/obj/item/proc/convert_matter_to_lumps(skip_qdel = FALSE)
1313+
1314+
var/list/scrap_matter = list()
1315+
for(var/mat in matter)
1316+
var/mat_amount = matter[mat]
1317+
var/obj/item/stack/material/mat_stack = /obj/item/stack/material/lump
1318+
var/mat_per_stack = SHEET_MATERIAL_AMOUNT * initial(mat_stack.matter_multiplier)
1319+
var/sheet_amount = round(mat_amount / mat_per_stack)
1320+
if(sheet_amount)
1321+
var/obj/item/stack/material/lump/lump = new(loc, sheet_amount, mat)
1322+
LAZYADD(., lump)
1323+
mat_amount -= sheet_amount * mat_per_stack
1324+
if(mat_amount)
1325+
scrap_matter[mat] += mat_amount
1326+
1327+
if(length(scrap_matter))
1328+
var/obj/item/debris/scraps/scraps = new(loc)
1329+
scraps.matter = scrap_matter.Copy()
1330+
scraps.update_primary_material()
1331+
LAZYADD(., scraps)
1332+
1333+
matter = null
1334+
material = null
1335+
if(!skip_qdel)
1336+
qdel(src)

code/game/objects/items/circuitboards/machinery/household.dm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@
4646
/obj/item/stock_parts/circuitboard/cooker/get_buildable_types()
4747
return subtypesof(/obj/machinery/cooker)
4848

49+
/obj/item/stock_parts/circuitboard/centrifuge
50+
name = "circuitboard (industrial centrifuge)"
51+
build_path = /obj/machinery/centrifuge
52+
board_type = "machine"
53+
origin_tech = @'{"biotech":2,"engineering":1}'
54+
req_components = list(
55+
/obj/item/stock_parts/manipulator = 2,
56+
/obj/item/stock_parts/matter_bin = 2
57+
)
58+
4959
/obj/item/stock_parts/circuitboard/seed_extractor
5060
name = "circuitboard (seed extractor)"
5161
build_path = /obj/machinery/seed_extractor

code/modules/fabrication/designs/imprinter/designs_misc_circuits.dm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@
344344
/datum/fabricator_recipe/imprinter/circuit/cooker
345345
path = /obj/item/stock_parts/circuitboard/cooker
346346

347+
/datum/fabricator_recipe/imprinter/circuit/centrifuge
348+
path = /obj/item/stock_parts/circuitboard/centrifuge
349+
347350
/datum/fabricator_recipe/imprinter/circuit/seed_extractor
348351
path = /obj/item/stock_parts/circuitboard/seed_extractor
349352

code/modules/hydroponics/grown.dm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@
1515
var/seeds_extracted = FALSE
1616
var/datum/seed/seed
1717

18+
// This is sort of pointless while food is a valid input on the ChemMaster but maybe
19+
// in the future there will be some more interesting ways to process growns/food.
20+
/obj/item/food/grown/handle_centrifuge_process(obj/machinery/centrifuge/centrifuge)
21+
if(!(. = ..()))
22+
return
23+
if(reagents?.total_volume)
24+
reagents.trans_to_holder(centrifuge.loaded_beaker.reagents, reagents.total_volume)
25+
for(var/obj/item/thing in contents)
26+
thing.dropInto(centrifuge.loc)
27+
for(var/atom/movable/thing in convert_matter_to_lumps())
28+
thing.dropInto(centrifuge.loc)
29+
1830
/obj/item/food/grown/get_examine_strings(mob/user, distance, infix, suffix)
1931
. = ..()
2032
if(user && distance <= 1 && seed && user.skill_check(work_skill, SKILL_BASIC))

code/modules/materials/definitions/liquids/materials_liquid_toxins.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
name = "spider venom"
6666
uid = "liquid_spider_venom"
6767
lore_text = "A deadly necrotic toxin produced by giant spiders to disable their prey."
68-
taste_description = "absolutely vile"
68+
taste_description = "vile poison"
6969
color = "#91d895"
7070
toxicity_targets_organ = BP_LIVER
7171
toxicity = 5

icons/obj/machines/centrifuge.dmi

715 Bytes
Binary file not shown.

maps/exodus/exodus-2.dmm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26489,7 +26489,7 @@
2648926489
pixel_x = -21;
2649026490
pixel_y = -10
2649126491
},
26492-
/obj/machinery/honey_extractor,
26492+
/obj/machinery/centrifuge/mapped,
2649326493
/turf/floor/tiled/steel_grid,
2649426494
/area/exodus/hydroponics/garden)
2649526495
"bev" = (

maps/ministation/ministation-1.dmm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6040,7 +6040,7 @@
60406040
"zj" = (
60416041
/obj/effect/floor_decal/corner/beige/half,
60426042
/obj/structure/table/glass,
6043-
/obj/machinery/honey_extractor,
6043+
/obj/machinery/centrifuge/mapped,
60446044
/turf/floor/tiled,
60456045
/area/ministation/hydro)
60466046
"zl" = (

maps/tradeship/tradeship-0.dmm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@
15621562
/turf/floor/tiled/steel_grid,
15631563
/area/ship/trade/loading_bay)
15641564
"yT" = (
1565-
/obj/machinery/honey_extractor,
1565+
/obj/machinery/centrifuge/mapped,
15661566
/obj/item/seeds/tomatoseed,
15671567
/turf/floor,
15681568
/area/ship/trade/aft_port_underside_maint)

0 commit comments

Comments
 (0)