From 1ac2fcb5ea74aebec7075393a26ab90a367635b8 Mon Sep 17 00:00:00 2001 From: MrPerson Date: Sun, 27 Nov 2016 22:01:00 -0800 Subject: [PATCH] Snack trash generation rework Quick and ugly but it's OO so fuck you. \>typecasting src smh Fixes #21583 --- .../food_and_drinks/food/customizables.dm | 3 +-- code/modules/food_and_drinks/food/snacks.dm | 27 ++++++++++--------- code/modules/hydroponics/grown.dm | 20 +++++++------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/code/modules/food_and_drinks/food/customizables.dm b/code/modules/food_and_drinks/food/customizables.dm index 4aab7b60a77..c55e1f3b371 100644 --- a/code/modules/food_and_drinks/food/customizables.dm +++ b/code/modules/food_and_drinks/food/customizables.dm @@ -48,8 +48,7 @@ if(!user.unEquip(I)) return if(S.trash) - new S.trash(get_turf(user)) - S.trash = null //we remove the plate before adding the ingredient + S.generate_trash(get_turf(user)) ingredients += S S.loc = src mix_filling_color(S) diff --git a/code/modules/food_and_drinks/food/snacks.dm b/code/modules/food_and_drinks/food/snacks.dm index 9ebb50e0698..ed992146b5e 100644 --- a/code/modules/food_and_drinks/food/snacks.dm +++ b/code/modules/food_and_drinks/food/snacks.dm @@ -25,19 +25,9 @@ return if(!reagents.total_volume) usr.unEquip(src) //so icons update :[ - - if(trash) - if(ispath(trash, /obj/item/weapon/grown) && istype(src, /obj/item/weapon/reagent_containers/food/snacks/grown)) - var/obj/item/weapon/reagent_containers/food/snacks/grown/G = src - var/obj/item/TrashItem = new trash(usr, G.seed) - usr.put_in_hands(TrashItem) - else if(ispath(trash,/obj/item)) - var/obj/item/TrashItem = new trash(usr) - usr.put_in_hands(TrashItem) - else if(istype(trash,/obj/item)) - usr.put_in_hands(trash) + var/obj/item/trash_item = generate_trash(usr) + usr.put_in_hands(trash_item) qdel(src) - return /obj/item/weapon/reagent_containers/food/snacks/attack_self(mob/user) @@ -209,6 +199,19 @@ reagents.trans_to(slice,reagents_per_slice) return +/obj/item/weapon/reagent_containers/food/snacks/proc/generate_trash(atom/location) + if(trash) + if(ispath(trash, /obj/item)) + . = new trash(location) + trash = null + return + else if(istype(trash, /obj/item)) + var/obj/item/trash_item = trash + trash_item.forceMove(location) + . = trash + trash = null + return + /obj/item/weapon/reagent_containers/food/snacks/proc/update_overlays(obj/item/weapon/reagent_containers/food/snacks/S) cut_overlays() var/image/I = new(src.icon, "[initial(icon_state)]_filling") diff --git a/code/modules/hydroponics/grown.dm b/code/modules/hydroponics/grown.dm index d486dec83ab..b377b71b228 100644 --- a/code/modules/hydroponics/grown.dm +++ b/code/modules/hydroponics/grown.dm @@ -106,10 +106,7 @@ new splat_type(T) if(trash) - if(ispath(trash, /obj/item/weapon/grown) || ispath(trash, /obj/item/weapon/reagent_containers/food/snacks/grown)) - new trash(T, seed) - else - new trash(T) + generate_trash(T) visible_message("[src] has been squashed.","You hear a smack.") if(seed) @@ -159,17 +156,18 @@ user.AddLuminosity(-G.get_lum(seed)) SetLuminosity(G.get_lum(seed)) - +/obj/item/weapon/reagent_containers/food/snacks/grown/generate_trash(atom/location) + if(trash && ispath(trash, /obj/item/weapon/grown)) + . = new trash(location, seed) + trash = null + return + return ..() // For item-containing growns such as eggy or gatfruit -/obj/item/weapon/reagent_containers/food/snacks/grown/shell/attack_self(mob/user as mob) +/obj/item/weapon/reagent_containers/food/snacks/grown/shell/attack_self(mob/user) user.unEquip(src) if(trash) - var/obj/item/weapon/T - if(ispath(trash, /obj/item/weapon/grown) || ispath(trash, /obj/item/weapon/reagent_containers/food/snacks/grown)) - T = new trash(user.loc, seed) - else - T = new trash(user.loc) + var/obj/item/T = generate_trash() user.put_in_hands(T) user << "You open [src]\'s shell, revealing \a [T]." qdel(src)