Skip to content

Commit

Permalink
Add new rack & gun rack parts fix
Browse files Browse the repository at this point in the history
  • Loading branch information
skifsky committed Jul 30, 2024
1 parent e20712c commit 0e25646
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 6 deletions.
69 changes: 63 additions & 6 deletions modular_ss220/aesthetics/racks/code/racks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,76 @@
/obj/structure/rack/gunrack/deconstruct(disassembled = TRUE)
if(!(flags & NODECONSTRUCT))
density = FALSE
var/obj/item/gunrack_parts/newparts = new(loc)
var/obj/item/rack_parts/gunrack_parts/newparts = new(loc)
transfer_fingerprints_to(newparts)
for(var/obj/item/I in loc.contents)
if(istype(I, /obj/item/gun))
var/obj/item/gun/to_remove = I
to_remove.remove_from_rack()
qdel(src)

/obj/item/gunrack_parts
/obj/item/rack_parts/gunrack_parts
name = "gun rack parts"
desc = "Parts of a gun rack."
icon = 'icons/obj/items.dmi'
icon = 'modular_ss220/aesthetics/racks/icons/racks.dmi'
icon_state = "gunrack_parts"
flags = CONDUCT
materials = list(MAT_METAL=2000)
var/building = FALSE

/obj/item/rack_parts/gunrack_parts/attack_self(mob/user)
if(building)
return
building = TRUE
to_chat(user, "<span class='notice'>You start constructing a gun rack...</span>")
if(do_after(user, 50, target = user, progress=TRUE))
if(!user.drop_item(src))
return
var/obj/structure/rack/gunrack/R = new /obj/structure/rack/gunrack(user.loc)
user.visible_message("<span class='notice'>[user] assembles \a [R].\
</span>", "<span class='notice'>You assemble \a [R].</span>")
R.add_fingerprint(user)
qdel(src)
building = FALSE

/obj/structure/rack/shelving
name = "shelving"
desc = "A shelving for storing various goods"
icon_state = "shelving"

/obj/structure/rack/shelving/attackby(obj/item/W, mob/user, params)
. = ..()
if(W.loc == get_turf(src))
add_fingerprint(user)
var/list/click_params = params2list(params)
//Center the icon where the user clicked.
if(!click_params || !click_params["icon-x"] || !click_params["icon-y"])
return
//Clamp it so that the icon never moves more than 16 pixels in either direction (thus leaving the table turf)
W.pixel_x = clamp(text2num(click_params["icon-x"]) - 16, -(world.icon_size/2), world.icon_size/2)
W.pixel_y = clamp(text2num(click_params["icon-y"]) - 16, -(world.icon_size/2), world.icon_size/2)

/obj/structure/rack/shelving/deconstruct(disassembled = TRUE)
if(!(flags & NODECONSTRUCT))
density = FALSE
var/obj/item/rack_parts/shelving_parts/newparts = new(loc)
transfer_fingerprints_to(newparts)
qdel(src)

/obj/item/rack_parts/shelving_parts
name = "shelving parts"
desc = "Parts of a shelving"
icon = 'modular_ss220/aesthetics/racks/icons/racks.dmi'
icon_state = "shelving_parts"

/obj/item/rack_parts/shelving_parts/attack_self(mob/user)
if(building)
return
building = TRUE
to_chat(user, "<span class='notice'>You start constructing a shelving...</span>")
if(do_after(user, 50, target = user, progress=TRUE))
if(!user.drop_item(src))
return
var/obj/structure/rack/shelving/R = new /obj/structure/rack/shelving(user.loc)
user.visible_message("<span class='notice'>[user] assembles \a [R].\
</span>", "<span class='notice'>You assemble \a [R].</span>")
R.add_fingerprint(user)
qdel(src)
building = FALSE
Binary file modified modular_ss220/aesthetics/racks/icons/racks.dmi
Binary file not shown.

0 comments on commit 0e25646

Please sign in to comment.