mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 23:27:34 +01:00
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)  In constrast, handle_gravity is currently on average maybe 15 seconds.  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:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user