mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-06-23 15:14:43 +01:00
0b0c5ea91e
## About The Pull Request Extends the part of the crafting unit test that ensures consistency between the total mats of the components of a recipe (or rather, the result of said recipe) and a generic instance of the same type as its result, previously only implemented on food recipes. ## Why It's Good For The Game This ensures a degree of consistency with the material composition of various objects in the game. I couldn't do it in the original PR as that one was too big already and it took months to get it merged, and have the relative bugs fixed. Currently a WIP as I slowly deal with the unit test reports. ## Changelog 🆑 refactor: Follow-up to the crafting/material refactor from months ago. All objects crafted with stacks now inherit their mat composition (not necessarily the effects and color) by default, while previously only a few things like chair, sinks and toilets did. Report any object looking or behaving weirdly as a result. fix: The material composition of ammo boxes is no longer a 1/10 of what it's supposed to be. It was a shitty hack to make it harder to recycle empty ammo boxes. Instead, they lose materials as they're emptied now. /🆑
108 lines
3.2 KiB
Plaintext
108 lines
3.2 KiB
Plaintext
/* Table Frames
|
|
* Contains:
|
|
* Frames
|
|
* Wooden Frames
|
|
*/
|
|
|
|
|
|
/*
|
|
* Normal Frames
|
|
*/
|
|
|
|
/obj/structure/table_frame
|
|
name = "table frame"
|
|
desc = "Four metal legs with four framing rods for a table. You could easily pass through this."
|
|
icon = 'icons/obj/structures.dmi'
|
|
icon_state = "table_frame"
|
|
density = FALSE
|
|
anchored = FALSE
|
|
layer = PROJECTILE_HIT_THRESHHOLD_LAYER
|
|
custom_materials = list(/datum/material/iron = SHEET_MATERIAL_AMOUNT)
|
|
max_integrity = 100
|
|
var/framestack = /obj/item/stack/rods
|
|
var/framestackamount = 2
|
|
|
|
/obj/structure/table_frame/Initialize(mapload)
|
|
. = ..()
|
|
register_context()
|
|
|
|
/obj/structure/table_frame/add_context(atom/source, list/context, obj/item/held_item, mob/living/user)
|
|
if(isnull(held_item))
|
|
return NONE
|
|
|
|
if(held_item.tool_behaviour == TOOL_WRENCH)
|
|
context[SCREENTIP_CONTEXT_LMB] = "Deconstruct"
|
|
context[SCREENTIP_CONTEXT_RMB] = "Deconstruct"
|
|
return CONTEXTUAL_SCREENTIP_SET
|
|
|
|
if(isstack(held_item) && get_table_type(held_item))
|
|
context[SCREENTIP_CONTEXT_LMB] = "Construct table"
|
|
return CONTEXTUAL_SCREENTIP_SET
|
|
|
|
/obj/structure/table_frame/wrench_act(mob/living/user, obj/item/tool)
|
|
balloon_alert(user, "deconstructing...")
|
|
tool.play_tool_sound(src)
|
|
if(!tool.use_tool(src, user, 3 SECONDS))
|
|
return ITEM_INTERACT_BLOCKING
|
|
playsound(loc, 'sound/items/deconstruct.ogg', 50, TRUE)
|
|
deconstruct(TRUE)
|
|
return ITEM_INTERACT_SUCCESS
|
|
|
|
/obj/structure/table_frame/wrench_act_secondary(mob/living/user, obj/item/tool)
|
|
return wrench_act(user, tool)
|
|
|
|
/obj/structure/table_frame/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
|
|
if(!isstack(tool))
|
|
return NONE
|
|
var/obj/item/stack/our_stack = tool
|
|
var/table_type = get_table_type(our_stack)
|
|
if(isnull(table_type))
|
|
return NONE
|
|
|
|
if(our_stack.get_amount() < 1)
|
|
balloon_alert(user, "need more material!")
|
|
return ITEM_INTERACT_BLOCKING
|
|
if(locate(/obj/structure/table) in loc)
|
|
balloon_alert(user, "can't stack tables!")
|
|
return ITEM_INTERACT_BLOCKING
|
|
|
|
balloon_alert(user, "constructing table...")
|
|
if(!do_after(user, 2 SECONDS, target = src))
|
|
return ITEM_INTERACT_BLOCKING
|
|
if((locate(/obj/structure/table) in loc) || !our_stack.use(1))
|
|
return ITEM_INTERACT_BLOCKING
|
|
|
|
new table_type(loc, src, our_stack)
|
|
qdel(src)
|
|
return ITEM_INTERACT_SUCCESS
|
|
|
|
/// Gets the table type we make with our given stack.
|
|
/obj/structure/table_frame/proc/get_table_type(obj/item/stack/our_stack)
|
|
return our_stack.get_table_type()
|
|
|
|
/obj/structure/table_frame/atom_deconstruct(disassembled = TRUE)
|
|
new framestack(get_turf(src), framestackamount)
|
|
|
|
/obj/structure/table_frame/narsie_act()
|
|
new /obj/structure/table_frame/wood(src.loc)
|
|
qdel(src)
|
|
|
|
/*
|
|
* Wooden Frames
|
|
*/
|
|
|
|
/obj/structure/table_frame/wood
|
|
name = "wooden table frame"
|
|
desc = "Four wooden legs with four framing wooden rods for a wooden table. You could easily pass through this."
|
|
icon_state = "wood_frame"
|
|
framestack = /obj/item/stack/sheet/mineral/wood
|
|
framestackamount = 2
|
|
resistance_flags = FLAMMABLE
|
|
custom_materials = list(/datum/material/wood = SHEET_MATERIAL_AMOUNT * 2)
|
|
|
|
/obj/structure/table_frame/wood/get_table_type(obj/item/stack/our_stack)
|
|
if(istype(our_stack, /obj/item/stack/sheet/mineral/wood))
|
|
return /obj/structure/table/wood
|
|
if(istype(our_stack, /obj/item/stack/tile/carpet))
|
|
return /obj/structure/table/wood/poker
|