Skip to content

Commit

Permalink
Bee and insect swarm rework (beewrite).
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Jul 30, 2024
1 parent 5990ca9 commit 53feb86
Show file tree
Hide file tree
Showing 37 changed files with 1,086 additions and 331 deletions.
169 changes: 169 additions & 0 deletions code/game/machinery/centrifuge.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
/datum/storage/hopper/industrial/centrifuge
can_hold = list(/obj/item/chems/food) // also handles hive frames; see insects modpack.
expected_type = /obj/machinery/centrifuge

/datum/storage/hopper/industrial/centrifuge/can_be_inserted(obj/item/W, mob/user, stop_messages)
. = ..()
if(. && !W.reagents?.total_volume)
if(user)
to_chat(user, SPAN_WARNING("\The [W] is empty."))
return FALSE

/obj/machinery/centrifuge
name = "industrial centrifuge"
desc = "A machine used to extract reagents and materials from objects via spinning them at extreme speed."
icon = 'icons/obj/machines/centrifuge.dmi'
icon_state = ICON_STATE_WORLD
anchored = TRUE
density = TRUE
construct_state = /decl/machine_construction/default/panel_closed
uncreated_component_parts = null
storage = /datum/storage/hopper/industrial/centrifuge
base_type = /obj/machinery/centrifuge
stat_immune = 0

// Reference to our reagent container. Set to a path to create on init.
var/obj/item/loaded_beaker

// Stolen from fabricators.
var/sound_id
var/datum/sound_token/sound_token
var/work_sound = 'sound/machines/fabricator_loop.ogg'

/obj/machinery/centrifuge/mapped
loaded_beaker = /obj/item/chems/glass/beaker/large

/obj/machinery/centrifuge/Initialize()
. = ..()
if(ispath(loaded_beaker))
loaded_beaker = new loaded_beaker

/obj/machinery/centrifuge/Destroy()
QDEL_NULL(loaded_beaker)
return ..()

/obj/machinery/centrifuge/dismantle()
if(loaded_beaker)
loaded_beaker.dropInto(loc)
loaded_beaker = null
return ..()

/obj/machinery/centrifuge/components_are_accessible(path)
return use_power != POWER_USE_ACTIVE && ..()

/obj/machinery/centrifuge/cannot_transition_to(state_path, mob/user)
if(use_power == POWER_USE_ACTIVE)
return SPAN_NOTICE("You must wait for \the [src] to finish first!")
return ..()

/obj/machinery/centrifuge/attackby(obj/item/used_item, mob/user)

if(use_power == POWER_USE_ACTIVE)
to_chat(user, SPAN_NOTICE("\The [src] is currently spinning, wait until it's finished."))
return TRUE

if((. = component_attackby(used_item, user)))
return

// Load in a new container for products.
if(istype(used_item, /obj/item/chems/glass/beaker))
if(loaded_beaker)
to_chat(user, SPAN_WARNING("\The [src] already has a beaker loaded."))
return TRUE
if(user.try_unequip(used_item, src))
loaded_beaker = used_item
to_chat(user, SPAN_NOTICE("You load \the [loaded_beaker] into \the [src]."))
return TRUE

// Parent call handles inserting the frame into our contents,
return ..()

/obj/machinery/centrifuge/attack_hand(mob/user)

if(use_power == POWER_USE_ACTIVE)
user.visible_message("\The [user] disengages \the [src].")
update_use_power(POWER_USE_IDLE)
return TRUE

if(use_power == POWER_USE_IDLE)
if(!loaded_beaker || QDELETED(loaded_beaker))
to_chat(user, SPAN_WARNING("\The [src] has no beaker loaded to receive any products."))
loaded_beaker = null // just in case
return TRUE

if(length(get_stored_inventory()))
user.visible_message("\The [user] engages \the [src].")
update_use_power(POWER_USE_ACTIVE)
else
to_chat(user, SPAN_WARNING("\The [src]'s hopper is empty."))
return TRUE

if(use_power == POWER_USE_OFF || !operable())
to_chat(user, SPAN_WARNING("\The [src]'s interface is unresponsive."))
return TRUE

return ..()

/obj/machinery/centrifuge/Process(wait, tick)
..()

if(use_power != POWER_USE_ACTIVE)
return

if(!loaded_beaker)
visible_message("\The [src] stops spinning and flashes a red light.")
update_use_power(POWER_USE_IDLE)
return

var/list/processing_items = get_stored_inventory()
if(!length(processing_items))
visible_message("\The [src] stops spinning and flashes a green light.")
update_use_power(POWER_USE_IDLE)
return

var/obj/item/thing = processing_items[1]
thing.handle_centrifuge_process(src)
if(!QDELETED(thing) && loc)
thing.dropInto(loc)

/obj/machinery/recycler/Initialize()
sound_id = "[work_sound]"
return ..()

/obj/machinery/recycler/Destroy()
QDEL_NULL(sound_token)
return ..()

/obj/machinery/recycler/update_use_power()
. = ..()
if(use_power == POWER_USE_ACTIVE)
if(!sound_token)
sound_token = play_looping_sound(src, sound_id, work_sound, volume = 30)
else
dump_trace_material()
QDEL_NULL(sound_token)

/obj/machinery/centrifuge/on_update_icon()
icon_state = initial(icon_state)
if(stat & BROKEN)
icon_state = "[icon_state]-broken"
else if(use_power == POWER_USE_OFF || !operable())
icon_state = "[icon_state]-off"
else if(use_power == POWER_USE_ACTIVE)
icon_state = "[icon_state]-working"

/obj/machinery/centrifuge/get_alt_interactions(var/mob/user)
. = ..()
if(loaded_beaker)
LAZYADD(., list(/decl/interaction_handler/remove_centrifuge_beaker))

/decl/interaction_handler/remove_centrifuge_beaker
name = "Remove Beaker"
expected_target_type = /obj/machinery/centrifuge

/decl/interaction_handler/remove_centrifuge_beaker/invoked(atom/target, mob/user, obj/item/prop)
var/obj/machinery/centrifuge/centrifuge = target
if(centrifuge.loaded_beaker)
centrifuge.loaded_beaker.dropInto(centrifuge.loc)
user.put_in_hands(centrifuge.loaded_beaker)
centrifuge.loaded_beaker = null
31 changes: 31 additions & 0 deletions code/game/objects/items/__item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1150,3 +1150,34 @@ modules/mob/living/human/life.dm if you die, you will be zoomed out.

/obj/item/proc/get_equipment_tint()
return TINT_NONE

// Bespoke proc for handling when a centrifuge smooshes us, only currently used by growns and hive frames.
/obj/item/proc/handle_centrifuge_process(obj/machinery/centrifuge/centrifuge)
SHOULD_CALL_PARENT(TRUE)
return istype(centrifuge) && !QDELETED(centrifuge.loaded_beaker) && istype(centrifuge.loaded_beaker)

/obj/item/proc/convert_matter_to_lumps(skip_qdel = FALSE)

var/list/scrap_matter = list()
for(var/mat in matter)
var/mat_amount = matter[mat]
var/obj/item/stack/material/mat_stack = /obj/item/stack/material/lump
var/mat_per_stack = SHEET_MATERIAL_AMOUNT * initial(mat_stack.matter_multiplier)
var/sheet_amount = round(mat_amount / mat_per_stack)
if(sheet_amount)
var/obj/item/stack/material/lump/lump = new(loc, sheet_amount, mat)
LAZYADD(., lump)
mat_amount -= sheet_amount * mat_per_stack
if(mat_amount)
scrap_matter[mat] += mat_amount

if(length(scrap_matter))
var/obj/item/debris/scraps/scraps = new(loc)
scraps.matter = scrap_matter.Copy()
scraps.update_primary_material()
LAZYADD(., scraps)

matter = null
material = null
if(!skip_qdel)
qdel(src)
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
/obj/item/stock_parts/console_screen = 1,
/obj/item/stock_parts/keyboard = 1,
/obj/item/stock_parts/power/apc/buildable = 1
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@
/obj/item/stock_parts/circuitboard/cooker/get_buildable_types()
return subtypesof(/obj/machinery/cooker)

/obj/item/stock_parts/circuitboard/centrifuge
name = "circuitboard (industrial centrifuge)"
build_path = /obj/machinery/centrifuge
board_type = "machine"
origin_tech = @'{"biotech":2,"engineering":1}'
req_components = list(
/obj/item/stock_parts/manipulator = 2,
/obj/item/stock_parts/matter_bin = 2)

/obj/item/stock_parts/circuitboard/seed_extractor
name = "circuitboard (seed extractor)"
build_path = /obj/machinery/seed_extractor
board_type = "machine"
origin_tech = @'{"biotech":2,"engineering":1}'
req_components = list(
/obj/item/stock_parts/manipulator = 2,
/obj/item/stock_parts/matter_bin = 2
)

/obj/item/stock_parts/circuitboard/seed_storage
name = "circuitboard (seed storage)"
build_path = /obj/machinery/seed_storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
path = /obj/item/stock_parts/circuitboard/cooker

/datum/fabricator_recipe/imprinter/circuit/seed_extractor
path = /obj/item/stock_parts/circuitboard/seed
path = /obj/item/stock_parts/circuitboard/seed_extractor

/datum/fabricator_recipe/imprinter/circuit/vending
path = /obj/item/stock_parts/circuitboard/vending
Expand Down Expand Up @@ -496,3 +496,6 @@

/datum/fabricator_recipe/imprinter/circuit/central_atmos
path = /obj/item/stock_parts/circuitboard/central_atmos

/datum/fabricator_recipe/imprinter/circuit/centrifuge
path = /obj/item/stock_parts/circuitboard/centrifuge
12 changes: 12 additions & 0 deletions code/modules/hydroponics/grown.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
var/seeds_extracted = FALSE
var/datum/seed/seed

// This is sort of pointless while food is a valid input on the ChemMaster but maybe
// in the future there will be some more interesting ways to process growns/food.
/obj/item/chems/food/grown/handle_centrifuge_process(obj/machinery/centrifuge/centrifuge)
if(!(. = ..()))
return
if(reagents.total_volume)
reagents.trans_to_holder(centrifuge.loaded_beaker.reagents, reagents.total_volume)
for(var/obj/item/thing in contents)
thing.dropInto(centrifuge.loc)
for(var/atom/movable/thing in convert_matter_to_lumps())
thing.dropInto(centrifuge.loc)

/obj/item/chems/food/grown/examine(mob/user, distance)
. = ..()
if(user && distance <= 1 && seed && user.skill_check(work_skill, SKILL_BASIC))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
name = "spider venom"
uid = "liquid_spider_venom"
lore_text = "A deadly necrotic toxin produced by giant spiders to disable their prey."
taste_description = "absolutely vile"
taste_description = "vile poison"
color = "#91d895"
toxicity_targets_organ = BP_LIVER
toxicity = 5
Expand Down
Binary file removed icons/obj/apiary_bees_etc.dmi
Binary file not shown.
Binary file removed icons/obj/beekeeping.dmi
Binary file not shown.
Binary file added icons/obj/machines/centrifuge.dmi
Binary file not shown.
Binary file modified icons/obj/virology.dmi
Binary file not shown.
1 change: 1 addition & 0 deletions maps/away/unishi/unishi.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "unishi_areas.dm"
#include "unishi_jobs.dm"
#include "../../../mods/content/xenobiology/_xenobiology.dme"
#include "../../../mods/content/insects/_insects.dme"

/obj/abstract/submap_landmark/joinable_submap/unishi
name = "SRV Verne"
Expand Down
2 changes: 1 addition & 1 deletion maps/exodus/exodus-2.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -26481,7 +26481,7 @@
pixel_x = -21;
pixel_y = -10
},
/obj/machinery/honey_extractor,
/obj/machinery/centrifuge/mapped,
/turf/floor/tiled/steel_grid,
/area/exodus/hydroponics/garden)
"bev" = (
Expand Down
10 changes: 5 additions & 5 deletions maps/ministation/ministation-1.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -5727,9 +5727,9 @@
/obj/item/tool/hoe/mini,
/obj/item/tool/spade,
/obj/item/tool/spade,
/obj/item/honey_frame,
/obj/item/honey_frame,
/obj/item/honey_frame,
/obj/item/hive_frame/crafted,
/obj/item/hive_frame/crafted,
/obj/item/hive_frame/crafted,
/turf/floor/tiled,
/area/ministation/hydro)
"yg" = (
Expand Down Expand Up @@ -6051,7 +6051,7 @@
"zj" = (
/obj/effect/floor_decal/corner/beige/half,
/obj/structure/table/glass,
/obj/machinery/honey_extractor,
/obj/machinery/centrifuge/mapped,
/turf/floor/tiled,
/area/ministation/hydro)
"zl" = (
Expand Down Expand Up @@ -8759,7 +8759,7 @@
/turf/floor/tiled,
/area/ministation/hall/e2)
"Oo" = (
/obj/machinery/beehive,
/obj/structure/apiary/mapped,
/turf/floor/fake_grass,
/area/ministation/hydro)
"Op" = (
Expand Down
2 changes: 1 addition & 1 deletion maps/tradeship/tradeship-0.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,7 @@
/turf/floor/tiled/steel_grid,
/area/ship/trade/loading_bay)
"yT" = (
/obj/machinery/honey_extractor,
/obj/machinery/centrifuge/mapped,
/obj/item/seeds/tomatoseed,
/turf/floor,
/area/ship/trade/aft_port_underside_maint)
Expand Down
7 changes: 0 additions & 7 deletions mods/content/insects/_insects.dm
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
/datum/extension/insect_hive


/decl/insect_species

/decl/insect_species/bees

8 changes: 7 additions & 1 deletion mods/content/insects/_insects.dme
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
#include "centrifuge.dm"
#include "closets.dm"
#include "items.dm"
#include "materials.dm"
#include "recipes.dm"
#include "trading.dm"
#include "hives/_hive.dm"
#include "hives\_hive.dm"
#include "hives\hive_frame.dm"
#include "hives\hive_insects.dm"
#include "hives\hive_queen.dm"
#include "hives\hive_structure.dm"
#include "hives\hive_swarm.dm"
// END_INCLUDE
#endif
Loading

0 comments on commit 53feb86

Please sign in to comment.