Skip to content

Commit

Permalink
Cleans up seed_extractor.dm and adds the ability to mass process
Browse files Browse the repository at this point in the history
container contents.
  • Loading branch information
doganesi committed May 26, 2024
1 parent 2521048 commit 1cab350
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 6 deletions.
42 changes: 36 additions & 6 deletions code/game/machinery/seed_extractor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,38 @@

/obj/structure/machinery/seed_extractor/attackby(obj/item/O as obj, mob/user as mob)

// Plant bag and other storage containers.
if(istype(O,/obj/item/storage))
var/obj/item/storage/container = O
if(length(container.contents) == 0)
to_chat(user, SPAN_NOTICE("[container] is empty."))
return

to_chat(user, SPAN_NOTICE("You start dumping the contents of [container] into [src]."))
if(!do_after(user, 1.5 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC))
return

for(var/obj/item/item as anything in container)
if(extract(item, user))
container.item_used(item)

playsound(user.loc, "rustle", 15, 1, 6)
else
extract(O, user)



/obj/structure/machinery/seed_extractor/proc/extract(obj/item/O as obj, mob/user as mob)
// Fruits and vegetables.
if(istype(O, /obj/item/reagent_container/food/snacks/grown) || istype(O, /obj/item/grown))
if(user.temp_drop_inv_item(O))
var/datum/seed/new_seed_type
if(istype(O, /obj/item/grown))
var/obj/item/grown/F = O
new_seed_type = GLOB.seed_types[F.plantname]
var/obj/item/grown/plant = O
new_seed_type = GLOB.seed_types[plant.plantname]
else
var/obj/item/reagent_container/food/snacks/grown/F = O
new_seed_type = GLOB.seed_types[F.plantname]
var/obj/item/reagent_container/food/snacks/grown/plant = O
new_seed_type = GLOB.seed_types[plant.plantname]

if(new_seed_type)
to_chat(user, SPAN_NOTICE("You extract some seeds from [O]."))
Expand All @@ -29,9 +51,17 @@
else
to_chat(user, "[O] doesn't seem to have any usable seeds inside it.")
qdel(O)
return TRUE
//Grass.
else if(istype(O, /obj/item/stack/tile/grass))
var/obj/item/stack/tile/grass/S = O
if (S.use(1))
var/obj/item/stack/tile/grass/grass = O
if (grass.use(1))
to_chat(user, SPAN_NOTICE("You extract some seeds from the grass tile."))
new /obj/item/seeds/grassseed(loc)
return TRUE
else
to_chat(user, SPAN_WARNING("Cannot get seeds from [O]."))
return FALSE



18 changes: 18 additions & 0 deletions code/game/objects/items/storage/storage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,24 @@ W is always an item. stop_warning prevents messaging. user may be null.**/
update_icon()
W.mouse_opacity = initial(W.mouse_opacity)

//Handle clean removal from storage when item is used up (vs dropped)
/obj/item/storage/proc/item_used(obj/item/W as obj)
for(var/mob/M in can_see_content())
if(M.client)
M.client.remove_from_screen(W)

W.moveToNullspace()

orient2hud()
for(var/mob/M in can_see_content())
show_to(M)
if(W.maptext && (storage_flags & STORAGE_CONTENT_NUM_DISPLAY))
W.maptext = ""
W.on_exit_storage(src)
update_icon()
W.mouse_opacity = initial(W.mouse_opacity)


//This proc is called when you want to place an item into the storage item.
/obj/item/storage/attackby(obj/item/W as obj, mob/user as mob)
..()
Expand Down

0 comments on commit 1cab350

Please sign in to comment.