mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-25 08:34:23 +00:00
This PR fixes a case where certain materials caused issues when working with stacking machines, because they did not have set merge_type from the get go, which meant that initial() of that variable returned null. To clarify further - if /obj/item/stack does not have set merge_type, it is generated merge_type upon Initialize(), which is the same as its typepath. For example, currently /obj/item/stack/sheet/bluespace_crystal does not have any merge_type set, and it is given merge_type = /obj/item/stack/sheet/bluespace_crystal upon Initialize(). Each Initialize(). Again and again. There are quite a bit of these cases in the codebase, especially if its some older code. I have gone through them and set all of them their set merge_type, which they would inevitably receive anyway upon initializing and it fixes a bug mentioned above. To prevent this happening again, I have also included unit test to check if merge types are set for stacks, included exceptions are usually abstract paths like /obj/item/stack/sheet/mineral, which contains zero behavior on its own and does not spawn unless done via admin tools.
145 lines
4.0 KiB
Plaintext
145 lines
4.0 KiB
Plaintext
|
|
|
|
/*
|
|
* Wrapping Paper
|
|
*/
|
|
|
|
/obj/item/stack/wrapping_paper
|
|
name = "wrapping paper"
|
|
desc = "Wrap packages with this festive paper to make gifts."
|
|
icon = 'icons/obj/stack_objects.dmi'
|
|
icon_state = "wrap_paper"
|
|
item_flags = NOBLUDGEON
|
|
amount = 25
|
|
max_amount = 25
|
|
resistance_flags = FLAMMABLE
|
|
merge_type = /obj/item/stack/wrapping_paper
|
|
|
|
/obj/item/stack/wrapping_paper/use(used, transfer)
|
|
var/turf/T = get_turf(src)
|
|
. = ..()
|
|
if(QDELETED(src) && !transfer)
|
|
new /obj/item/c_tube(T)
|
|
|
|
/obj/item/stack/wrapping_paper/small
|
|
desc = "Wrap packages with this festive paper to make gifts. This roll looks a bit skimpy."
|
|
amount = 10
|
|
merge_type = /obj/item/stack/wrapping_paper/small
|
|
|
|
/*
|
|
* Package Wrap
|
|
*/
|
|
|
|
/obj/item/stack/package_wrap
|
|
name = "package wrapper"
|
|
singular_name = "wrapping sheet"
|
|
desc = "You can use this to wrap items in."
|
|
icon = 'icons/obj/stack_objects.dmi'
|
|
icon_state = "deliveryPaper"
|
|
item_flags = NOBLUDGEON
|
|
amount = 25
|
|
max_amount = 25
|
|
resistance_flags = FLAMMABLE
|
|
grind_results = list(/datum/reagent/cellulose = 5)
|
|
merge_type = /obj/item/stack/package_wrap
|
|
|
|
/obj/item/stack/package_wrap/suicide_act(mob/living/user)
|
|
user.visible_message("<span class='suicide'>[user] begins wrapping [user.p_them()]self in \the [src]! It looks like [user.p_theyre()] trying to commit suicide!</span>")
|
|
if(use(3))
|
|
var/obj/structure/big_delivery/P = new /obj/structure/big_delivery(get_turf(user.loc))
|
|
P.icon_state = "deliverypackage5"
|
|
user.forceMove(P)
|
|
P.add_fingerprint(user)
|
|
return OXYLOSS
|
|
else
|
|
to_chat(user, "<span class='warning'>You need more paper!</span>")
|
|
return SHAME
|
|
|
|
/obj/item/proc/can_be_package_wrapped() //can the item be wrapped with package wrapper into a delivery package
|
|
return TRUE
|
|
|
|
/obj/item/storage/can_be_package_wrapped()
|
|
return FALSE
|
|
|
|
/obj/item/storage/box/can_be_package_wrapped()
|
|
return TRUE
|
|
|
|
/obj/item/small_delivery/can_be_package_wrapped()
|
|
return FALSE
|
|
|
|
/obj/item/stack/package_wrap/afterattack(obj/target, mob/user, proximity)
|
|
. = ..()
|
|
if(!proximity)
|
|
return
|
|
if(!istype(target))
|
|
return
|
|
if(target.anchored)
|
|
return
|
|
|
|
if(isitem(target))
|
|
var/obj/item/I = target
|
|
if(!I.can_be_package_wrapped())
|
|
return
|
|
if(user.is_holding(I))
|
|
if(!user.dropItemToGround(I))
|
|
return
|
|
else if(!isturf(I.loc))
|
|
return
|
|
if(use(1))
|
|
var/obj/item/small_delivery/P = new /obj/item/small_delivery(get_turf(I.loc))
|
|
if(user.Adjacent(I))
|
|
P.add_fingerprint(user)
|
|
I.add_fingerprint(user)
|
|
user.put_in_hands(P)
|
|
I.forceMove(P)
|
|
var/size = round(I.w_class)
|
|
P.name = "[weightclass2text(size)] parcel"
|
|
P.w_class = size
|
|
size = min(size, 5)
|
|
P.icon_state = "deliverypackage[size]"
|
|
|
|
else if(istype (target, /obj/structure/closet))
|
|
var/obj/structure/closet/O = target
|
|
if(O.opened)
|
|
return
|
|
if(!O.delivery_icon) //no delivery icon means unwrappable closet (e.g. body bags)
|
|
to_chat(user, "<span class='warning'>You can't wrap this!</span>")
|
|
return
|
|
if(use(3))
|
|
var/obj/structure/big_delivery/P = new /obj/structure/big_delivery(get_turf(O.loc))
|
|
P.icon_state = O.delivery_icon
|
|
O.forceMove(P)
|
|
P.add_fingerprint(user)
|
|
O.add_fingerprint(user)
|
|
else
|
|
to_chat(user, "<span class='warning'>You need more paper!</span>")
|
|
return
|
|
else
|
|
to_chat(user, "<span class='warning'>The object you are trying to wrap is unsuitable for the sorting machinery!</span>")
|
|
return
|
|
|
|
user.visible_message("<span class='notice'>[user] wraps [target].</span>")
|
|
user.log_message("has used [name] on [key_name(target)]", LOG_ATTACK, color="blue")
|
|
|
|
/obj/item/stack/package_wrap/use(used, transfer = FALSE)
|
|
var/turf/T = get_turf(src)
|
|
. = ..()
|
|
if(QDELETED(src) && !transfer)
|
|
new /obj/item/c_tube(T)
|
|
|
|
/obj/item/stack/package_wrap/small
|
|
desc = "You can use this to wrap items in. This roll looks a bit skimpy."
|
|
w_class = WEIGHT_CLASS_SMALL
|
|
amount = 5
|
|
merge_type = /obj/item/stack/package_wrap/small
|
|
|
|
/obj/item/c_tube
|
|
name = "cardboard tube"
|
|
desc = "A tube... of cardboard."
|
|
icon = 'icons/obj/stack_objects.dmi'
|
|
icon_state = "c_tube"
|
|
throwforce = 0
|
|
w_class = WEIGHT_CLASS_TINY
|
|
throw_speed = 3
|
|
throw_range = 5
|