Leanable component (#21431)

Refactors leanable code into a component, now attached to walls, (full)
windows, doors (of all types), and vending machines. See video for
example behavior.

https://github.com/user-attachments/assets/032d2cb2-17e3-4604-90b6-040e183dccd9
This commit is contained in:
Batrachophreno
2025-10-04 19:50:27 +00:00
committed by GitHub
parent 5fec421dae
commit 0b612d1653
14 changed files with 195 additions and 106 deletions
+4 -8
View File
@@ -103,28 +103,24 @@
return FALSE
/obj/structure/mouse_drop_receive(atom/dropped, mob/user, params)
var/mob/living/H = user
if(istype(H) && can_climb(H) && dropped == user)
do_climb(dropped)
else
return ..()
if(!do_climb(dropped))
return ..()
/obj/structure/proc/can_climb(var/mob/living/user, post_climb_check=0)
if (!climbable)
to_chat(user, SPAN_WARNING("\The [src] cannot be climbed!"))
return FALSE
if (!can_touch(user) || (!post_climb_check && (user in climbers)))
return FALSE
if (!user.Adjacent(src))
to_chat(user, SPAN_WARNING("You must be next to \the [src] to climb it."))
return FALSE
var/obj/occupied = turf_is_crowded()
if(occupied)
to_chat(user, SPAN_WARNING("There's \a [occupied] in the way."))
to_chat(user, SPAN_WARNING("There's \a [occupied] in the way of climbing this."))
return FALSE
return TRUE
@@ -145,7 +141,7 @@
/obj/structure/proc/do_climb(var/mob/living/user)
if (!can_climb(user))
return
return FALSE
user.visible_message(SPAN_WARNING("[user] starts [atom_flags & ATOM_FLAG_CHECKS_BORDER ? "leaping over" : "climbing onto"] \the [src]!"))
LAZYADD(climbers, user)
+4
View File
@@ -781,6 +781,10 @@
qdel(src)
update_nearby_icons()
/obj/structure/window/full/mouse_drop_receive(atom/dropping, mob/user, params)
//Adds the component only once. We do it here & not in Initialize() because there are tons of walls & we don't want to add to their init times
LoadComponent(/datum/component/leanable, dropping)
/********** Full Windows **********/
// Reinforced Window
/obj/structure/window/full/reinforced