mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-25 16:45:42 +00:00
This is a pretty big change all around. The gist of it is that it moves the mobility_flags into traits or variables that can track the sources, and to which we can append code to react to the events, be it via signals or via on_event-like procs. For example, MOBILITY_STAND could mean, depending on context, that the mob is either already standing or that it may be able to stand, and thus is lying down. There was a lot of snowflakery and redefinitions on top of redefinitions, so this is bound to create bugs I'm willing to fix as I learn them. The end-goal is for every living mob to use the same mobility system, for the traits to mean the same among them, and for no place to just mass-change settings without a way to trace it, such as with mobility_flags = NONE and mobility_flags = ALL Fixes AIs being able to strip nearby people. They've lost their hands usage.
43 lines
1.3 KiB
Plaintext
43 lines
1.3 KiB
Plaintext
#define SHORT 5/7
|
|
#define TALL 7/5
|
|
|
|
/**
|
|
# squish.dm
|
|
*
|
|
* It's an element that squishes things. After the duration passes, it reverses the transformation it squished with, taking into account if they are a different orientation than they started (read: rotationally-fluid)
|
|
*
|
|
* Normal squishes apply vertically, as if the target is being squished from above, but you can set reverse to TRUE if you want to squish them from the sides, like if they pancake into a wall from the East or West
|
|
*/
|
|
/datum/element/squish
|
|
element_flags = ELEMENT_DETACH
|
|
|
|
/datum/element/squish/Attach(datum/target, duration=20 SECONDS, reverse=FALSE)
|
|
. = ..()
|
|
if(!iscarbon(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
|
|
var/mob/living/carbon/C = target
|
|
var/was_lying = C.body_position == LYING_DOWN
|
|
addtimer(CALLBACK(src, .proc/Detach, C, was_lying, reverse), duration)
|
|
|
|
if(reverse)
|
|
C.transform = C.transform.Scale(SHORT, TALL)
|
|
else
|
|
C.transform = C.transform.Scale(TALL, SHORT)
|
|
|
|
/datum/element/squish/Detach(mob/living/carbon/C, was_lying, reverse)
|
|
. = ..()
|
|
if(istype(C))
|
|
var/is_lying = C.body_position == LYING_DOWN
|
|
|
|
if(reverse)
|
|
is_lying = !is_lying
|
|
|
|
if(was_lying == is_lying)
|
|
C.transform = C.transform.Scale(SHORT, TALL)
|
|
else
|
|
C.transform = C.transform.Scale(TALL, SHORT)
|
|
|
|
#undef SHORT
|
|
#undef TALL
|