mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-27 09:31:54 +00:00
## 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 /🆑
131 lines
5.0 KiB
Plaintext
131 lines
5.0 KiB
Plaintext
//Science modules for MODsuits
|
|
|
|
///Reagent Scanner - Lets the user scan reagents.
|
|
/obj/item/mod/module/reagent_scanner
|
|
name = "MOD reagent scanner module"
|
|
desc = "A module based off research-oriented Nanotrasen HUDs, this is capable of scanning the contents of \
|
|
containers and projecting the information in an easy-to-read format on the wearer's display. \
|
|
It cannot detect flavors, so that's up to you."
|
|
icon_state = "scanner"
|
|
module_type = MODULE_TOGGLE
|
|
complexity = 1
|
|
active_power_cost = DEFAULT_CHARGE_DRAIN * 0.2
|
|
incompatible_modules = list(/obj/item/mod/module/reagent_scanner)
|
|
cooldown_time = 0.5 SECONDS
|
|
|
|
/obj/item/mod/module/reagent_scanner/on_activation()
|
|
. = ..()
|
|
if(!.)
|
|
return
|
|
ADD_TRAIT(mod.wearer, TRAIT_REAGENT_SCANNER, MOD_TRAIT)
|
|
|
|
/obj/item/mod/module/reagent_scanner/on_deactivation(display_message = TRUE, deleting = FALSE)
|
|
. = ..()
|
|
if(!.)
|
|
return
|
|
REMOVE_TRAIT(mod.wearer, TRAIT_REAGENT_SCANNER, MOD_TRAIT)
|
|
|
|
/obj/item/mod/module/reagent_scanner/advanced
|
|
name = "MOD advanced reagent scanner module"
|
|
complexity = 0
|
|
removable = FALSE
|
|
var/explosion_detection_dist = 21
|
|
|
|
/obj/item/mod/module/reagent_scanner/advanced/on_activation()
|
|
. = ..()
|
|
if(!.)
|
|
return
|
|
ADD_TRAIT(mod.wearer, TRAIT_RESEARCH_SCANNER, MOD_TRAIT)
|
|
RegisterSignal(SSdcs, COMSIG_GLOB_EXPLOSION, PROC_REF(sense_explosion))
|
|
|
|
/obj/item/mod/module/reagent_scanner/advanced/on_deactivation(display_message = TRUE, deleting = FALSE)
|
|
. = ..()
|
|
if(!.)
|
|
return
|
|
REMOVE_TRAIT(mod.wearer, TRAIT_RESEARCH_SCANNER, MOD_TRAIT)
|
|
UnregisterSignal(SSdcs, COMSIG_GLOB_EXPLOSION)
|
|
|
|
/obj/item/mod/module/reagent_scanner/advanced/proc/sense_explosion(datum/source, turf/epicenter,
|
|
devastation_range, heavy_impact_range, light_impact_range, took, orig_dev_range, orig_heavy_range, orig_light_range)
|
|
SIGNAL_HANDLER
|
|
var/turf/wearer_turf = get_turf(mod.wearer)
|
|
if(!is_valid_z_level(wearer_turf, epicenter))
|
|
return
|
|
if(get_dist(epicenter, wearer_turf) > explosion_detection_dist)
|
|
return
|
|
to_chat(mod.wearer, span_notice("Explosion detected! Epicenter: [devastation_range], Outer: [heavy_impact_range], Shock: [light_impact_range]"))
|
|
|
|
///Anti-Gravity - Makes the user weightless.
|
|
/obj/item/mod/module/anomaly_locked/antigrav
|
|
name = "MOD anti-gravity module"
|
|
desc = "A module that uses a gravitational core to make the user completely weightless."
|
|
icon_state = "antigrav"
|
|
module_type = MODULE_TOGGLE
|
|
complexity = 3
|
|
active_power_cost = DEFAULT_CHARGE_DRAIN * 0.7
|
|
incompatible_modules = list(/obj/item/mod/module/anomaly_locked, /obj/item/mod/module/atrocinator)
|
|
cooldown_time = 0.5 SECONDS
|
|
accepted_anomalies = list(/obj/item/assembly/signaler/anomaly/grav)
|
|
|
|
/obj/item/mod/module/anomaly_locked/antigrav/on_activation()
|
|
. = ..()
|
|
if(!.)
|
|
return
|
|
if(mod.wearer.has_gravity())
|
|
new /obj/effect/temp_visual/mook_dust(get_turf(src))
|
|
mod.wearer.AddElement(/datum/element/forced_gravity, 0)
|
|
playsound(src, 'sound/effects/gravhit.ogg', 50)
|
|
|
|
/obj/item/mod/module/anomaly_locked/antigrav/on_deactivation(display_message = TRUE, deleting = FALSE)
|
|
. = ..()
|
|
if(!.)
|
|
return
|
|
mod.wearer.RemoveElement(/datum/element/forced_gravity, 0)
|
|
if(deleting)
|
|
return
|
|
if(mod.wearer.has_gravity())
|
|
new /obj/effect/temp_visual/mook_dust(get_turf(src))
|
|
playsound(src, 'sound/effects/gravhit.ogg', 50)
|
|
|
|
/obj/item/mod/module/anomaly_locked/antigrav/prebuilt
|
|
prebuilt = TRUE
|
|
|
|
///Teleporter - Lets the user teleport to a nearby location.
|
|
/obj/item/mod/module/anomaly_locked/teleporter
|
|
name = "MOD teleporter module"
|
|
desc = "A module that uses a bluespace core to let the user transport their particles elsewhere."
|
|
icon_state = "teleporter"
|
|
module_type = MODULE_ACTIVE
|
|
complexity = 3
|
|
use_power_cost = DEFAULT_CHARGE_DRAIN * 5
|
|
cooldown_time = 5 SECONDS
|
|
accepted_anomalies = list(/obj/item/assembly/signaler/anomaly/bluespace)
|
|
/// Time it takes to teleport
|
|
var/teleport_time = 3 SECONDS
|
|
|
|
/obj/item/mod/module/anomaly_locked/teleporter/on_select_use(atom/target)
|
|
. = ..()
|
|
if(!.)
|
|
return
|
|
var/turf/open/target_turf = get_turf(target)
|
|
if(!istype(target_turf) || target_turf.is_blocked_turf_ignore_climbable() || !(target_turf in view(mod.wearer)))
|
|
balloon_alert(mod.wearer, "invalid target!")
|
|
return
|
|
balloon_alert(mod.wearer, "teleporting...")
|
|
var/matrix/pre_matrix = matrix()
|
|
pre_matrix.Scale(4, 0.25)
|
|
var/matrix/post_matrix = matrix()
|
|
post_matrix.Scale(0.25, 4)
|
|
animate(mod.wearer, teleport_time, color = COLOR_CYAN, transform = pre_matrix.Multiply(mod.wearer.transform), easing = SINE_EASING|EASE_OUT)
|
|
if(!do_after(mod.wearer, teleport_time, target = mod))
|
|
balloon_alert(mod.wearer, "interrupted!")
|
|
animate(mod.wearer, teleport_time*0.1, color = null, transform = post_matrix.Multiply(mod.wearer.transform), easing = SINE_EASING|EASE_IN)
|
|
return
|
|
animate(mod.wearer, teleport_time*0.1, color = null, transform = post_matrix.Multiply(mod.wearer.transform), easing = SINE_EASING|EASE_IN)
|
|
if(!do_teleport(mod.wearer, target_turf, asoundin = 'sound/effects/phasein.ogg'))
|
|
return
|
|
drain_power(use_power_cost)
|
|
|
|
/obj/item/mod/module/anomaly_locked/teleporter/prebuilt
|
|
prebuilt = TRUE
|