Skip to content

Commit

Permalink
Port benches from Polaris
Browse files Browse the repository at this point in the history
Fix table stepping check

Fix placing items on tables
  • Loading branch information
out-of-phaze authored and comma committed Sep 14, 2023
1 parent dc7ab5b commit f7e49c5
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
50 changes: 50 additions & 0 deletions code/game/objects/structures/benches.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/obj/structure/table/bench
name = "bench frame"
icon = 'icons/obj/bench.dmi'
icon_state = "solid_preview"
desc = "It's a bench, for putting things on. Or standing on, if you really want to."
top_surface_noun = "seat"
can_flip = FALSE
can_place_items = FALSE
density = FALSE
mob_offset = 0

/obj/structure/table/bench/reinforce_table()
return FALSE

/obj/structure/table/bench/update_material_name(override_name)
if(reinf_material)
name = "[reinf_material.solid_name] bench"
else if(material)
name = "[material.solid_name] bench frame"
else
name = "bench frame"

/obj/structure/table/bench/CanPass(atom/movable/mover)
return TRUE

/obj/structure/table/bench/frame
icon_state = "frame"
reinf_material = null

/obj/structure/table/bench/steel
icon_state = "solid_preview"
color = COLOR_GRAY40
reinf_material = /decl/material/solid/metal/steel

/obj/structure/table/bench/wooden
icon_state = "solid_preview"
color = WOOD_COLOR_GENERIC
material = /decl/material/solid/wood
reinf_material = /decl/material/solid/wood

/obj/structure/table/bench/padded
icon_state = "padded_preview"
material = /decl/material/solid/metal/steel
reinf_material = /decl/material/solid/metal/steel
felted = TRUE

/obj/structure/table/bench/glass
color = COLOR_DEEP_SKY_BLUE
alpha = 77
reinf_material = /decl/material/solid/glass
11 changes: 9 additions & 2 deletions code/game/objects/structures/tables.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
atom_flags = ATOM_FLAG_NO_TEMP_CHANGE | ATOM_FLAG_CLIMBABLE
layer = TABLE_LAYER
throwpass = TRUE
// Note that mob_offset also determines whether you can walk from one table to another without climbing.
// TODO: add 1px step-up?
mob_offset = 12
handle_generic_blending = TRUE
maxhealth = 10
Expand All @@ -30,6 +32,9 @@
var/felted = 0
var/list/connections

/// Whether items can be placed on this table via clicking.
var/can_place_items = TRUE

/obj/structure/table/clear_connections()
connections = null

Expand Down Expand Up @@ -200,7 +205,7 @@
. = ..()

// Finally we can put the object onto the table.
if(!. && !isrobot(user) && W.loc == user && user.try_unequip(W, src.loc))
if(!. && can_place_items && !isrobot(user) && W.loc == user && user.try_unequip(W, src.loc))
auto_align(W, click_params)
return TRUE

Expand Down Expand Up @@ -353,6 +358,8 @@
return FALSE
if(istype(additional_reinf_material) && (!istype(other.additional_reinf_material) || additional_reinf_material.type != other.additional_reinf_material.type))
return FALSE
if(mob_offset != other.mob_offset)
return FALSE
return TRUE

// set propagate if you're updating a table that should update tables around it too, for example if it's a new table or something important has changed (like material).
Expand Down Expand Up @@ -419,7 +426,7 @@
if(istype(mover) && mover.checkpass(PASS_FLAG_TABLE))
return 1
var/obj/structure/table/T = (locate() in get_turf(mover))
return (T && !T.is_flipped)
return T && !T.is_flipped && (mob_offset <= T.mob_offset)

//checks if projectile 'P' from turf 'from' can hit whatever is behind the table. Returns 1 if it can, 0 if bullet stops.
/obj/structure/table/proc/check_cover(obj/item/projectile/P, turf/from)
Expand Down
Binary file added icons/obj/bench.dmi
Binary file not shown.
1 change: 1 addition & 0 deletions nebula.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,7 @@
#include "code\game\objects\structures\barricade.dm"
#include "code\game\objects\structures\barsign.dm"
#include "code\game\objects\structures\bedsheet_bin.dm"
#include "code\game\objects\structures\benches.dm"
#include "code\game\objects\structures\bookcase.dm"
#include "code\game\objects\structures\catwalk.dm"
#include "code\game\objects\structures\charge_pylon.dm"
Expand Down

0 comments on commit f7e49c5

Please sign in to comment.