Skip to content

Commit d2c63a3

Browse files
Adds an industrial centrifuge to replace the honey extractor.
1 parent 2f3cdd1 commit d2c63a3

File tree

12 files changed

+260
-84
lines changed

12 files changed

+260
-84
lines changed

code/game/machinery/centrifuge.dm

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

code/game/objects/items/__item.dm

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -472,27 +472,9 @@
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+
LAZYADD(., convert_matter_to_lumps(skip_qdel))
496478
if(!skip_qdel)
497479
matter = null
498480
material = null
@@ -1319,3 +1301,34 @@ modules/mob/living/human/life.dm if you die, you will be zoomed out.
13191301
coating_string = FONT_COLORED(coating.get_color(), coating_string)
13201302
return coating_string
13211303
return ..()
1304+
1305+
// Bespoke proc for handling when a centrifuge smooshes us, only currently used by growns and hive frames.
1306+
/obj/item/proc/handle_centrifuge_process(obj/machinery/centrifuge/centrifuge)
1307+
SHOULD_CALL_PARENT(TRUE)
1308+
return istype(centrifuge) && !QDELETED(centrifuge.loaded_beaker) && istype(centrifuge.loaded_beaker)
1309+
1310+
/obj/item/proc/convert_matter_to_lumps(skip_qdel = FALSE)
1311+
1312+
var/list/scrap_matter = list()
1313+
for(var/mat in matter)
1314+
var/mat_amount = matter[mat]
1315+
var/obj/item/stack/material/mat_stack = /obj/item/stack/material/lump
1316+
var/mat_per_stack = SHEET_MATERIAL_AMOUNT * initial(mat_stack.matter_multiplier)
1317+
var/sheet_amount = round(mat_amount / mat_per_stack)
1318+
if(sheet_amount)
1319+
var/obj/item/stack/material/lump/lump = new(loc, sheet_amount, mat)
1320+
LAZYADD(., lump)
1321+
mat_amount -= sheet_amount * mat_per_stack
1322+
if(mat_amount)
1323+
scrap_matter[mat] += mat_amount
1324+
1325+
if(length(scrap_matter))
1326+
var/obj/item/debris/scraps/scraps = new(loc)
1327+
scraps.matter = scrap_matter.Copy()
1328+
scraps.update_primary_material()
1329+
LAZYADD(., scraps)
1330+
1331+
matter = null
1332+
material = null
1333+
if(!skip_qdel)
1334+
qdel(src)

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,24 @@
4646
/obj/item/stock_parts/circuitboard/cooker/get_buildable_types()
4747
return subtypesof(/obj/machinery/cooker)
4848

49-
/obj/item/stock_parts/circuitboard/honey
50-
name = "circuitboard (honey extractor)"
51-
build_path = /obj/machinery/honey_extractor
49+
/obj/item/stock_parts/circuitboard/centrifuge
50+
name = "circuitboard (industrial centrifuge)"
51+
build_path = /obj/machinery/centrifuge
5252
board_type = "machine"
5353
origin_tech = @'{"biotech":2,"engineering":1}'
5454
req_components = list(
5555
/obj/item/stock_parts/manipulator = 2,
5656
/obj/item/stock_parts/matter_bin = 2)
5757

58-
/obj/item/stock_parts/circuitboard/honey/seed
58+
/obj/item/stock_parts/circuitboard/seed_extractor
5959
name = "circuitboard (seed extractor)"
6060
build_path = /obj/machinery/seed_extractor
6161
board_type = "machine"
62+
origin_tech = @'{"biotech":2,"engineering":1}'
63+
req_components = list(
64+
/obj/item/stock_parts/manipulator = 2,
65+
/obj/item/stock_parts/matter_bin = 2
66+
)
6267

6368
/obj/item/stock_parts/circuitboard/seed_storage
6469
name = "circuitboard (seed storage)"

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

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

347-
/datum/fabricator_recipe/imprinter/circuit/honey_extractor
348-
path = /obj/item/stock_parts/circuitboard/honey
347+
/datum/fabricator_recipe/imprinter/circuit/centrifuge
348+
path = /obj/item/stock_parts/circuitboard/centrifuge
349349

350350
/datum/fabricator_recipe/imprinter/circuit/seed_extractor
351-
path = /obj/item/stock_parts/circuitboard/honey/seed
351+
path = /obj/item/stock_parts/circuitboard/seed_extractor
352352

353353
/datum/fabricator_recipe/imprinter/circuit/vending
354354
path = /obj/item/stock_parts/circuitboard/vending

code/modules/hydroponics/beekeeping/beehive.dm

Lines changed: 10 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -165,60 +165,6 @@
165165
++trays
166166
honeycombs = min(honeycombs + 0.1 * coef * min(trays, 5), frames * 100)
167167

168-
/obj/machinery/honey_extractor
169-
name = "honey extractor"
170-
desc = "A machine used to extract honey and wax from a beehive frame."
171-
icon = 'icons/obj/virology.dmi'
172-
icon_state = "centrifuge"
173-
anchored = TRUE
174-
density = TRUE
175-
construct_state = /decl/machine_construction/default/panel_closed
176-
uncreated_component_parts = null
177-
stat_immune = 0
178-
179-
var/processing = 0
180-
var/honey = 0
181-
182-
/obj/machinery/honey_extractor/components_are_accessible(path)
183-
return !processing && ..()
184-
185-
/obj/machinery/honey_extractor/cannot_transition_to(state_path, mob/user)
186-
if(processing)
187-
return SPAN_NOTICE("You must wait for \the [src] to finish first!")
188-
return ..()
189-
190-
/obj/machinery/honey_extractor/attackby(var/obj/item/I, var/mob/user)
191-
if(processing)
192-
to_chat(user, "<span class='notice'>\The [src] is currently spinning, wait until it's finished.</span>")
193-
return TRUE
194-
if(istype(I, /obj/item/honey_frame))
195-
var/obj/item/honey_frame/H = I
196-
if(!H.honey)
197-
to_chat(user, "<span class='notice'>\The [H] is empty, put it into a beehive.</span>")
198-
return TRUE
199-
user.visible_message("<span class='notice'>\The [user] loads \the [H] into \the [src] and turns it on.</span>", "<span class='notice'>You load \the [H] into \the [src] and turn it on.</span>")
200-
processing = H.honey
201-
icon_state = "centrifuge_moving"
202-
qdel(H)
203-
spawn(50)
204-
new /obj/item/honey_frame(loc)
205-
new /obj/item/stack/material/bar/wax(loc, 1)
206-
honey += processing
207-
processing = 0
208-
icon_state = "centrifuge"
209-
return TRUE
210-
else if(istype(I, /obj/item/chems/glass))
211-
if(!honey)
212-
to_chat(user, "<span class='notice'>There is no honey in \the [src].</span>")
213-
return TRUE
214-
var/obj/item/chems/glass/G = I
215-
var/transferred = min(G.reagents.maximum_volume - G.reagents.total_volume, honey)
216-
G.add_to_reagents(/decl/material/liquid/nutriment/honey, transferred)
217-
honey -= transferred
218-
user.visible_message("<span class='notice'>\The [user] collects honey from \the [src] into \the [G].</span>", "<span class='notice'>You collect [transferred] units of honey from \the [src] into \the [G].</span>")
219-
return TRUE
220-
return ..() // smack it, interact with components, etc.
221-
222168
/obj/item/bee_smoker
223169
name = "bee smoker"
224170
desc = "A device used to calm down bees before harvesting honey."
@@ -236,6 +182,16 @@
236182
material = /decl/material/solid/organic/wood/oak
237183
var/honey = 0
238184

185+
// This is crap, will be replaced in beewrite PR.
186+
/obj/item/honey_frame/handle_centrifuge_process(obj/machinery/centrifuge/centrifuge)
187+
if(!(. = ..()) || !honey)
188+
return
189+
centrifuge?.loaded_beaker?.add_to_reagents(/decl/material/liquid/nutriment/honey, honey)
190+
honey = 0
191+
new /obj/item/honey_frame(centrifuge.loc)
192+
new /obj/item/stack/material/bar(centrifuge.loc, 1, /decl/material/solid/organic/wax)
193+
qdel(src)
194+
239195
/obj/item/honey_frame/filled
240196
name = "filled beehive frame"
241197
desc = "A frame for the beehive that the bees have filled with honeycombs."

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))

0 commit comments

Comments
 (0)