Files
Paradise/code/game/objects/structures/table_frames.dm
warriorstar-orion 525c68d617 Attack chain, initial setup. (pull *immediately* for *any* TM issues) (#26834)
* refactor: Attack chain, initial setup.

* migrate curtain to make dreamchecker happy

* update thurible

* don't call attacked_by separately for legacy attack chain

* remove duplicate proc

* condense similar code, put allowances for legacy code in new procs

* update docs, include diagram source

* add comment on how to update diagram

* fix admonition

* mindflayer updates

* remove commented out code

* clarify all steps

* after_attack should be overridable

* whoops

* retrofit recent changes

* duh, can't restrict this yet because of tool_acts

* i hate ore bags with the fire of a thousand suns

* return correct value for object attack logic

* Various cleanups.

We don't want to attempt to pull stuff out of `/obj/item/attackby`,
because those pieces are part of the related objects' migrations, not
`/obj/item` itself. Attempting to do this causes knockon effects where
things expected to call e.g. `/obj/item/storage/attackby` in the call
chain were not ferried over to the new item interaction code, because
the related objects hadn't actually been migrated over yet.

I've used refactoring /obj/vehicle as the example for migrating
`attackby` methods instead.

* simplify some argument names

* fuck it

* make it do the thing

* Rename CI module call

* Prove that CI works

* improve test output

* aaand fix it again

* fix curtain tool interactions

* fix compile error

* fix compile error

* Better docs, introduce migration plan tool.
2024-12-02 23:36:36 +00:00

134 lines
4.6 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
max_integrity = 100
///The resource dropped when the table frame is destroyed or deconstructed
var/framestack = /obj/item/stack/rods
///How many of framestack resource are dropped
var/framestackamount = 2
///How long the table takes to make
var/construction_time = 5 SECONDS
///What stacks can be used to make the table, and if it will result in a unique table
var/list/restrict_table_types = list() //ex: list(/obj/item/stack/tile/carpet = /obj/structure/table/wood/poker, /obj/item/stack/sheet/wood = /obj/item/stack/sheet/wood::table_type), carpet will make poker table, wood will result in standard table_type. If the list is empty, any material can be used for its default table_type.
/obj/structure/table_frame/attackby__legacy__attackchain(obj/item/I, mob/user, params)
if(!try_make_table(I, user))
return ..()
///Try to make a table with the item used to attack. FALSE if you can't make a table and should attack. TRUE does not necessarily mean a table was made.
/obj/structure/table_frame/proc/try_make_table(obj/item/stack/stack, mob/user)
if(!istype(stack))
return FALSE
var/obj/structure/table/new_table_type = stack.table_type
if(length(restrict_table_types))
var/valid_stack_type = FALSE
for(var/obj/item/stack/current_stack as anything in restrict_table_types)
if(istype(stack, current_stack))
new_table_type = restrict_table_types[current_stack]
valid_stack_type = TRUE
break
if(!valid_stack_type)
return FALSE
if(!new_table_type)
return FALSE
if(stack.get_amount() < 1)
to_chat(user, "<span class='warning'>You need at least one sheet of [stack] to do this!</span>")
return TRUE
to_chat(user, "<span class='notice'>You start adding [stack] to [src]...</span>")
if(!do_after(user, construction_time, target = src))
return TRUE
if(!stack.use(1))
to_chat(user, "<span class='warning'>You need at least one sheet of [stack] to do this!</span>")
return TRUE
var/obj/structure/table/table_already_there = locate(/obj/structure/table) in get_turf(src)
if(table_already_there) //check again after to make sure one wasnt added since
to_chat(user, "<span class='warning'>There is already [table_already_there] here.</span>")
return TRUE
if(!istype(new_table_type, /obj/structure/table)) //if its something unique, skip the table parts
new new_table_type(loc)
qdel(src)
return TRUE
make_new_table(new_table_type)
return TRUE
/obj/structure/table_frame/wrench_act(mob/user, obj/item/I)
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
TOOL_ATTEMPT_DISMANTLE_MESSAGE
if(I.use_tool(src, user, 30, volume = I.tool_volume))
TOOL_DISMANTLE_SUCCESS_MESSAGE
for(var/i = 1, i <= framestackamount, i++)
new framestack(get_turf(src))
qdel(src)
/obj/structure/table_frame/proc/make_new_table(table_type) //makes sure the new table made retains what we had as a frame
var/obj/structure/table/T = new table_type(loc)
T.frame = type
T.framestack = framestack
T.framestackamount = framestackamount
qdel(src)
/obj/structure/table_frame/deconstruct(disassembled = TRUE)
new framestack(get_turf(src), framestackamount)
qdel(src)
/obj/structure/table_frame/narsie_act()
new /obj/structure/table_frame/wood(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/wood
framestackamount = 2
resistance_flags = FLAMMABLE
restrict_table_types = list(/obj/item/stack/tile/carpet = /obj/structure/table/wood/poker, /obj/item/stack/sheet/wood = /obj/item/stack/sheet/wood::table_type)
/obj/structure/table_frame/brass
name = "brass table frame"
desc = "Four pieces of brass arranged in a square. It's slightly warm to the touch."
icon_state = "brass_frame"
resistance_flags = FIRE_PROOF | ACID_PROOF
density = TRUE
anchored = TRUE
framestack = /obj/item/stack/tile/brass
framestackamount = 1
construction_time = 2 SECONDS
restrict_table_types = list(/obj/item/stack/tile/brass = /obj/item/stack/tile/brass::table_type)
/obj/structure/table_frame/brass/narsie_act()
..()
if(src) //do we still exist?
var/previouscolor = color
color = "#960000"
animate(src, color = previouscolor, time = 8)