mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-12 00:27:31 +01:00
36cdf384ba
## About The Pull Request Closes #91131. The author currently has other priorities, and as I need it for something else I am finishing it myself with the author's blessing. Recently, we turned `transferItemToLoc(...)` into a proc intended to be for transfers to non-turfs, with it now playing an animation to reflect that. However, this had the effect of leaving us with `dropItemToGround(...)` for mob>turf transfers, which isn't _ideal_. It sends an 'item dropped' signal, it randomizes offsets, and using it to transfer to a non-`drop_location()` loc was implemented as an afterthought. So in this pr we create a new proc, `transfer_item_to_turf(...)`, that separates off the actual transferring, setting offsets, and animating into its own proc. Then `dropItemToGround(...)`, tables, racks, easels, closets, hoops, beds, conveyor belts, pin the tail corgi posters, some other stuff, and the `floor_placeable` element call such each with their own preferred arguments. While we could leave setting offsets out of it, because setting the offsets after calling the animation works just fine, having them be set before the animation felt like a more intuitive flow. ...While I would love to refactor the easel's incredibly questionable `attackby(...)`, that is outside of the scope of this pr. ## Why It's Good For The Game Fixes #91082. Less jank 👍 ## Changelog 🆑 fix: Placing an item on a table/turf via the alt-click menu actually centers it, again. fix: Certain items, like canvases or syringe guns, are no longer weirdly offset when placed on tables. fix: Placing items on racks, closets, crates, hoops, beds, conveyor belts, and pin the tail corgi posters is animated again, instead of instantly teleporting followed by the pickup animation. fix: Placing a canvas on an easels no longer applies a random offset as if dropped. fix: Tucking in someone else actually animates the bedsheet from you to them, instead of from them to them. qol: Placing a canvas on an easel is animated. /🆑
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.transfer_item_to_turf(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)
|