mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-20 19:49:39 +01:00
## About The Pull Request So previously I put out a pr that made beds alternate their `buckle_lying` angle based on their current direction, such that you would always use the headrest as a headrest. However, the medical/roller beds have their sprites flipped, and so these would instead always use the headrest as a footrest. This wasn't obvious before as both regular and medical/roller beds would use the headrest on half their directions, just different halves. While we could have fixed this by flipping the sprites on the medical/roller beds, I think it's better to flip their buckling angles instead so that the medical/roller beds maintain how they look while being pulled, so my first thought was to override the `update_buckle_vars(...)` proc with the other directions. However, during testing I realized that these flipped sprites would also affect the `bed_tuckable` element interactions with the code, used to work out how to place certain items onto beds. So instead of just overriding the proc, we add a new var `left_headrest_dirs` that defines the directions for which the headrest faces left, change its value for medical/roller beds, and use this for the `update_buckle_vars(...)` proc and `bed_tuckle` element. This fixes our issues. As a side-effect, this also fixes an issue where `bed_tuckable` would consider north-facing regular beds as if their headrest was on the right rather than on the left. <details> <summary>Images</summary>     </details> ## Why It's Good For The Game Fixes part of #86521. Good to not use the headrest as a footrest all the time. ## Changelog 🆑 fix: Fixed being buckled to medical/roller beds making you always use the headrest as a footrest. fix: Fixed bedsheets/diskies/plushies/etc put on medical/roller beds facing the wrong direction. fix: Fixed bedsheets/diskies/plushies/etc put on any bed facing the wrong direction on some beds. /🆑
74 lines
2.5 KiB
Plaintext
74 lines
2.5 KiB
Plaintext
/// Tucking element, for things that can be tucked into bed.
|
|
/datum/element/bed_tuckable
|
|
element_flags = ELEMENT_BESPOKE
|
|
argument_hash_start_idx = 3
|
|
/// our pixel_x offset - how much the item moves x when in bed (+x is closer to the pillow)
|
|
var/x_offset = 0
|
|
/// our pixel_y offset - how much the item move y when in bed (-y is closer to the middle)
|
|
var/y_offset = 0
|
|
/// our rotation degree - how many degrees we need to turn the item to get to the left/right side
|
|
var/rotation_degree = 0
|
|
/// our starting angle for the item
|
|
var/starting_angle = 0
|
|
|
|
/datum/element/bed_tuckable/Attach(obj/target, mapload = FALSE, x = 0, y = 0, rotation = 0)
|
|
. = ..()
|
|
if(!isitem(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
|
|
x_offset = x
|
|
y_offset = y
|
|
starting_angle = rotation
|
|
RegisterSignal(target, COMSIG_ITEM_ATTACK_ATOM, PROC_REF(tuck_into_bed))
|
|
if(!mapload)
|
|
return
|
|
var/turf/our_home = get_turf(target)
|
|
var/obj/structure/bed/eepy = locate(/obj/structure/bed) in our_home
|
|
if(isnull(eepy))
|
|
return
|
|
tuck(target, eepy)
|
|
|
|
/datum/element/bed_tuckable/Detach(obj/target)
|
|
. = ..()
|
|
UnregisterSignal(target, list(COMSIG_ITEM_ATTACK_ATOM, COMSIG_ITEM_PICKUP))
|
|
|
|
/**
|
|
* Tuck our object into bed.
|
|
*
|
|
* tucked - the object being tucked
|
|
* target_bed - the bed we're tucking them into
|
|
* tucker - the guy doing the tucking
|
|
*/
|
|
/datum/element/bed_tuckable/proc/tuck_into_bed(obj/item/tucked, obj/structure/bed/target_bed, mob/living/tucker)
|
|
SIGNAL_HANDLER
|
|
|
|
if(!istype(target_bed))
|
|
return
|
|
|
|
if(!tucker.transferItemToLoc(tucked, target_bed.drop_location()))
|
|
return
|
|
|
|
to_chat(tucker, span_notice("You lay [tucked] out on [target_bed]."))
|
|
tuck(tucked, target_bed)
|
|
return COMPONENT_NO_AFTERATTACK
|
|
|
|
/datum/element/bed_tuckable/proc/tuck(obj/item/tucked, obj/structure/bed/target_bed)
|
|
tucked.dir = target_bed.dir & target_bed.left_headrest_dirs ? EAST : WEST
|
|
tucked.pixel_x = target_bed.dir & target_bed.left_headrest_dirs ? -x_offset : x_offset
|
|
tucked.pixel_y = y_offset
|
|
if(starting_angle)
|
|
rotation_degree = target_bed.dir & target_bed.left_headrest_dirs ? starting_angle + 180 : starting_angle
|
|
tucked.transform = turn(tucked.transform, rotation_degree)
|
|
RegisterSignal(tucked, COMSIG_ITEM_PICKUP, PROC_REF(untuck))
|
|
|
|
/**
|
|
* If we rotate our object, then we need to un-rotate it when it's picked up
|
|
*
|
|
* tucked - the object that is tucked
|
|
*/
|
|
/datum/element/bed_tuckable/proc/untuck(obj/item/tucked)
|
|
SIGNAL_HANDLER
|
|
|
|
tucked.transform = turn(tucked.transform, -rotation_degree)
|
|
UnregisterSignal(tucked, COMSIG_ITEM_PICKUP)
|