Saves roughly 20% off living/Life(), makes gravity event based (#74084)

## About The Pull Request

Right now, each time life processes we need to run has_gravity, and
check its output against a bunch of thresholds.
We could save off that second bit by caching the previous value, but
we'd still be only updating this every 2 seconds.

This potentially delayed updating leads to really janky feeling behavior
around transition points too (like when moving on/off the sand on tram
station)

So instead of doing this updating off life(), let's make it event based.
We'll decompose has_gravity, and take all the values it relies on, and
check for them changing ourselves.
That way we get instant response, and can save all the wasted
has_gravity calls.

This constant checking on movement adds a few signal registrations, a
connect_loc, and some logic on living/Moved

The Moved logic increases Moved's self by 50%, roughly 1 second a round
at worst.
Don't have concrete numbers for the connect_loc

(new self / old self)

![image](https://user-images.githubusercontent.com/58055496/226091990-8cbeef82-6a37-488c-a0b6-cf570156c2dc.png)

In constrast, handle_gravity is currently on average maybe 15 seconds.


![image](https://user-images.githubusercontent.com/58055496/226092056-5fc7fc59-46e2-4e01-a6ee-6867de30c1f0.png)

I could JUST save maybe 13 seconds and not spend the 1 by storing the
previous gravity value, but I think this is worth the ux changes. It
does add some extra resistance to change, but s much nice.

Moved some functions around too, and removed now redundant
update_gravity calls

## Why It's Good For The Game

Snappier gravity, faster Life()

## Changelog
🆑
qol: Human gravity will react to changes instantly, instead of waiting
for the next process tick. Hopefully this feels better and not worse
/🆑
This commit is contained in:
LemonInTheDark
2023-03-25 22:44:27 -06:00
committed by GitHub
parent 5c012d1e8e
commit 5aab9dd88a
15 changed files with 119 additions and 45 deletions
@@ -287,7 +287,6 @@
playsound(src, 'sound/effects/curseattack.ogg', 50)
mod.wearer.AddElement(/datum/element/forced_gravity, NEGATIVE_GRAVITY)
RegisterSignal(mod.wearer, COMSIG_MOVABLE_MOVED, PROC_REF(check_upstairs))
mod.wearer.update_gravity(mod.wearer.has_gravity())
ADD_TRAIT(mod.wearer, TRAIT_SILENT_FOOTSTEPS, MOD_TRAIT)
check_upstairs() //todo at some point flip your screen around
@@ -303,7 +302,6 @@
qdel(mod.wearer.RemoveElement(/datum/element/forced_gravity, NEGATIVE_GRAVITY))
UnregisterSignal(mod.wearer, COMSIG_MOVABLE_MOVED)
step_count = 0
mod.wearer.update_gravity(mod.wearer.has_gravity())
REMOVE_TRAIT(mod.wearer, TRAIT_SILENT_FOOTSTEPS, MOD_TRAIT)
var/turf/open/openspace/current_turf = get_turf(mod.wearer)
if(istype(current_turf))
@@ -74,7 +74,6 @@
if(mod.wearer.has_gravity())
new /obj/effect/temp_visual/mook_dust(get_turf(src))
mod.wearer.AddElement(/datum/element/forced_gravity, 0)
mod.wearer.update_gravity(mod.wearer.has_gravity())
playsound(src, 'sound/effects/gravhit.ogg', 50)
/obj/item/mod/module/anomaly_locked/antigrav/on_deactivation(display_message = TRUE, deleting = FALSE)
@@ -82,7 +81,6 @@
if(!.)
return
mod.wearer.RemoveElement(/datum/element/forced_gravity, 0)
mod.wearer.update_gravity(mod.wearer.has_gravity())
if(deleting)
return
if(mod.wearer.has_gravity())