Skip to content

Commit 342aa7d

Browse files
Adds an industrial centrifuge to replace the honey extractor.
1 parent 67e6cac commit 342aa7d

File tree

12 files changed

+241
-65
lines changed

12 files changed

+241
-65
lines changed

code/game/machinery/centrifuge.dm

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

code/game/objects/items/__item.dm

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,3 +1320,34 @@ modules/mob/living/human/life.dm if you die, you will be zoomed out.
13201320
coating_string = FONT_COLORED(coating.get_color(), coating_string)
13211321
return coating_string
13221322
return ..()
1323+
1324+
// Bespoke proc for handling when a centrifuge smooshes us, only currently used by growns and hive frames.
1325+
/obj/item/proc/handle_centrifuge_process(obj/machinery/centrifuge/centrifuge)
1326+
SHOULD_CALL_PARENT(TRUE)
1327+
return istype(centrifuge) && !QDELETED(centrifuge.loaded_beaker) && istype(centrifuge.loaded_beaker)
1328+
1329+
/obj/item/proc/convert_matter_to_lumps(skip_qdel = FALSE)
1330+
1331+
var/list/scrap_matter = list()
1332+
for(var/mat in matter)
1333+
var/mat_amount = matter[mat]
1334+
var/obj/item/stack/material/mat_stack = /obj/item/stack/material/lump
1335+
var/mat_per_stack = SHEET_MATERIAL_AMOUNT * initial(mat_stack.matter_multiplier)
1336+
var/sheet_amount = round(mat_amount / mat_per_stack)
1337+
if(sheet_amount)
1338+
var/obj/item/stack/material/lump/lump = new(loc, sheet_amount, mat)
1339+
LAZYADD(., lump)
1340+
mat_amount -= sheet_amount * mat_per_stack
1341+
if(mat_amount)
1342+
scrap_matter[mat] += mat_amount
1343+
1344+
if(length(scrap_matter))
1345+
var/obj/item/debris/scraps/scraps = new(loc)
1346+
scraps.matter = scrap_matter.Copy()
1347+
scraps.update_primary_material()
1348+
LAZYADD(., scraps)
1349+
1350+
matter = null
1351+
material = null
1352+
if(!skip_qdel)
1353+
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/examine(mob/user, distance)
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" = (

0 commit comments

Comments
 (0)