Files
Bubberstation/code/datums/elements/wheel.dm
Ben10Omintrix 91baa94ac5 event based incapicated and able_to_run (#86031)
## About The Pull Request
this is a revival of #82635 . i got permission from potato to reopen
this, he did almost all the work. i only just solved the conflicts and
fixed all the bugs that were preventing the original from being merged
(but it should be TMed first)

## Why It's Good For The Game
slightly improves the performance of basic mob AI

## Changelog
🆑
LemonInTheDark
refactor: able_to_run and incapacitated have been refactored to be event
based
/🆑

---------

Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
Co-authored-by: ZephyrTFA <matthew@tfaluc.com>
2024-09-04 10:02:49 -04:00

29 lines
936 B
Plaintext

/// Element which spins you as you move
/datum/element/wheel
/datum/element/wheel/Attach(datum/target)
. = ..()
if(!ismovable(target))
return ELEMENT_INCOMPATIBLE
RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved))
/datum/element/wheel/Detach(datum/source)
. = ..()
UnregisterSignal(source, COMSIG_MOVABLE_MOVED)
/datum/element/wheel/proc/on_moved(atom/movable/moved, atom/oldloc, direction, forced)
SIGNAL_HANDLER
if(forced || CHECK_MOVE_LOOP_FLAGS(moved, MOVEMENT_LOOP_OUTSIDE_CONTROL))
return
if(isliving(moved))
var/mob/living/living_moved = moved
if (living_moved.incapacitated || living_moved.body_position == LYING_DOWN)
return
var/rotation_degree = (360 / 3)
if(direction & SOUTHWEST)
rotation_degree *= -1
var/matrix/to_turn = matrix(moved.transform)
to_turn = turn(moved.transform, rotation_degree)
animate(moved, transform = to_turn, time = 0.1 SECONDS, flags = ANIMATION_PARALLEL)