Skip to content

Commit

Permalink
Merge pull request #4835 from out-of-phaze/codequality/chair-icon-split
Browse files Browse the repository at this point in the history
Separate beds and chairs out of furniture.dmi, groundwork for eventual de-bedding of chairs
  • Loading branch information
MistakeNot4892 authored Feb 4, 2025
2 parents 72752db + 70162a5 commit 69466a2
Show file tree
Hide file tree
Showing 66 changed files with 206 additions and 222 deletions.
6 changes: 6 additions & 0 deletions code/game/objects/structures/__structure.dm
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@
)
victim.standard_weapon_hit_effects(S, user, S.expend_attack_force()*2, BP_HEAD)
qdel(grab)
return TRUE
else if(can_buckle && !buckled_mob && istype(victim) && istype(user))
user.visible_message(SPAN_NOTICE("\The [user] attempts to put \the [victim] onto \the [src]!"))
if(do_after(user, 2 SECONDS, src) && !QDELETED(victim) && !QDELETED(user) && !QDELETED(grab) && user_buckle_mob(victim, user))
qdel(grab)
return TRUE
else if(atom_flags & ATOM_FLAG_CLIMBABLE)
var/obj/occupied = turf_is_crowded()
if (occupied)
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/structures/_structure_icon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var/global/list/default_noblend_objects = list(/obj/machinery/door/window, /obj/

var/list/dirs
var/list/other_dirs
// TODO: Allow structures to limit dirs?
for(var/direction in global.alldirs)
var/turf/T = get_step(src, direction)
if(T)
Expand Down
36 changes: 15 additions & 21 deletions code/game/objects/structures/beds/bed.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
// TODO by end of Q2 2025: Repath /obj/structure/bed/chair to just /obj/structure/chair.
// Remaining steps:
// - Move padding interactions and padding_color var onto an extension
// - Allow /obj/structure/grab_attack to handle buckling
/obj/structure/bed
name = "bed"
desc = "A raised, padded platform for sleeping on. This one has straps for ensuring restful snoozing in microgravity."
icon = 'icons/obj/furniture.dmi'
icon_state = "bed"
icon = 'icons/obj/structures/furniture/bed.dmi'
icon_state = ICON_STATE_WORLD
anchored = TRUE
can_buckle = TRUE
buckle_dir = SOUTH
Expand All @@ -20,7 +19,6 @@
parts_type = /obj/item/stack/material/rods
user_comfort = 1
obj_flags = OBJ_FLAG_SUPPORT_MOB
var/base_icon = "bed"
var/padding_color

/obj/structure/bed/user_can_mousedrop_onto(mob/user, atom/being_dropped, incapacitation_flags, params)
Expand All @@ -37,24 +35,29 @@
/obj/structure/bed/get_surgery_success_modifier(delicate)
return delicate ? -5 : 0

/obj/structure/bed/update_material_name()
/obj/structure/bed/update_material_name(override_name)
var/base_name = override_name || initial(name)
var/new_name = base_name
if(reinf_material)
SetName("[reinf_material.adjective_name] [initial(name)]")
new_name = "[reinf_material.adjective_name] [base_name]"
else if(material)
SetName("[material.adjective_name] [initial(name)]")
else
SetName(initial(name))
new_name = "[material.adjective_name] [base_name]"
if(name_prefix)
new_name = "[name_prefix] [new_name]"
SetName(new_name)

/obj/structure/bed/update_material_desc()
if(reinf_material)
desc = "[initial(desc)] It's made of [material.use_name] and covered with [reinf_material.use_name]."
else
desc = "[initial(desc)] It's made of [material.use_name]."

// Reuse the cache/code from stools, todo maybe unify.
/obj/structure/bed/proc/get_base_icon()
return ICON_STATE_WORLD

/obj/structure/bed/on_update_icon()
..()
icon_state = base_icon
icon_state = get_base_icon()
if(istype(reinf_material))
if(material_alteration & MAT_FLAG_ALTERATION_COLOR)
add_overlay(overlay_image(icon, "[icon_state]_padding", padding_color || reinf_material.color, RESET_COLOR))
Expand Down Expand Up @@ -122,15 +125,6 @@
remove_padding()
return TRUE

/obj/structure/bed/grab_attack(obj/item/grab/grab, mob/user)
var/mob/living/victim = grab.get_affecting_mob()
if(istype(victim) && istype(user))
user.visible_message(SPAN_NOTICE("\The [user] attempts to put \the [victim] onto \the [src]!"))
if(do_after(user, 2 SECONDS, src) && !QDELETED(victim) && !QDELETED(user) && !QDELETED(grab) && user_buckle_mob(victim, user))
qdel(grab)
return TRUE
return ..()

/obj/structure/bed/proc/add_padding(var/padding_type, var/new_padding_color)
reinf_material = GET_DECL(padding_type)
padding_color = new_padding_color
Expand All @@ -149,7 +143,7 @@
/obj/structure/bed/psych
name = "psychiatrist's couch"
desc = "For prime comfort during psychiatric evaluations."
icon_state = "psychbed"
icon = 'icons/obj/structures/furniture/bed_psych.dmi'
material = /decl/material/solid/organic/wood/walnut

/obj/structure/bed/psych/leather
Expand Down
4 changes: 1 addition & 3 deletions code/game/objects/structures/beds/bedroll.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/obj/item/bedroll
name = "bedroll"
desc = "A thick, padded bag big enough for a human to huddle in, rolled into a tight tube for easy-ish transport."
icon = 'icons/obj/structures/bedroll.dmi'
icon = 'icons/obj/structures/bedroll_rolled.dmi'
icon_state = ICON_STATE_WORLD
w_class = ITEM_SIZE_LARGE
material = /decl/material/solid/organic/leather
Expand Down Expand Up @@ -44,8 +44,6 @@
desc = "A thick, padded bag big enough for a human to huddle in. It's better than sleeping on the ground."
user_comfort = 0.65
icon = 'icons/obj/structures/bedroll.dmi'
icon_state = "bedroll"
base_icon = "bedroll"
w_class = ITEM_SIZE_LARGE
anchored = FALSE
material = /decl/material/solid/organic/leather
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/beds/simple_bed.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/obj/structure/bed/simple
desc = "A slatted wooden bed."
icon = 'icons/obj/structures/simple_bed.dmi'
icon = 'icons/obj/structures/furniture/bed_simple.dmi'
icon_state = "bed_padded_preview" // For map editor preview purposes
parts_type = /obj/item/stack/material/plank
material = /decl/material/solid/organic/wood/oak
Expand Down
18 changes: 0 additions & 18 deletions code/game/objects/structures/beds/travois.dm

This file was deleted.

103 changes: 46 additions & 57 deletions code/game/objects/structures/benches/bench.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,109 +2,98 @@
/obj/structure/bed/chair/bench
name = "bench"
desc = "A simple slatted bench."
icon = 'icons/obj/structures/benches.dmi'
icon_state = "bench_standing"
base_icon = "bench"
icon = 'icons/obj/structures/furniture/bench.dmi'
icon_state = ICON_STATE_WORLD + "_standing"
color = WOOD_COLOR_GENERIC
reinf_material = null
material = /decl/material/solid/organic/wood/oak
obj_flags = 0
anchored = TRUE
var/connect_neighbors = TRUE
/// A bitfield of connected neighbors.
var/neighbors = 0

/obj/structure/bed/chair/bench/should_have_alpha_mask()
return simulated && isturf(loc) && connect_neighbors && !(locate(/obj/structure/bed/chair/bench) in get_step(loc, SOUTH))
if(!simulated || !isturf(loc))
return FALSE
var/obj/structure/bed/chair/bench/south_neighbor = locate() in get_step(loc, SOUTH)
if(can_visually_connect_to(south_neighbor)) // if we're connected to a south neighbor don't add an alpha mask
return TRUE
return TRUE

/obj/structure/bed/chair/bench/single
name = "slatted seat"
base_icon = "bench_standing"
anchored = FALSE
connect_neighbors = FALSE
// TODO: make this use the generic structure smoothing system?
/obj/structure/bed/chair/bench/can_visually_connect_to(var/obj/structure/bed/chair/bench/other)
return istype(other) && other.dir == dir && other.icon == icon && other.material == material

/obj/structure/bed/chair/bench/Initialize(mapload)
. = ..()
if(connect_neighbors)
. = INITIALIZE_HINT_LATELOAD
..()
return INITIALIZE_HINT_LATELOAD

/obj/structure/bed/chair/bench/LateInitialize(mapload)
..()
if(connect_neighbors)
if(mapload)
update_base_icon()
else
update_neighbors()
if(mapload)
recalculate_connections()
else
update_neighbors()

/obj/structure/bed/chair/bench/Destroy()
var/oldloc = loc
. = ..()
if(connect_neighbors)
update_neighbors(oldloc)
update_neighbors(oldloc)

/obj/structure/bed/chair/bench/set_dir()
var/olddir = dir
. = ..()
if(. && connect_neighbors)
if(.)
update_neighbors(update_dir = olddir, skip_icon_update = TRUE)
update_neighbors(update_dir = dir)

/obj/structure/bed/chair/bench/Move()
var/oldloc = loc
. = ..()
if(. && connect_neighbors)
if(.)
update_neighbors(oldloc, skip_icon_update = TRUE)
update_neighbors(loc)

/obj/structure/bed/chair/bench/proc/update_neighbors(update_loc = loc, update_dir = dir, skip_icon_update)
if(!connect_neighbors)
return
if(!skip_icon_update)
update_base_icon()
recalculate_connections()
if(!isturf(update_loc))
return
for(var/stepdir in list(turn(update_dir, -90), turn(update_dir, 90)))
for(var/obj/structure/bed/chair/bench/other in get_step(update_loc, stepdir))
other.update_base_icon()

/obj/structure/bed/chair/bench/proc/update_base_icon()

if(!connect_neighbors)
return

base_icon = initial(base_icon)
other.recalculate_connections()

// TODO: Make this use base structure smoothing eventually? Somehow?
/obj/structure/bed/chair/bench/proc/recalculate_connections()
neighbors = 0
if(!isturf(loc))
base_icon = "[base_icon]_standing"
neighbors = 0
else
var/neighbors = 0
var/left_dir = turn(dir, -90)
var/right_dir = turn(dir, 90)
for(var/checkdir in list(left_dir, right_dir))
for(var/checkdir in list(turn(dir, -90), turn(dir, 90)))
var/turf/check_turf = get_step(loc, checkdir)
for(var/obj/structure/bed/chair/bench/other in check_turf)
if(other.connect_neighbors && other.dir == dir && initial(other.base_icon) == base_icon && other.material == material)
// TODO: Make this use normal structure smoothing helpers.
if(other.dir == dir && other.icon == icon && other.material == material)
neighbors |= checkdir
break

if(neighbors & left_dir)
if(neighbors & right_dir)
base_icon = "[base_icon]_middle"
else
base_icon = "[base_icon]_right"
else if(neighbors & right_dir)
base_icon = "[base_icon]_left"
else
base_icon = "[base_icon]_standing"

update_icon()

/obj/structure/bed/chair/bench/proc/get_material_icon()
return material?.bench_icon

/obj/structure/bed/chair/bench/update_materials()
/obj/structure/bed/chair/bench/get_base_icon()
. = ..()
var/icon/material_icon = get_material_icon()
if(material_icon)
icon = material_icon
var/left_dir = turn(dir, -90)
var/right_dir = turn(dir, 90)
if(neighbors & left_dir)
if(neighbors & right_dir)
. += "_middle"
else
. += "_right"
else if(neighbors & right_dir)
. += "_left"
else
. += "_standing"

/obj/structure/bed/chair/bench/get_material_icon()
return material?.bench_icon || initial(icon)

/obj/structure/bed/chair/bench/mahogany
color = WOOD_COLOR_RICH
Expand Down
7 changes: 3 additions & 4 deletions code/game/objects/structures/benches/lounge.dm
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/obj/structure/bed/chair/bench/lounge
name = "lounge"
desc = "An elegant lounge, perfect for reclining on."
icon = 'icons/obj/structures/lounge.dmi'
icon_state = "lounge_standing"
base_icon = "lounge"
icon = 'icons/obj/structures/furniture/lounge.dmi'

// Just use the existing icon.
/obj/structure/bed/chair/bench/lounge/get_material_icon()
return icon
return icon || initial(icon)

/obj/structure/bed/chair/bench/lounge/mapped
color = /decl/material/solid/organic/wood/mahogany::color
Expand Down
12 changes: 2 additions & 10 deletions code/game/objects/structures/benches/pew.dm
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
/obj/structure/bed/chair/bench/pew
name = "pew"
desc = "A long bench with a backboard, commonly found in places of worship, courtrooms and so on. Not known for being particularly comfortable."
icon = 'icons/obj/structures/pews.dmi'
icon_state = "pew_standing"
base_icon = "pew"
icon = 'icons/obj/structures/furniture/pew.dmi'

/obj/structure/bed/chair/bench/pew/get_material_icon()
return material?.pew_icon

/obj/structure/bed/chair/bench/pew/single
name = "backed chair"
desc = "A tall chair with a sturdy back. Not very comfortable."
base_icon = "pew_standing"
connect_neighbors = FALSE
return material?.pew_icon || initial(icon)

/obj/structure/bed/chair/bench/pew/mahogany
color = /decl/material/solid/organic/wood/mahogany::color
Expand Down
Loading

0 comments on commit 69466a2

Please sign in to comment.